Example #1
0
  public RosterElement(Element roster_el, XMPPResourceConnection session)
      throws TigaseStringprepException {
    this.session = session;
    if (roster_el.getName() == ELEM_NAME) {
      this.stringpreped = roster_el.getAttributeStaticStr(STRINGPREP_ATT);
      setJid(roster_el.getAttributeStaticStr(JID_ATT));
      setName(roster_el.getAttributeStaticStr(NAME_ATT));
      if (roster_el.getAttributeStaticStr(SUBS_ATT) == null) {
        subscription = SubscriptionType.none;
      } else {
        subscription = SubscriptionType.valueOf(roster_el.getAttributeStaticStr(SUBS_ATT));
      }

      String grps = roster_el.getAttributeStaticStr(GRP_ATT);

      if ((grps != null) && !grps.trim().isEmpty()) {
        setGroups(grps.split(","));
      }

      String other_data = roster_el.getAttributeStaticStr(OTHER_ATT);

      if ((other_data != null) && !other_data.trim().isEmpty()) {
        otherData = other_data;
      }

      String num_str = roster_el.getAttributeStaticStr(ACTIVITY_ATT);

      if (num_str != null) {
        try {
          activity = Double.parseDouble(num_str);
        } catch (NumberFormatException nfe) {
          log.warning("Incorrect activity field: " + num_str);
          activity = INITIAL_ACTIVITY_VAL;
        }
      }
      num_str = roster_el.getAttributeStaticStr(WEIGHT_ATT);
      if (num_str != null) {
        try {
          weight = Double.parseDouble(num_str);
        } catch (NumberFormatException nfe) {
          log.warning("Incorrect weight field: " + num_str);
          weight = INITIAL_WEIGHT_VAL;
        }
      }
      num_str = roster_el.getAttributeStaticStr(LAST_SEEN_ATT);
      if (num_str != null) {
        try {
          lastSeen = Long.parseLong(num_str);
        } catch (NumberFormatException nfe) {
          log.warning("Incorrect last seen field: " + num_str);
          lastSeen = INITIAL_LAST_SEEN_VAL;
        }
      }
    } else {
      log.warning("Incorrect roster data: " + roster_el.toString());
    }
  }