use of org.jivesoftware.smackx.pubsub.Item in project Smack by igniterealtime.
the class ItemProvider method parse.
@Override
public Item parse(XmlPullParser parser, int initialDepth) throws Exception {
String id = parser.getAttributeValue(null, "id");
String node = parser.getAttributeValue(null, "node");
int tag = parser.next();
if (tag == XmlPullParser.END_TAG) {
return new Item(id, node);
} else {
String payloadElemName = parser.getName();
String payloadNS = parser.getNamespace();
final ExtensionElementProvider<ExtensionElement> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS);
if (extensionProvider == null) {
CharSequence payloadText = PacketParserUtils.parseElement(parser, true);
return new PayloadItem<SimplePayload>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText));
} else {
return new PayloadItem<ExtensionElement>(id, node, extensionProvider.parse(parser));
}
}
}
Aggregations