Package facebook4j.internal.org.json

Examples of facebook4j.internal.org.json.JSONArray


        return headers;
    }

    private void cacheHeaders() {
        try {
            JSONArray array = json.getJSONArray("headers");
            for (int i = 0; i < array.length(); i++) {
                JSONObject headersJsonObject = array.getJSONObject(i);
                String n = getRawString("name", headersJsonObject);
                String v = getRawString("value", headersJsonObject);
                synchronized (headers) {
                    List<String> values = headers.get(n);
                    if (values == null) {
View Full Code Here


    @Override
    public JSONArray asJSONArray() throws FacebookException {
        if (bodyJsonArray == null) {
            try {
                bodyJsonArray = new JSONArray(asString());
                if (CONF.isPrettyDebugEnabled()) {
                    logger.debug(bodyJsonArray.toString(1));
                } else {
                    logger.debug(responseAsString != null ? responseAsString : bodyJsonArray.toString());
                }
View Full Code Here

        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Movie> movies = new ResponseListImpl<Movie>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject movieJSONObject = list.getJSONObject(i);
                Movie movie = new MovieJSONImpl(movieJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(movie, movieJSONObject);
                }
                movies.add(movie);
View Full Code Here

            if (!json.isNull("from")) {
                JSONObject fromJSONObject = json.getJSONObject("from");
                from = new CategoryJSONImpl(fromJSONObject);
            }
            if (!json.isNull("to")) {
                JSONArray toJSONArray = json.getJSONObject("to").getJSONArray("data");
                to = new ArrayList<IdNameEntity>();
                for (int i = 0; i < toJSONArray.length(); i++) {
                    JSONObject toJSONObject = toJSONArray.getJSONObject(i);
                    to.add(new IdNameEntityJSONImpl(toJSONObject));
                }
            } else {
                to = Collections.emptyList();
            }
            message = getRawString("message", json);
            if (!json.isNull("message_tags")) {
                String raw = json.get("message_tags").toString();
                if (raw.startsWith("[")) {
                    JSONArray tagsJSONArray = json.getJSONArray("message_tags");
                    messageTags = new ArrayList<Tag>();
                    for (int i = 0; i < tagsJSONArray.length(); i++) {
                        JSONObject tagJSONObject = tagsJSONArray.getJSONObject(i);
                        messageTags.add(new TagJSONImpl(tagJSONObject));
                    }
                } else {
                    JSONObject tagsJSONObject = json.getJSONObject("message_tags");
                    Iterator ids = tagsJSONObject.keys();
                    while (ids.hasNext()) {
                        String id = (String) ids.next();
                        JSONArray tagsJSONArray = tagsJSONObject.getJSONArray(id);
                        messageTags = new ArrayList<Tag>();
                        for (int i = 0; i < tagsJSONArray.length(); i++) {
                            JSONObject tagJSONObject = tagsJSONArray.getJSONObject(i);
                            messageTags.add(new TagJSONImpl(tagJSONObject));
                        }
                    }
                }
            } else {
                messageTags = Collections.emptyList();
            }
            picture = getURL("picture", json);
            fullPicture = getURL("full_picture", json);
            link = getURL("link", json);
            name = getRawString("name", json);
            caption = getRawString("caption", json);
            description = getRawString("description", json);
            source = getURL("source", json);
            if (!json.isNull("properties")) {
                JSONArray propertyJSONArray = json.getJSONArray("properties");
                properties = new ArrayList<Post.Property>();
                for (int i = 0; i < propertyJSONArray.length(); i++) {
                    JSONObject propertyJSONObject = propertyJSONArray.getJSONObject(i);
                    properties.add(new PropertyJSONImpl(propertyJSONObject));
                }
            } else {
                properties = Collections.emptyList();
            }
            icon = getURL("icon", json);
            if (!json.isNull("actions")) {
                JSONArray actionJSONArray = json.getJSONArray("actions");
                actions = new ArrayList<Post.Action>();
                for (int i = 0; i < actionJSONArray.length(); i++) {
                    JSONObject actionJSONObject = actionJSONArray.getJSONObject(i);
                    actions.add(new ActionJSONImpl(actionJSONObject));
                }
            } else {
                actions = Collections.emptyList();
            }
            if (!json.isNull("privacy")) {
                JSONObject privacyJSONObject = json.getJSONObject("privacy");
                privacy = new PrivacyJSONImpl(privacyJSONObject);
            }
            type = getRawString("type", json);
            if (!json.isNull("shares")){
                JSONObject sharesJSONObject = json.getJSONObject("shares");
                if (!sharesJSONObject.isNull("count")){
                    sharesCount = getInt("count", sharesJSONObject);
                }
            }
            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("place")) {
                JSONObject placeJSONObject = json.getJSONObject("place");
                place = new PlaceJSONImpl(placeJSONObject);
            }
            statusType = getRawString("status_type", json);
            story = getRawString("story", json);
            if (!json.isNull("story_tags")) {
                JSONObject storyTagsJSONObject = json.getJSONObject("story_tags");
                storyTags = new HashMap<String, Tag[]>();
                @SuppressWarnings("unchecked")
                Iterator<String> keys = storyTagsJSONObject.keys();
                while (keys.hasNext()) {
                    String key = (String) keys.next();
                    JSONArray storyTagsJSONArray = storyTagsJSONObject.getJSONArray(key);
                    Tag[] tags = new Tag[storyTagsJSONArray.length()];
                    for (int i = 0; i < storyTagsJSONArray.length(); i++) {
                        JSONObject tag = storyTagsJSONArray.getJSONObject(i);
                        tags[i] = new TagJSONImpl(tag);
                    }
                    storyTags.put(key, tags);
                }
            } else {
                storyTags = Collections.emptyMap();
            }
            if (!json.isNull("with_tags")) {
                JSONArray withTagsJSONArray = json.getJSONObject("with_tags").getJSONArray("data");
                withTags = new ArrayList<IdNameEntity>();
                for (int i = 0; i < withTagsJSONArray.length(); i++) {
                    JSONObject withTagJSONObject = withTagsJSONArray.getJSONObject(i);
                    withTags.add(new IdNameEntityJSONImpl(withTagJSONObject));
                }
            } else {
                withTags = Collections.emptyList();
            }
            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 comment = new CommentJSONImpl(list.getJSONObject(i));
                        comments.add(comment);
                    }
                } else {
                    comments = new PagableListImpl<Comment>(1, commentsJSONObject);
                }
View Full Code Here

        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Post> posts = new ResponseListImpl<Post>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject postJSONObject = list.getJSONObject(i);
                Post post = new PostJSONImpl(postJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(post, postJSONObject);
                }
                posts.add(post);
View Full Code Here

        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Friendlist> friendlists = new ResponseListImpl<Friendlist>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject friendlistJSONObject = list.getJSONObject(i);
                Friendlist friendlist = new FriendlistJSONImpl(friendlistJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(friendlist, friendlistJSONObject);
                }
                friendlists.add(friendlist);
View Full Code Here

                JSONObject fromJSONObject = json.getJSONObject("from");
                from = new IdNameEntityJSONImpl(fromJSONObject);
            }
            if (!json.isNull("tags")) {
                JSONObject tagsJSONObject = json.getJSONObject("tags");
                JSONArray list = tagsJSONObject.getJSONArray("data");
                final int size = list.length();
                tags = new PagableListImpl<IdNameEntity>(size, tagsJSONObject);
                for (int i = 0; i < size; i++) {
                    IdNameEntityJSONImpl tag = new IdNameEntityJSONImpl(list.getJSONObject(i));
                    tags.add(tag);
                }
            } else {
                tags = new PagableListImpl<IdNameEntity>(0);
            }
            if (!json.isNull("place")) {
                JSONObject placeJSONObject = json.getJSONObject("place");
                place = new PlaceJSONImpl(placeJSONObject);
            }
            if (!json.isNull("application")) {
                JSONObject applicationJSONObject = json.getJSONObject("application");
                application = new ApplicationJSONImpl(applicationJSONObject);
            }
            createdTime = getISO8601Datetime("created_time", 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);
            }
            message = getRawString("message", json);
            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 comment = new CommentJSONImpl(list.getJSONObject(i));
                        comments.add(comment);
                    }
                } else {
                    comments = new PagableListImpl<Comment>(1, commentsJSONObject);
                }
View Full Code Here

        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Checkin> checkins = new ResponseListImpl<Checkin>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject checkinJSONObject = list.getJSONObject(i);
                Checkin checkin = new CheckinJSONImpl(checkinJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(checkin, checkinJSONObject);
                }
                checkins.add(checkin);
View Full Code Here

                messageTags = new HashMap<String, Tag[]>();
                @SuppressWarnings("unchecked")
                Iterator<String> keys = messageTagsJSONObject.keys();
                while (keys.hasNext()) {
                    String key = (String) keys.next();
                    JSONArray messageTagsJSONArray = messageTagsJSONObject.getJSONArray(key);
                    Tag[] tags = new Tag[messageTagsJSONArray.length()];
                    for (int i = 0; i < messageTagsJSONArray.length(); i++) {
                        JSONObject tag = messageTagsJSONArray.getJSONObject(i);
                        tags[i] = new TagJSONImpl(tag);
                    }
                    messageTags.put(key, tags);
                }
            } else {
                messageTags = Collections.emptyMap();
            }
            if (!json.isNull("object_id")) {
                objectId = getRawString("object_id", json);
            }
            privacy = new PrivacyJSONImpl(json.getJSONObject("privacy"));
            if (!json.isNull("to")) {
                JSONArray toJSONArray = json.getJSONObject("to").getJSONArray("data");
                to = new ArrayList<Category>();
                for (int i = 0; i < toJSONArray.length(); i++) {
                    JSONObject toJSONObject = toJSONArray.getJSONObject(i);
                    to.add(new CategoryJSONImpl(toJSONObject));
                }
            } else {
                to = Collections.emptyList();
            }
View Full Code Here

        try {
            if (conf.isJSONStoreEnabled()) {
                DataObjectFactoryUtil.clearThreadLocalMap();
            }
            JSONObject json = res.asJSONObject();
            JSONArray list = json.getJSONArray("data");
            final int size = list.length();
            ResponseList<Tagged> taggeds = new ResponseListImpl<Tagged>(size, json);
            for (int i = 0; i < size; i++) {
                JSONObject taggedJSONObject = list.getJSONObject(i);
                Tagged tagged = new TaggedJSONImpl(taggedJSONObject);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(tagged, taggedJSONObject);
                }
                taggeds.add(tagged);
View Full Code Here

TOP

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

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.