Search in sources :

Example 6 with NodeInfo

use of org.jivesoftware.smackx.iot.element.NodeInfo in project Smack by igniterealtime.

the class IoTDisownProvider method parse.

@Override
public IoTDisown parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmppStringprepException {
    Jid jid = ParserUtils.getJidAttribute(parser);
    NodeInfo nodeInfo = NodeInfoParser.parse(parser);
    return new IoTDisown(jid, nodeInfo);
}
Also used : Jid(org.jxmpp.jid.Jid) NodeInfo(org.jivesoftware.smackx.iot.element.NodeInfo) IoTDisown(org.jivesoftware.smackx.iot.discovery.element.IoTDisown)

Example 7 with NodeInfo

use of org.jivesoftware.smackx.iot.element.NodeInfo in project Smack by igniterealtime.

the class IoTRegisterProvider method parse.

@Override
public IoTRegister parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
    boolean selfOwned = ParserUtils.getBooleanAttribute(parser, "selfOwned", false);
    NodeInfo nodeInfo = NodeInfoParser.parse(parser);
    List<Tag> tags = new ArrayList<>();
    while (parser.getDepth() != initialDepth) {
        XmlPullParser.Event event = parser.next();
        if (event != XmlPullParser.Event.START_ELEMENT) {
            continue;
        }
        final String element = parser.getName();
        Tag.Type type = null;
        switch(element) {
            case "str":
                type = Tag.Type.str;
                break;
            case "num":
                type = Tag.Type.num;
                break;
        }
        if (type == null) {
            continue;
        }
        String name = parser.getAttributeValue(null, "name");
        String value = parser.getAttributeValue(null, "value");
        tags.add(new Tag(name, type, value));
    }
    return new IoTRegister(tags, nodeInfo, selfOwned);
}
Also used : NodeInfo(org.jivesoftware.smackx.iot.element.NodeInfo) ArrayList(java.util.ArrayList) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) Tag(org.jivesoftware.smackx.iot.discovery.element.Tag) IoTRegister(org.jivesoftware.smackx.iot.discovery.element.IoTRegister)

Example 8 with NodeInfo

use of org.jivesoftware.smackx.iot.element.NodeInfo in project Smack by igniterealtime.

the class IoTClaimedProvider method parse.

@Override
public IoTClaimed parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmppStringprepException {
    Jid jid = ParserUtils.getJidAttribute(parser);
    NodeInfo nodeInfo = NodeInfoParser.parse(parser);
    return new IoTClaimed(jid, nodeInfo);
}
Also used : Jid(org.jxmpp.jid.Jid) NodeInfo(org.jivesoftware.smackx.iot.element.NodeInfo) IoTClaimed(org.jivesoftware.smackx.iot.discovery.element.IoTClaimed)

Example 9 with NodeInfo

use of org.jivesoftware.smackx.iot.element.NodeInfo in project Smack by igniterealtime.

the class IoTRemoveProvider method parse.

@Override
public IoTRemove parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException {
    Jid jid = ParserUtils.getJidAttribute(parser);
    if (jid.hasResource()) {
        // TODO: Should be SmackParseException.
        throw new IOException("JID must be without resourcepart");
    }
    BareJid bareJid = jid.asBareJid();
    NodeInfo nodeInfo = NodeInfoParser.parse(parser);
    return new IoTRemove(bareJid, nodeInfo);
}
Also used : IoTRemove(org.jivesoftware.smackx.iot.discovery.element.IoTRemove) Jid(org.jxmpp.jid.Jid) BareJid(org.jxmpp.jid.BareJid) BareJid(org.jxmpp.jid.BareJid) NodeInfo(org.jivesoftware.smackx.iot.element.NodeInfo) IOException(java.io.IOException)

Aggregations

NodeInfo (org.jivesoftware.smackx.iot.element.NodeInfo)9 Jid (org.jxmpp.jid.Jid)6 ArrayList (java.util.ArrayList)3 IoTClaimed (org.jivesoftware.smackx.iot.discovery.element.IoTClaimed)2 IoTDisown (org.jivesoftware.smackx.iot.discovery.element.IoTDisown)2 IoTRegister (org.jivesoftware.smackx.iot.discovery.element.IoTRegister)2 IoTRemove (org.jivesoftware.smackx.iot.discovery.element.IoTRemove)2 Tag (org.jivesoftware.smackx.iot.discovery.element.Tag)2 BareJid (org.jxmpp.jid.BareJid)2 IOException (java.io.IOException)1 SmackException (org.jivesoftware.smack.SmackException)1 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)1 NodeElement (org.jivesoftware.smackx.iot.data.element.NodeElement)1 TimestampElement (org.jivesoftware.smackx.iot.data.element.TimestampElement)1