public static EntityBareJid getBareJidAttribute(XmlPullParser parser) throws XmppStringprepException { return getBareJidAttribute(parser, JID); }
@Override public Friend parse(XmlPullParser parser, int initialDepth) throws XmppStringprepException { BareJid jid = ParserUtils.getBareJidAttribute(parser); return new Friend(jid); }
@Override public Unfriend parse(XmlPullParser parser, int initialDepth) throws Exception { BareJid jid = ParserUtils.getBareJidAttribute(parser); return new Unfriend(jid); }
/** * PacketExtensionProvider implementation. * @throws IOException * @throws XmlPullParserException */ @Override public WorkgroupInformation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { EntityBareJid workgroupJID = ParserUtils.getBareJidAttribute(parser); // since this is a start and end tag, and we arrive on the start, this should guarantee // we leave on the end parser.next(); return new WorkgroupInformation(workgroupJID); } }
private static MUCUser.Decline parseDecline(XmlPullParser parser) throws XmlPullParserException, IOException { String reason = null; EntityBareJid to = ParserUtils.getBareJidAttribute(parser, "to"); EntityBareJid from = ParserUtils.getBareJidAttribute(parser, "from"); outerloop: while (true) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals("reason")) { reason = parser.nextText(); } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals("decline")) { break outerloop; } } } return new MUCUser.Decline(reason, from, to); } }
private Item parseAgent(XmlPullParser parser) throws XmlPullParserException, IOException { boolean done = false; EntityBareJid jid = ParserUtils.getBareJidAttribute(parser); String type = parser.getAttributeValue("", "type"); String name = null; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG && "name".equals(parser.getName())) { name = parser.nextText(); } else if (eventType == XmlPullParser.END_TAG && "agent".equals(parser.getName())) { done = true; } } return new Item(jid, type, name); } }
@Override public AgentStatus parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { AgentStatus agentStatus = new AgentStatus(); agentStatus.workgroupJID = ParserUtils.getBareJidAttribute(parser); boolean done = false; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if ("chat".equals(parser.getName())) { agentStatus.currentChats.add(parseChatInfo(parser)); } else if ("max-chats".equals(parser.getName())) { agentStatus.maxChats = Integer.parseInt(parser.nextText()); } } else if (eventType == XmlPullParser.END_TAG && ELEMENT_NAME.equals(parser.getName())) { done = true; } } return agentStatus; }
private static MUCUser.Invite parseInvite(XmlPullParser parser) throws XmlPullParserException, IOException { String reason = null; EntityBareJid to = ParserUtils.getBareJidAttribute(parser, "to"); EntityJid from = ParserUtils.getEntityJidAttribute(parser, "from"); outerloop: while (true) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals("reason")) { reason = parser.nextText(); } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals("invite")) { break outerloop; } } } return new MUCUser.Invite(reason, from, to); }
public static Destroy parseDestroy(XmlPullParser parser) throws XmlPullParserException, IOException { final int initialDepth = parser.getDepth(); final EntityBareJid jid = ParserUtils.getBareJidAttribute(parser); String reason = null; outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: final String name = parser.getName(); switch (name) { case "reason": reason = parser.nextText(); break; } break; case XmlPullParser.END_TAG: if (initialDepth == parser.getDepth()) { break outerloop; } break; } } return new Destroy(jid, reason); } }
private static BookmarkedConference getConferenceStorage(XmlPullParser parser) throws XmlPullParserException, IOException { String name = parser.getAttributeValue("", "name"); boolean autojoin = ParserUtils.getBooleanAttribute(parser, "autojoin", false); EntityBareJid jid = ParserUtils.getBareJidAttribute(parser);
@Override public Affiliation parse(XmlPullParser parser, int initialDepth) throws Exception { String node = parser.getAttributeValue(null, "node"); BareJid jid = ParserUtils.getBareJidAttribute(parser); String namespaceString = parser.getNamespace(); AffiliationNamespace namespace = AffiliationNamespace.fromXmlns(namespaceString); 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, namespace); } else if (node == null && jid != 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; }
public static EntityBareJid getBareJidAttribute(XmlPullParser parser) throws XmppStringprepException { return getBareJidAttribute(parser, JID); }
@Override public Friend parse(XmlPullParser parser, int initialDepth) throws XmppStringprepException { BareJid jid = ParserUtils.getBareJidAttribute(parser); return new Friend(jid); }
@Override public Unfriend parse(XmlPullParser parser, int initialDepth) throws Exception { BareJid jid = ParserUtils.getBareJidAttribute(parser); return new Unfriend(jid); }