Esempio n. 1
0
 /*package*/
 static List<DirectMessage> constructDirectMessages(Response res, Weibo weibo)
     throws WeiboException {
   Document doc = res.asDocument();
   if (isRootNodeNilClasses(doc)) {
     return new ArrayList<DirectMessage>(0);
   } else {
     try {
       ensureRootNodeNameIs("direct-messages", doc);
       NodeList list = doc.getDocumentElement().getElementsByTagName("direct_message");
       int size = list.getLength();
       List<DirectMessage> messages = new ArrayList<DirectMessage>(size);
       for (int i = 0; i < size; i++) {
         Element status = (Element) list.item(i);
         messages.add(new DirectMessage(res, status, weibo));
       }
       return messages;
     } catch (WeiboException te) {
       if (isRootNodeNilClasses(doc)) {
         return new ArrayList<DirectMessage>(0);
       } else {
         throw te;
       }
     }
   }
 }
Esempio n. 2
0
  /*package*/
  static List<DirectMessage> constructDirectMessages(Response res) throws WeiboException {
    JSONArray list = res.asJSONArray();

    try {
      int size = list.length();
      List<DirectMessage> messages = new ArrayList<DirectMessage>(size);
      for (int i = 0; i < size; i++) {

        messages.add(new DirectMessage(list.getJSONObject(i)));
      }
      return messages;
    } catch (JSONException jsone) {
      throw new WeiboException(jsone);
    }
  }
Esempio n. 3
0
 /*package*/ DirectMessage(Response res, Weibo weibo) throws WeiboException {
   super(res);
   init(res, res.asDocument().getDocumentElement(), weibo);
 }