Example #1
0
 /*package*/
 static ResponseList<User> createUserList(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<User> users = new ResponseListImpl<User>(size, json);
     for (int i = 0; i < size; i++) {
       JSONObject userJSONObject = list.getJSONObject(i);
       User user = new UserJSONImpl(userJSONObject);
       if (conf.isJSONStoreEnabled()) {
         DataObjectFactoryUtil.registerJSONObject(user, userJSONObject);
       }
       users.add(user);
     }
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.registerJSONObject(users, list);
     }
     return users;
   } catch (JSONException jsone) {
     throw new FacebookException(jsone);
   }
 }
 /*package*/
 static ResponseList<Status> createStatusList(HttpResponse res, Configuration conf)
     throws TwitterException {
   try {
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.clearThreadLocalMap();
     }
     JSONArray list = res.asJSONArray();
     int size = list.length();
     ResponseList<Status> statuses = new ResponseListImpl<Status>(size, res);
     for (int i = 0; i < size; i++) {
       JSONObject json = list.getJSONObject(i);
       Status status = new StatusJSONImpl(json);
       if (conf.isJSONStoreEnabled()) {
         DataObjectFactoryUtil.registerJSONObject(status, json);
       }
       statuses.add(status);
     }
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.registerJSONObject(statuses, list);
     }
     return statuses;
   } catch (JSONException jsone) {
     throw new TwitterException(jsone);
   } catch (TwitterException te) {
     throw te;
   }
 }
 /*package*/ AccountSettingsJSONImpl(HttpResponse res, Configuration conf)
     throws TwitterException {
   this(res, res.asJSONObject());
   if (conf.isJSONStoreEnabled()) {
     DataObjectFactoryUtil.clearThreadLocalMap();
     DataObjectFactoryUtil.registerJSONObject(this, res.asJSONObject());
   }
 }
 /*package*/ MessageJSONImpl(HttpResponse res, Configuration conf) throws FacebookException {
   super(res);
   JSONObject json = res.asJSONObject();
   init(json);
   if (conf.isJSONStoreEnabled()) {
     DataObjectFactoryUtil.clearThreadLocalMap();
     DataObjectFactoryUtil.registerJSONObject(this, json);
   }
 }
 /*package*/
 static ResponseList<Location> createLocationList(HttpResponse res, Configuration conf)
     throws TwitterException {
   if (conf.isJSONStoreEnabled()) {
     DataObjectFactoryUtil.clearThreadLocalMap();
   }
   return createLocationList(res.asJSONArray(), conf.isJSONStoreEnabled());
 }
Example #6
0
 /*package*/
 static List<User> createUserArray(HttpResponse res, Configuration conf) throws FacebookException {
   try {
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.clearThreadLocalMap();
     }
     JSONObject json = res.asJSONObject();
     List<User> users = new ArrayList<User>();
     Iterator ids = json.keys();
     while (ids.hasNext()) {
       String id = (String) ids.next();
       User user = new UserJSONImpl((JSONObject) json.get(id));
       users.add(user);
     }
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.registerJSONObject(users, json);
     }
     return users;
   } catch (JSONException jsone) {
     throw new FacebookException(jsone);
   }
 }
 /*package*/
 static ResponseList<Message> createMessageList(HttpResponse res, Configuration conf)
     throws FacebookException {
   try {
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.clearThreadLocalMap();
     }
     JSONObject json = res.asJSONObject();
     JSONArray list = json.getJSONArray("data");
     int size = list.length();
     ResponseList<Message> messages = new ResponseListImpl<Message>(size, json);
     for (int i = 0; i < size; i++) {
       Message message = new MessageJSONImpl(list.getJSONObject(i));
       messages.add(message);
     }
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.registerJSONObject(messages, json);
     }
     return messages;
   } catch (JSONException jsone) {
     throw new FacebookException(jsone);
   }
 }
 /*package*/
 static ResponseList<Checkin> createCheckinList(HttpResponse res, Configuration conf)
     throws FacebookException {
   try {
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.clearThreadLocalMap();
     }
     JSONObject json = res.asJSONObject();
     JSONArray list = json.getJSONArray("data");
     int size = list.length();
     ResponseList<Checkin> checkins = new ResponseListImpl<Checkin>(size, json);
     for (int i = 0; i < size; i++) {
       Checkin checkin = new CheckinJSONImpl(list.getJSONObject(i));
       checkins.add(checkin);
     }
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.registerJSONObject(checkins, json);
     }
     return checkins;
   } catch (JSONException jsone) {
     throw new FacebookException(jsone);
   }
 }
 /*package*/
 static ResponseList<Location> createLocationList(JSONArray list, boolean storeJSON)
     throws TwitterException {
   try {
     int size = list.length();
     ResponseList<Location> locations = new ResponseListImpl<Location>(size, null);
     for (int i = 0; i < size; i++) {
       JSONObject json = list.getJSONObject(i);
       Location location = new LocationJSONImpl(json);
       locations.add(location);
       if (storeJSON) {
         DataObjectFactoryUtil.registerJSONObject(location, json);
       }
     }
     if (storeJSON) {
       DataObjectFactoryUtil.registerJSONObject(locations, list);
     }
     return locations;
   } catch (JSONException jsone) {
     throw new TwitterException(jsone);
   } catch (TwitterException te) {
     throw te;
   }
 }