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;
}
Aggregations