Exemplo n.º 1
0
 /*package*/
 static ResponseList<Relationship> createRelationshipList(HttpResponse res, Configuration conf)
     throws TwitterException {
   try {
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.clearThreadLocalMap();
     }
     JSONArray list = res.asJSONArray();
     int size = list.length();
     ResponseList<Relationship> relationships = new ResponseListImpl<Relationship>(size, res);
     for (int i = 0; i < size; i++) {
       JSONObject json = list.getJSONObject(i);
       Relationship relationship = new RelationshipJSONImpl(json);
       if (conf.isJSONStoreEnabled()) {
         DataObjectFactoryUtil.registerJSONObject(relationship, json);
       }
       relationships.add(relationship);
     }
     if (conf.isJSONStoreEnabled()) {
       DataObjectFactoryUtil.registerJSONObject(relationships, list);
     }
     return relationships;
   } catch (JSONException jsone) {
     throw new TwitterException(jsone);
   } catch (TwitterException te) {
     throw te;
   }
 }
Exemplo n.º 2
0
 /*package*/
 static ResponseList<UserList> createUserListList(HttpResponse res, Configuration conf)
     throws TwitterException {
   try {
     if (conf.isJSONStoreEnabled()) {
       TwitterObjectFactory.clearThreadLocalMap();
     }
     JSONArray list = res.asJSONArray();
     int size = list.length();
     ResponseList<UserList> users = new ResponseListImpl<UserList>(size, res);
     for (int i = 0; i < size; i++) {
       JSONObject userListJson = list.getJSONObject(i);
       UserList userList = new UserListJSONImpl(userListJson);
       users.add(userList);
       if (conf.isJSONStoreEnabled()) {
         TwitterObjectFactory.registerJSONObject(userList, userListJson);
       }
     }
     if (conf.isJSONStoreEnabled()) {
       TwitterObjectFactory.registerJSONObject(users, list);
     }
     return users;
   } catch (JSONException jsone) {
     throw new TwitterException(jsone);
   }
 }
Exemplo n.º 3
0
 public static ResponseList<ContributorFact> createContributorFactList(HttpResponse res) {
   if (null == res) {
     return null;
   }
   XMLParser parser = new XMLParser(res.asString());
   NodeList nodelist = parser.getNodeList("response/result/contributor_fact");
   ResponseList<ContributorFact> list =
       new ResponseListImpl<ContributorFact>(nodelist.getLength(), res);
   for (int i = 0; i < nodelist.getLength(); i++) {
     Node node = nodelist.item(i);
     try {
       XMLParser childParser = new XMLParser(XMLParser.getXmlStringFromNode(node));
       ContributorFact contributorFact = new ContributorFactImpl(childParser, true);
       list.add(contributorFact);
     } catch (TransformerFactoryConfigurationError e) {
       e.printStackTrace();
     } catch (TransformerException e) {
       e.printStackTrace();
     }
   }
   return list;
 }