Search in sources :

Example 1 with SimplePayload

use of org.jivesoftware.smackx.pubsub.SimplePayload 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));
        }
    }
}
Also used : PayloadItem(org.jivesoftware.smackx.pubsub.PayloadItem) Item(org.jivesoftware.smackx.pubsub.Item) PayloadItem(org.jivesoftware.smackx.pubsub.PayloadItem) ExtensionElement(org.jivesoftware.smack.packet.ExtensionElement) SimplePayload(org.jivesoftware.smackx.pubsub.SimplePayload)

Aggregations

ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)1 Item (org.jivesoftware.smackx.pubsub.Item)1 PayloadItem (org.jivesoftware.smackx.pubsub.PayloadItem)1 SimplePayload (org.jivesoftware.smackx.pubsub.SimplePayload)1