Search in sources :

Example 1 with Provider

use of org.jivesoftware.smack.provider.Provider in project Smack by igniterealtime.

the class SmackTestUtil method parse.

@SuppressWarnings("unchecked")
public static <E extends Element> E parse(Reader reader, AbstractProvider<E> abstractProvider, XmlPullParserKind parserKind) throws XmlPullParserException, IOException, SmackParsingException {
    XmlPullParser parser = getParserFor(reader, parserKind);
    final E element;
    if (abstractProvider instanceof Provider) {
        Provider<E> provider = (Provider<E>) abstractProvider;
        element = provider.parse(parser);
    } else if (abstractProvider instanceof IqProvider) {
        IqData iqData = PacketParserUtils.parseIqData(parser);
        parser.next();
        ParserUtils.forwardToStartElement(parser);
        IqProvider<?> iqProvider = (IqProvider<?>) abstractProvider;
        element = (E) iqProvider.parse(parser, iqData);
    } else {
        throw new AssertionError();
    }
    return element;
}
Also used : XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) IqData(org.jivesoftware.smack.packet.IqData) IqProvider(org.jivesoftware.smack.provider.IqProvider) Provider(org.jivesoftware.smack.provider.Provider) AbstractProvider(org.jivesoftware.smack.provider.AbstractProvider) IqProvider(org.jivesoftware.smack.provider.IqProvider)

Aggregations

IqData (org.jivesoftware.smack.packet.IqData)1 AbstractProvider (org.jivesoftware.smack.provider.AbstractProvider)1 IqProvider (org.jivesoftware.smack.provider.IqProvider)1 Provider (org.jivesoftware.smack.provider.Provider)1 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)1