Search in sources :

Example 1 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) throws Exception {
    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 2 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) throws Exception {
    boolean selfOwned = ParserUtils.getBooleanAttribute(parser, "selfOwned", false);
    NodeInfo nodeInfo = NodeInfoParser.parse(parser);
    List<Tag> tags = new ArrayList<>();
    while (parser.getDepth() != initialDepth) {
        int event = parser.next();
        if (event != XmlPullParser.START_TAG) {
            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) Tag(org.jivesoftware.smackx.iot.discovery.element.Tag) IoTRegister(org.jivesoftware.smackx.iot.discovery.element.IoTRegister)

Example 3 with NodeInfo

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

the class IoTFieldsExtensionProvider method parseNode.

public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
    final int initialDepth = parser.getDepth();
    final NodeInfo nodeInfo = NodeInfoParser.parse(parser);
    List<TimestampElement> timestampElements = new ArrayList<>();
    outerloop: while (true) {
        final XmlPullParser.Event eventType = parser.next();
        final String name = parser.getName();
        switch(eventType) {
            case START_ELEMENT:
                switch(name) {
                    case TimestampElement.ELEMENT:
                        TimestampElement timestampElement = parseTimestampElement(parser);
                        timestampElements.add(timestampElement);
                        break;
                }
                break;
            case END_ELEMENT:
                if (parser.getDepth() == initialDepth) {
                    break outerloop;
                }
                break;
            default:
                // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
                break;
        }
    }
    return new NodeElement(nodeInfo, timestampElements);
}
Also used : NodeInfo(org.jivesoftware.smackx.iot.element.NodeInfo) TimestampElement(org.jivesoftware.smackx.iot.data.element.TimestampElement) ArrayList(java.util.ArrayList) NodeElement(org.jivesoftware.smackx.iot.data.element.NodeElement)

Example 4 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) throws Exception {
    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 5 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) throws Exception {
    Jid jid = ParserUtils.getJidAttribute(parser);
    if (jid.hasResource()) {
        throw new SmackException("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) SmackException(org.jivesoftware.smack.SmackException)

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