Ejemplo n.º 1
0
 private static CharSequence parseContentDepthWithoutRoundtrip(
     XmlPullParser xmlPullParser, int i, boolean z) throws XmlPullParserException, IOException {
   XmlStringBuilder xmlStringBuilder = new XmlStringBuilder();
   Object obj = null;
   int eventType = xmlPullParser.getEventType();
   String str = null;
   while (true) {
     Object obj2;
     switch (eventType) {
       case VideoSize.HVGA /*2*/:
         xmlStringBuilder.halfOpenElement(xmlPullParser.getName());
         if (str == null || z) {
           String namespace = xmlPullParser.getNamespace();
           if (StringUtils.isNotEmpty(namespace)) {
             xmlStringBuilder.attribute("xmlns", namespace);
             str = xmlPullParser.getName();
           }
         }
         for (eventType = 0; eventType < xmlPullParser.getAttributeCount(); eventType++) {
           xmlStringBuilder.attribute(
               xmlPullParser.getAttributeName(eventType),
               xmlPullParser.getAttributeValue(eventType));
         }
         if (!xmlPullParser.isEmptyElementTag()) {
           xmlStringBuilder.rightAngleBracket();
           obj2 = obj;
           break;
         }
         xmlStringBuilder.closeEmptyElement();
         obj2 = 1;
         continue;
       case Version.API03_CUPCAKE_15 /*3*/:
         if (obj != null) {
           obj2 = null;
         } else {
           xmlStringBuilder.closeElement(xmlPullParser.getName());
           obj2 = obj;
         }
         if (str != null && str.equals(xmlPullParser.getName())) {
           str = null;
         }
         if (xmlPullParser.getDepth() <= i) {
           return xmlStringBuilder;
         }
         continue;
       case Version.API04_DONUT_16 /*4*/:
         xmlStringBuilder.append(xmlPullParser.getText());
         break;
     }
     obj2 = obj;
     Object obj3 = obj2;
     eventType = xmlPullParser.next();
     obj = obj3;
   }
 }
Ejemplo n.º 2
0
 public XmlStringBuilder halfOpenElement(String name) {
   assert (StringUtils.isNotEmpty(name));
   sb.append('<').append(name);
   return this;
 }
Ejemplo n.º 3
0
 public static Presence parsePresence(XmlPullParser xmlPullParser)
     throws XmlPullParserException, IOException, SmackException {
   ParserUtils.assertAtStartTag(xmlPullParser);
   int depth = xmlPullParser.getDepth();
   Presence.Type type = Presence.Type.available;
   String attributeValue = xmlPullParser.getAttributeValue("", "type");
   if (!(attributeValue == null || attributeValue.equals(""))) {
     type = Presence.Type.fromString(attributeValue);
   }
   Stanza presence = new Presence(type);
   presence.setTo(xmlPullParser.getAttributeValue("", PrivacyItem.SUBSCRIPTION_TO));
   presence.setFrom(xmlPullParser.getAttributeValue("", PrivacyItem.SUBSCRIPTION_FROM));
   presence.setStanzaId(xmlPullParser.getAttributeValue("", "id"));
   String languageAttribute = getLanguageAttribute(xmlPullParser);
   if (!(languageAttribute == null || "".equals(languageAttribute.trim()))) {
     presence.setLanguage(languageAttribute);
   }
   while (true) {
     switch (xmlPullParser.next()) {
       case VideoSize.HVGA /*2*/:
         String name = xmlPullParser.getName();
         String namespace = xmlPullParser.getNamespace();
         Object obj = -1;
         switch (name.hashCode()) {
           case -1165461084:
             if (name.equals("priority")) {
               obj = 1;
               break;
             }
             break;
           case -892481550:
             if (name.equals(Status.ELEMENT)) {
               obj = null;
               break;
             }
             break;
           case 3529469:
             if (name.equals("show")) {
               obj = 2;
               break;
             }
             break;
           case 96784904:
             if (name.equals(XMPPError.ERROR)) {
               obj = 3;
               break;
             }
             break;
         }
         switch (obj) {
           case VideoSize.QCIF /*0*/:
             presence.setStatus(xmlPullParser.nextText());
             break;
           case VideoSize.CIF /*1*/:
             presence.setPriority(Integer.parseInt(xmlPullParser.nextText()));
             break;
           case VideoSize.HVGA /*2*/:
             obj = xmlPullParser.nextText();
             if (!StringUtils.isNotEmpty(obj)) {
               LOGGER.warning(
                   "Empty or null mode text in presence show element form "
                       + presence.getFrom()
                       + " with id '"
                       + presence.getStanzaId()
                       + "' which is invalid according to RFC6121 4.7.2.1");
               break;
             }
             presence.setMode(Mode.fromString(obj));
             break;
           case Version.API03_CUPCAKE_15 /*3*/:
             presence.setError(parseError(xmlPullParser));
             break;
           default:
             try {
               addExtensionElement(presence, xmlPullParser, name, namespace);
               break;
             } catch (Throwable e) {
               LOGGER.log(
                   Level.WARNING,
                   "Failed to parse extension packet in Presence packet. Attributes: from="
                       + presence.getFrom()
                       + " id="
                       + presence.getStanzaId(),
                   e);
               break;
             }
         }
       case Version.API03_CUPCAKE_15 /*3*/:
         if (xmlPullParser.getDepth() != depth) {
           break;
         }
         return presence;
       default:
         break;
     }
   }
 }