public static StanzaError . Builder parseError ( XmlPullParser parser , XmlEnvironment outerXmlEnvironment ) throws XmlPullParserException , IOException , SmackParsingException { final int initialDepth = parser . getDepth ( ) ; Map < String , String > descriptiveTexts = null ; XmlEnvironment stanzaErrorXmlEnvironment = XmlEnvironment . from ( parser , outerXmlEnvironment ) ; List < ExtensionElement > extensions = new ArrayList <> ( ) ; StanzaError . Builder builder = StanzaError . getBuilder ( ) ; // Parse the error header builder . setType ( StanzaError . Type . fromString ( parser . getAttributeValue ( "" , "type" ) ) ) ; builder . setErrorGenerator ( parser . getAttributeValue ( "" , "by" ) ) ; outerloop : while ( true ) { int eventType = parser . next ( ) ; switch ( eventType ) { case XmlPullParser . START_TAG : String name = parser . getName ( ) ; String namespace = parser . getNamespace ( ) ; switch ( namespace ) { case StanzaError . ERROR_CONDITION_AND_TEXT_NAMESPACE : switch ( name ) { case Stanza . TEXT : descriptiveTexts = parseDescriptiveTexts ( parser , descriptiveTexts ) ; break ; default : builder . setCondition ( StanzaError . Condition . fromString ( name ) ) ; if ( ! parser . isEmptyElementTag ( ) ) { builder . setConditionText ( parser . nextText ( ) ) ; } break ; } break ; default : PacketParserUtils . addExtensionElement ( extensions , parser , name , namespace , stanzaErrorXmlEnvironment ) ; } break ; case XmlPullParser . END_TAG : if ( parser . getDepth ( ) == initialDepth ) { break outerloop ; } } } builder . setExtensions ( extensions ) . setDescriptiveTexts ( descriptiveTexts ) ; return builder ; }
Parses error sub - packets .