Class PacketParserUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddExtensionElement(Collection<XmlElement> collection, org.jivesoftware.smack.xml.XmlPullParser parser, String elementName, String namespace, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) static voidaddExtensionElement(Collection<XmlElement> collection, org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) static voidaddExtensionElement(StanzaBuilder<?> stanzaBuilder, org.jivesoftware.smack.xml.XmlPullParser parser, String elementName, String namespace, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) static voidaddExtensionElement(StanzaBuilder<?> stanzaBuilder, org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) static voidaddExtensionElement(Stanza packet, org.jivesoftware.smack.xml.XmlPullParser parser, String elementName, String namespace, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) static voidaddExtensionElement(Stanza packet, org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) static org.jivesoftware.smack.xml.XmlPullParsergetParserFor(InputStream inputStream) static org.jivesoftware.smack.xml.XmlPullParsergetParserFor(Reader reader) static org.jivesoftware.smack.xml.XmlPullParsergetParserFor(String element) static Compress.FeatureparseCompressionFeature(org.jivesoftware.smack.xml.XmlPullParser parser) Parse the Compression Feature reported from the server.static CharSequenceparseContentDepth(org.jivesoftware.smack.xml.XmlPullParser parser, int depth) static CharSequenceparseContentDepth(org.jivesoftware.smack.xml.XmlPullParser parser, int depth, boolean fullNamespaces) Returns the content from the current position of the parser up to the closing tag of the given depth.parseDescriptiveTexts(org.jivesoftware.smack.xml.XmlPullParser parser, Map<String, String> descriptiveTexts) static CharSequenceparseElement(org.jivesoftware.smack.xml.XmlPullParser parser) Returns the current element as string.static CharSequenceparseElement(org.jivesoftware.smack.xml.XmlPullParser parser, boolean fullNamespaces) static StringparseElementText(org.jivesoftware.smack.xml.XmlPullParser parser) Returns the textual content of an element as String.static StanzaErrorparseError(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) Parses error sub-packets.static XmlElementparseExtensionElement(String elementName, String namespace, org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) Parses an extension element.static IQparseIQ(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) Parses an IQ packet.static IqDataparseIqData(org.jivesoftware.smack.xml.XmlPullParser parser, org.jxmpp.JxmppContext jxmppContext) static Collection<String>parseMechanisms(org.jivesoftware.smack.xml.XmlPullParser parser) Parse the available SASL mechanisms reported from the server.static MessageparseMessage(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) Parses a message packet.static PresenceparsePresence(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) Parses a presence packet.static Session.FeatureparseSessionFeature(org.jivesoftware.smack.xml.XmlPullParser parser) static StanzaparseStanza(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) Tries to parse and return either a Message, IQ or Presence stanza.static StartTlsparseStartTlsFeature(org.jivesoftware.smack.xml.XmlPullParser parser) static StreamErrorparseStreamError(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) Parses stream error packets.
-
Constructor Details
-
PacketParserUtils
public PacketParserUtils()
-
-
Method Details
-
getParserFor
public static org.jivesoftware.smack.xml.XmlPullParser getParserFor(String element) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOException
-
getParserFor
public static org.jivesoftware.smack.xml.XmlPullParser getParserFor(InputStream inputStream) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOException
-
getParserFor
public static org.jivesoftware.smack.xml.XmlPullParser getParserFor(Reader reader) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOException
-
parseStanza
public static Stanza parseStanza(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, SmackParsingException, IOException Tries to parse and return either a Message, IQ or Presence stanza. connection is optional and is used to return feature-not-implemented errors for unknown IQ stanzas.- Parameters:
parser- TODO javadoc me pleaseouterXmlEnvironment- the outer XML environment (optional).jxmppContext- the JXMPP context used when creating JIDs.- Returns:
- a stanza which is either a Message, IQ or Presence.
- Throws:
org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.SmackParsingException- if the Smack parser (provider) encountered invalid input.IOException- if an I/O error occurred.
-
parseMessage
public static Message parseMessage(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException Parses a message packet.- Parameters:
parser- the XML parser, positioned at the start of a message packet.outerXmlEnvironment- the outer XML environment (optional).jxmppContext- the JXMPP context used when creating JIDs.- Returns:
- a Message packet.
- Throws:
org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.IOException- if an I/O error occurred.SmackParsingException- if the Smack parser (provider) encountered invalid input.
-
parseElementText
public static String parseElementText(org.jivesoftware.smack.xml.XmlPullParser parser) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException Returns the textual content of an element as String. After this method returns the parser position will be END_ELEMENT, following the established pull parser calling convention.The parser must be positioned on a START_ELEMENT of an element which MUST NOT contain Mixed Content (as defined in XML 3.2.2), or else an XmlPullParserException will be thrown.
This method is used for the parts where the XMPP specification requires elements that contain only text or are the empty element.- Parameters:
parser- TODO javadoc me please- Returns:
- the textual content of the element as String
- Throws:
org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.IOException- if an I/O error occurred.
-
parseElement
public static CharSequence parseElement(org.jivesoftware.smack.xml.XmlPullParser parser) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException Returns the current element as string.The parser must be positioned on START_ELEMENT.
Note that only the outermost namespace attributes ("xmlns") will be returned, not nested ones.- Parameters:
parser- the XML pull parser- Returns:
- the element as string
- Throws:
org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.IOException- if an I/O error occurred.
-
parseElement
public static CharSequence parseElement(org.jivesoftware.smack.xml.XmlPullParser parser, boolean fullNamespaces) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOException
-
parseContentDepth
public static CharSequence parseContentDepth(org.jivesoftware.smack.xml.XmlPullParser parser, int depth) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOException
-
parseContentDepth
public static CharSequence parseContentDepth(org.jivesoftware.smack.xml.XmlPullParser parser, int depth, boolean fullNamespaces) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException Returns the content from the current position of the parser up to the closing tag of the given depth. Note that only the outermost namespace attributes ("xmlns") will be returned, not nested ones, iffullNamespacesis false. If it is true, then namespaces of parent elements will be added to child elements that don't define a different namespace.This method is able to parse the content with MX- and KXmlParser. KXmlParser does not support xml-roundtrip. i.e. return a String on getText() on START_ELEMENT and END_ELEMENT. We check for the XML_ROUNDTRIP feature. If it's not found we are required to work around this limitation, which results in only partial support for XML namespaces ("xmlns"): Only the outermost namespace of elements will be included in the resulting String, if
fullNamespacesis set to false.In particular Android's XmlPullParser does not support XML_ROUNDTRIP.
- Parameters:
parser- TODO javadoc me pleasedepth- TODO javadoc me pleasefullNamespaces- TODO javadoc me please- Returns:
- the content of the current depth
- Throws:
org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.IOException- if an I/O error occurred.
-
parsePresence
public static Presence parsePresence(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException Parses a presence packet.- Parameters:
parser- the XML parser, positioned at the start of a presence packet.outerXmlEnvironment- the outer XML environment (optional).jxmppContext- the JXMPP context used when creating JIDs.- Returns:
- a Presence packet.
- Throws:
IOException- if an I/O error occurred.org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.SmackParsingException- if the Smack parser (provider) encountered invalid input.
-
parseIqData
public static IqData parseIqData(org.jivesoftware.smack.xml.XmlPullParser parser, org.jxmpp.JxmppContext jxmppContext) throws org.jxmpp.stringprep.XmppStringprepException - Throws:
org.jxmpp.stringprep.XmppStringprepException
-
parseIQ
public static IQ parseIQ(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, org.jxmpp.stringprep.XmppStringprepException, IOException, SmackParsingException Parses an IQ packet.- Parameters:
parser- the XML parser, positioned at the start of an IQ packet.outerXmlEnvironment- the outer XML environment (optional).jxmppContext- the JXMPP context used when creating JIDs.- Returns:
- an IQ object.
- Throws:
org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.org.jxmpp.stringprep.XmppStringprepException- if the provided string is invalid.IOException- if an I/O error occurred.SmackParsingException- if the Smack parser (provider) encountered invalid input.
-
parseMechanisms
public static Collection<String> parseMechanisms(org.jivesoftware.smack.xml.XmlPullParser parser) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException Parse the available SASL mechanisms reported from the server.- Parameters:
parser- the XML parser, positioned at the start of the mechanisms stanza.- Returns:
- a collection of Stings with the mechanisms included in the mechanisms stanza.
- Throws:
IOException- if an I/O error occurred.org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.
-
parseCompressionFeature
public static Compress.Feature parseCompressionFeature(org.jivesoftware.smack.xml.XmlPullParser parser) throws IOException, org.jivesoftware.smack.xml.XmlPullParserException Parse the Compression Feature reported from the server.- Parameters:
parser- the XML parser, positioned at the start of the compression stanza.- Returns:
- The CompressionFeature stream element
- Throws:
IOException- if an I/O error occurred.org.jivesoftware.smack.xml.XmlPullParserException- if an exception occurs while parsing the stanza.
-
parseDescriptiveTexts
public static Map<String,String> parseDescriptiveTexts(org.jivesoftware.smack.xml.XmlPullParser parser, Map<String, String> descriptiveTexts) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException- Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOException
-
parseStreamError
public static StreamError parseStreamError(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException Parses stream error packets.- Parameters:
parser- the XML parser.outerXmlEnvironment- the outer XML environment (optional).jxmppContext- the JXMPP context used when creating JIDs.- Returns:
- an stream error packet.
- Throws:
IOException- if an I/O error occurred.org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.SmackParsingException- if the Smack parser (provider) encountered invalid input.
-
parseError
public static StanzaError parseError(org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException Parses error sub-packets.- Parameters:
parser- the XML parser.outerXmlEnvironment- the outer XML environment (optional).jxmppContext- the JXMPP context used when creating JIDs.- Returns:
- an error sub-packet.
- Throws:
IOException- if an I/O error occurred.org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.SmackParsingException- if the Smack parser (provider) encountered invalid input.
-
parseExtensionElement
public static XmlElement parseExtensionElement(String elementName, String namespace, org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException Parses an extension element.- Parameters:
elementName- the XML element name of the extension element.namespace- the XML namespace of the stanza extension.parser- the XML parser, positioned at the starting element of the extension.outerXmlEnvironment- the outer XML environment (optional).jxmppContext- the JXMPP context used when creating JIDs.- Returns:
- an extension element.
- Throws:
org.jivesoftware.smack.xml.XmlPullParserException- if an error in the XML parser occurred.IOException- if an I/O error occurred.SmackParsingException- if the Smack parser (provider) encountered invalid input.
-
parseStartTlsFeature
public static StartTls parseStartTlsFeature(org.jivesoftware.smack.xml.XmlPullParser parser) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOException
-
parseSessionFeature
public static Session.Feature parseSessionFeature(org.jivesoftware.smack.xml.XmlPullParser parser) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOException
-
addExtensionElement
public static void addExtensionElement(StanzaBuilder<?> stanzaBuilder, org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOExceptionSmackParsingException
-
addExtensionElement
public static void addExtensionElement(StanzaBuilder<?> stanzaBuilder, org.jivesoftware.smack.xml.XmlPullParser parser, String elementName, String namespace, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOExceptionSmackParsingException
-
addExtensionElement
public static void addExtensionElement(Stanza packet, org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOExceptionSmackParsingException
-
addExtensionElement
public static void addExtensionElement(Stanza packet, org.jivesoftware.smack.xml.XmlPullParser parser, String elementName, String namespace, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOExceptionSmackParsingException
-
addExtensionElement
public static void addExtensionElement(Collection<XmlElement> collection, org.jivesoftware.smack.xml.XmlPullParser parser, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOExceptionSmackParsingException
-
addExtensionElement
public static void addExtensionElement(Collection<XmlElement> collection, org.jivesoftware.smack.xml.XmlPullParser parser, String elementName, String namespace, XmlEnvironment outerXmlEnvironment, org.jxmpp.JxmppContext jxmppContext) throws org.jivesoftware.smack.xml.XmlPullParserException, IOException, SmackParsingException - Throws:
org.jivesoftware.smack.xml.XmlPullParserExceptionIOExceptionSmackParsingException
-