use of org.jivesoftware.smackx.pubsub.Item.ItemNamespace in project Smack by igniterealtime.
the class ItemProvider method parse.
@Override
public Item parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
String id = parser.getAttributeValue(null, "id");
String node = parser.getAttributeValue(null, "node");
String xmlns = parser.getNamespace();
ItemNamespace itemNamespace = ItemNamespace.fromXmlns(xmlns);
XmlPullParser.TagEvent event = parser.nextTag();
switch(event) {
case START_ELEMENT:
String payloadElemName = parser.getName();
String payloadNS = parser.getNamespace();
final ExtensionElementProvider<ExtensionElement> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS);
if (extensionProvider == null) {
// TODO: Should we use StandardExtensionElement in this case? And probably remove SimplePayload all together.
CharSequence payloadText = PacketParserUtils.parseElement(parser, true);
return new PayloadItem<>(itemNamespace, id, node, new SimplePayload(payloadText.toString()));
} else {
return new PayloadItem<>(itemNamespace, id, node, extensionProvider.parse(parser));
}
case END_ELEMENT:
return new Item(itemNamespace, id, node);
default:
throw new AssertionError("unknown: " + event);
}
}
Aggregations