Search in sources :

Example 1 with PubSubNamespace

use of org.jivesoftware.smackx.pubsub.packet.PubSubNamespace in project Smack by igniterealtime.

the class AffiliationProvider method parse.

@Override
public Affiliation parse(XmlPullParser parser, int initialDepth) throws Exception {
    String node = parser.getAttributeValue(null, "node");
    BareJid jid = ParserUtils.getBareJidAttribute(parser);
    String affiliationString = parser.getAttributeValue(null, "affiliation");
    Affiliation.Type affiliationType = null;
    if (affiliationString != null) {
        affiliationType = Affiliation.Type.valueOf(affiliationString);
    }
    Affiliation affiliation;
    if (node != null && jid == null) {
        // affiliationType may be empty
        affiliation = new Affiliation(node, affiliationType);
    } else if (node == null && jid != null) {
        // TODO
        PubSubNamespace namespace = null;
        affiliation = new Affiliation(jid, affiliationType, namespace);
    } else {
        throw new SmackException("Invalid affililation. Either one of 'node' or 'jid' must be set" + ". Node: " + node + ". Jid: " + jid + '.');
    }
    return affiliation;
}
Also used : BareJid(org.jxmpp.jid.BareJid) SmackException(org.jivesoftware.smack.SmackException) Affiliation(org.jivesoftware.smackx.pubsub.Affiliation) PubSubNamespace(org.jivesoftware.smackx.pubsub.packet.PubSubNamespace)

Example 2 with PubSubNamespace

use of org.jivesoftware.smackx.pubsub.packet.PubSubNamespace in project Smack by igniterealtime.

the class PubSubProvider method parse.

@Override
public PubSub parse(XmlPullParser parser, int initialDepth) throws Exception {
    String namespace = parser.getNamespace();
    PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
    PubSub pubsub = new PubSub(pubSubNamespace);
    outerloop: while (true) {
        int eventType = parser.next();
        switch(eventType) {
            case XmlPullParser.START_TAG:
                PacketParserUtils.addExtensionElement(pubsub, parser);
                break;
            case XmlPullParser.END_TAG:
                if (parser.getDepth() == initialDepth) {
                    break outerloop;
                }
                break;
        }
    }
    return pubsub;
}
Also used : PubSub(org.jivesoftware.smackx.pubsub.packet.PubSub) PubSubNamespace(org.jivesoftware.smackx.pubsub.packet.PubSubNamespace)

Example 3 with PubSubNamespace

use of org.jivesoftware.smackx.pubsub.packet.PubSubNamespace in project Smack by igniterealtime.

the class PubSubProvider method parse.

@Override
public PubSub parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
    String namespace = parser.getNamespace();
    PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
    PubSub pubsub = new PubSub(pubSubNamespace);
    outerloop: while (true) {
        XmlPullParser.Event eventType = parser.next();
        switch(eventType) {
            case START_ELEMENT:
                PacketParserUtils.addExtensionElement(pubsub, parser, xmlEnvironment);
                break;
            case END_ELEMENT:
                if (parser.getDepth() == initialDepth) {
                    break outerloop;
                }
                break;
            default:
                // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
                break;
        }
    }
    return pubsub;
}
Also used : PubSub(org.jivesoftware.smackx.pubsub.packet.PubSub) PubSubNamespace(org.jivesoftware.smackx.pubsub.packet.PubSubNamespace)

Aggregations

PubSubNamespace (org.jivesoftware.smackx.pubsub.packet.PubSubNamespace)3 PubSub (org.jivesoftware.smackx.pubsub.packet.PubSub)2 SmackException (org.jivesoftware.smack.SmackException)1 Affiliation (org.jivesoftware.smackx.pubsub.Affiliation)1 BareJid (org.jxmpp.jid.BareJid)1