/** {@inheritDoc} */ public long[] getContributors() { if (contributors != null) { // http://twitter4j.org/jira/browse/TFJ-592 // preserving serialized form compatibility with older versions contributorsIDs = new long[contributors.length]; for (int i = 0; i < contributors.length; i++) { try { contributorsIDs[i] = Long.parseLong(contributors[i]); } catch (NumberFormatException nfe) { nfe.printStackTrace(); logger.warn("failed to parse contributors:" + nfe); } } contributors = null; } return contributorsIDs; }
private void init(JSONObject json) throws TwitterException { id = getLong("id", json); text = getUnescapedString("text", json); source = getUnescapedString("source", json); createdAt = getDate("created_at", json); isTruncated = getBoolean("truncated", json); inReplyToStatusId = getLong("in_reply_to_status_id", json); inReplyToUserId = getLong("in_reply_to_user_id", json); isFavorited = getBoolean("favorited", json); inReplyToScreenName = getUnescapedString("in_reply_to_screen_name", json); retweetCount = getLong("retweet_count", json); try { if (!json.isNull("user")) { user = new UserJSONImpl(json.getJSONObject("user")); } } catch (JSONException jsone) { throw new TwitterException(jsone); } geoLocation = z_T4JInternalJSONImplFactory.createGeoLocation(json); if (!json.isNull("place")) { try { place = new PlaceJSONImpl(json.getJSONObject("place")); } catch (JSONException ignore) { ignore.printStackTrace(); logger.warn("failed to parse place:" + json); } } if (!json.isNull("retweeted_status")) { try { retweetedStatus = new StatusJSONImpl(json.getJSONObject("retweeted_status")); } catch (JSONException ignore) { ignore.printStackTrace(); logger.warn("failed to parse retweeted_status:" + json); } } if (!json.isNull("contributors")) { try { JSONArray contributorsArray = json.getJSONArray("contributors"); contributorsIDs = new long[contributorsArray.length()]; for (int i = 0; i < contributorsArray.length(); i++) { contributorsIDs[i] = Long.parseLong(contributorsArray.getString(i)); } } catch (NumberFormatException ignore) { ignore.printStackTrace(); logger.warn("failed to parse contributors:" + json); } catch (JSONException ignore) { ignore.printStackTrace(); logger.warn("failed to parse contributors:" + json); } } else { contributors = null; } if (!json.isNull("entities")) { try { JSONObject entities = json.getJSONObject("entities"); int len; if (!entities.isNull("user_mentions")) { JSONArray userMentionsArray = entities.getJSONArray("user_mentions"); len = userMentionsArray.length(); userMentionEntities = new UserMentionEntity[len]; for (int i = 0; i < len; i++) { userMentionEntities[i] = new UserMentionEntityJSONImpl(userMentionsArray.getJSONObject(i)); } } if (!entities.isNull("urls")) { JSONArray urlsArray = entities.getJSONArray("urls"); len = urlsArray.length(); urlEntities = new URLEntity[len]; for (int i = 0; i < len; i++) { urlEntities[i] = new URLEntityJSONImpl(urlsArray.getJSONObject(i)); } } if (!entities.isNull("hashtags")) { JSONArray hashtagsArray = entities.getJSONArray("hashtags"); len = hashtagsArray.length(); hashtagEntities = new HashtagEntity[len]; for (int i = 0; i < len; i++) { hashtagEntities[i] = new HashtagEntityJSONImpl(hashtagsArray.getJSONObject(i)); } } if (!entities.isNull("media")) { JSONArray mediaArray = entities.getJSONArray("media"); len = mediaArray.length(); mediaEntities = new MediaEntity[len]; for (int i = 0; i < len; i++) { mediaEntities[i] = new MediaEntityJSONImpl(mediaArray.getJSONObject(i)); } } } catch (JSONException jsone) { throw new TwitterException(jsone); } } if (!json.isNull("annotations")) { try { JSONArray annotationsArray = json.getJSONArray("annotations"); annotations = new Annotations(annotationsArray); } catch (JSONException ignore) { } } if (!json.isNull("current_user_retweet")) { try { myRetweetedStatus = new StatusJSONImpl(json.getJSONObject("current_user_retweet")); } catch (JSONException ignore) { ignore.printStackTrace(); logger.warn("failed to parse current_user_retweet:" + json); } } }