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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations