Package facebook4j.internal.org.json

Examples of facebook4j.internal.org.json.JSONObject


    static ResponseList<Account> createAccountList(HttpResponse res, Configuration conf) throws FacebookException {
        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Account> accounts = new ResponseListImpl<Account>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject accountJSONObject = list.getJSONObject(i);
                Account account = new AccountJSONImpl(accountJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(account, accountJSONObject);
                }
                accounts.add(account);
View Full Code Here


    static ResponseList<Book> createBookList(HttpResponse res, Configuration conf) throws FacebookException {
        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Book> books = new ResponseListImpl<Book>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject bookJSONObject = list.getJSONObject(i);
                Book book = new BookJSONImpl(bookJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(book, bookJSONObject);
                }
                books.add(book);
View Full Code Here

    public static Map<String, String> getStringMap(String name, JSONObject json) throws FacebookException {
        if (json.isNull(name)) {
            return Collections.emptyMap();
        }
        try {
            JSONObject jsonObject = json.getJSONObject(name);
            HashMap<String, String> result = new HashMap<String, String>();
            @SuppressWarnings("unchecked")
            Iterator<String> keys = jsonObject.keys();
            while (keys.hasNext()) {
                String key = (String) keys.next();
                result.put(key, jsonObject.getString(key));
            }
            return result;
        } catch (JSONException jsone) {
            throw new FacebookException(jsone.getMessage(), jsone);
        }
View Full Code Here

    public static Map<String, Long> getLongMap(String name, JSONObject json) throws FacebookException {
        if (json.isNull(name)) {
            return Collections.emptyMap();
        }
        try {
            JSONObject jsonObject = json.getJSONObject(name);
            HashMap<String, Long> result = new HashMap<String, Long>();
            @SuppressWarnings("unchecked")
            Iterator<String> keys = jsonObject.keys();
            while (keys.hasNext()) {
                String key = (String) keys.next();
                result.put(key, jsonObject.getLong(key));
            }
            return result;
        } catch (JSONException jsone) {
            throw new FacebookException(jsone.getMessage(), jsone);
        }
View Full Code Here

    public static Map<String, Boolean> getBooleanMap(String name, JSONObject json) throws FacebookException {
        if (json.isNull(name)) {
            return Collections.emptyMap();
        }
        try {
            JSONObject jsonObject = json.getJSONObject(name);
            HashMap<String, Boolean> result = new HashMap<String, Boolean>();
            @SuppressWarnings("unchecked")
            Iterator<String> keys = jsonObject.keys();
            while (keys.hasNext()) {
                String key = (String) keys.next();
                result.put(key, jsonObject.getBoolean(key));
            }
            return result;
        } catch (JSONException jsone) {
            throw new FacebookException(jsone.getMessage(), jsone);
        }
View Full Code Here

    private String type;
    private Privacy privacy;

    /*package*/LinkJSONImpl(HttpResponse res, Configuration conf) throws FacebookException {
        super(res);
        JSONObject json = res.asJSONObject();
        init(json);
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
            DataObjectFactoryUtil.registerJSONObject(this, json);
        }
View Full Code Here

    private void init(JSONObject json) throws FacebookException {
        try {
            id = getRawString("id", json);
            if (!json.isNull("from")) {
                JSONObject fromJSONObject = json.getJSONObject("from");
                from = new IdNameEntityJSONImpl(fromJSONObject);
            }
            link = getRawString("link", json);
            name = getRawString("name", json);
            if (!json.isNull("likes")) {
                JSONObject likesJSONObject = json.getJSONObject("likes");
                if (!likesJSONObject.isNull("data")) {
                    JSONArray list = likesJSONObject.getJSONArray("data");
                    final int size = list.length();
                    likes = new PagableListImpl<Like>(size, likesJSONObject);
                    for (int i = 0; i < size; i++) {
                        LikeJSONImpl like = new LikeJSONImpl(list.getJSONObject(i));
                        likes.add(like);
                    }
                } else {
                    likes = new PagableListImpl<Like>(1, likesJSONObject);
                }
            } else {
                likes = new PagableListImpl<Like>(0);
            }
            if (!json.isNull("comments")) {
                JSONObject commentsJSONObject = json.getJSONObject("comments");
                if (!commentsJSONObject.isNull("data")) {
                    JSONArray list = commentsJSONObject.getJSONArray("data");
                    final int size = list.length();
                    comments = new PagableListImpl<Comment>(size, commentsJSONObject);
                    for (int i = 0; i < size; i++) {
                        CommentJSONImpl tag = new CommentJSONImpl(list.getJSONObject(i));
                        comments.add(tag);
                    }
                } else {
                    comments = new PagableListImpl<Comment>(1, commentsJSONObject);
                }
            } else {
                comments = new PagableListImpl<Comment>(0);
            }
            description = getRawString("description", json);
            icon = getRawString("icon", json);
            picture = getRawString("picture", json);
            message = getRawString("message", json);
            createdTime = getISO8601Datetime("created_time", json);
            type = getRawString("type", json);
            if (!json.isNull("privacy")) {
                JSONObject privacyJSONObject = json.getJSONObject("privacy");
                privacy = new PrivacyJSONImpl(privacyJSONObject);
            }
        } catch (JSONException jsone) {
            throw new FacebookException(jsone.getMessage(), jsone);
        }
View Full Code Here

    static ResponseList<Link> createLinkList(HttpResponse res, Configuration conf) throws FacebookException {
        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Link> links = new ResponseListImpl<Link>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject linkJSONObject = list.getJSONObject(i);
                Link link = new LinkJSONImpl(linkJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(link, linkJSONObject);
                }
                links.add(link);
View Full Code Here

    private Date createdTime;
    private Date updatedTime;

    /*package*/MilestoneJSONImpl(HttpResponse res, Configuration conf) throws FacebookException {
        super(res);
        JSONObject json = res.asJSONObject();
        init(json);
        if (conf.isJSONStoreEnabled()) {
            DataObjectFactoryUtil.clearThreadLocalMap();
            DataObjectFactoryUtil.registerJSONObject(this, json);
        }
View Full Code Here

    static ResponseList<Milestone> createMilestoneList(HttpResponse res, Configuration conf) throws FacebookException {
        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Milestone> milestones = new ResponseListImpl<Milestone>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject eventJSONObject = list.getJSONObject(i);
                Milestone milestone = new MilestoneJSONImpl(eventJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(milestone, eventJSONObject);
                }
                milestones.add(milestone);
View Full Code Here

TOP

Related Classes of facebook4j.internal.org.json.JSONObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.