示例#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);
   }
 }
示例#2
0
 /*package*/ UserJSONImpl(HttpResponse res, Configuration conf) throws FacebookException {
   if (conf.isJSONStoreEnabled()) {
     DataObjectFactoryUtil.clearThreadLocalMap();
   }
   JSONObject json = res.asJSONObject();
   init(json);
   if (conf.isJSONStoreEnabled()) {
     DataObjectFactoryUtil.registerJSONObject(this, json);
   }
 }
示例#3
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);
   }
 }