@Override public XmlStringBuilder toXML(String enclosingNamespace) { XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace); buf.halfOpenElement(ELEMENT); addCommonAttributes(buf, enclosingNamespace); if (type != Type.available) { buf.attribute("type", type); } buf.rightAngleBracket(); buf.optElement("status", status); if (priority != Integer.MIN_VALUE) { buf.element("priority", Integer.toString(priority)); } if (mode != null && mode != Mode.available) { buf.element("show", mode); } buf.append(getExtensions(), enclosingNamespace); // Add the error sub-packet, if there is one. appendErrorIfExists(buf, enclosingNamespace); buf.closeElement(ELEMENT); return buf; }
/** * {@inheritDoc} */ public Collection<ExtensionElement> getPresenceExtensions() { return lastPresenceSent != null ? new ArrayList<>(lastPresenceSent.getExtensions()) : EMPTY_PRESENCE_LIST; }
public static String getJidFromMUCPresence(Presence presence) { Collection<ExtensionElement> extensions = presence.getExtensions(); for (ExtensionElement extension : extensions) { if (extension instanceof MUCUser) { final MUCUser mucUser = (MUCUser) extension; Jid fullJid = mucUser.getItem().getJid(); if ( fullJid == null) { return null; } return fullJid.asBareJid().toString(); } } return null; }
@Override public XmlStringBuilder toXML(String enclosingNamespace) { XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace); buf.halfOpenElement(ELEMENT); addCommonAttributes(buf, enclosingNamespace); if (type != Type.available) { buf.attribute("type", type); } buf.rightAngleBracket(); buf.optElement("status", status); if (priority != Integer.MIN_VALUE) { buf.element("priority", Integer.toString(priority)); } if (mode != null && mode != Mode.available) { buf.element("show", mode); } buf.append(getExtensions(), enclosingNamespace); // Add the error sub-packet, if there is one. appendErrorIfExists(buf, enclosingNamespace); buf.closeElement(ELEMENT); return buf; }