Пример #1
0
 /**
  * Indicates whether some other object is "equal to" this by comparing all members.
  *
  * <p>The {@link #equals(Object)} method returns <code>true</code> if the user JIDs are equal.
  *
  * @param obj the reference object with which to compare.
  * @return <code>true</code> if this object is the same as the obj argument; <code>false</code>
  *     otherwise.
  */
 public boolean equalsDeep(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   RosterEntry other = (RosterEntry) obj;
   if (name == null) {
     if (other.name != null) return false;
   } else if (!name.equals(other.name)) return false;
   if (status == null) {
     if (other.status != null) return false;
   } else if (!status.equals(other.status)) return false;
   if (type == null) {
     if (other.type != null) return false;
   } else if (!type.equals(other.type)) return false;
   if (user == null) {
     if (other.user != null) return false;
   } else if (!user.equals(other.user)) return false;
   return true;
 }
Пример #2
0
 private static RosterPacket parseRoster(XmlPullParser parser) throws Exception {
   RosterPacket roster = new RosterPacket();
   boolean done = false;
   RosterPacket.Item item = null;
   while (!done) {
     if (parser.getEventType() == XmlPullParser.START_TAG && parser.getName().equals("query")) {
       String version = parser.getAttributeValue(null, "ver");
       roster.setVersion(version);
     }
     int eventType = parser.next();
     if (eventType == XmlPullParser.START_TAG) {
       if (parser.getName().equals("item")) {
         String jid = parser.getAttributeValue("", "jid");
         String name = parser.getAttributeValue("", "name");
         // Create packet.
         item = new RosterPacket.Item(jid, name);
         // Set status.
         String ask = parser.getAttributeValue("", "ask");
         RosterPacket.ItemStatus status = RosterPacket.ItemStatus.fromString(ask);
         item.setItemStatus(status);
         // Set type.
         String subscription = parser.getAttributeValue("", "subscription");
         RosterPacket.ItemType type =
             RosterPacket.ItemType.valueOf(subscription != null ? subscription : "none");
         item.setItemType(type);
       }
       if (parser.getName().equals("group") && item != null) {
         final String groupName = parser.nextText();
         if (groupName != null && groupName.trim().length() > 0) {
           item.addGroupName(groupName);
         }
       }
     } else if (eventType == XmlPullParser.END_TAG) {
       if (parser.getName().equals("item")) {
         roster.addRosterItem(item);
       }
       if (parser.getName().equals("query")) {
         done = true;
       }
     }
   }
   return roster;
 }