public XmlStringBuilder optXmlLangAttribute(String lang) { if (!StringUtils.isNullOrEmpty(lang)) { xmllangAttribute(lang); } return this; }
/** * Appends a tag that indicates that a body section begins. * * @param style the XHTML style of the body * @param lang the language of the body * @return this. */ private XHTMLText appendOpenBodyTag(String style, String lang) { text.halfOpenElement(Message.BODY); text.xmlnsAttribute(NAMESPACE); text.optElement(STYLE, style); text.xmllangAttribute(lang); text.rightAngleBracket(); return this; }
public XmlStringBuilder toXML() { XmlStringBuilder xml = new XmlStringBuilder(); xml.halfOpenElement("identity"); xml.xmllangAttribute(lang); xml.attribute("category", category); xml.optAttribute("name", name); xml.optAttribute("type", type); xml.closeEmptyElement(); return xml; }
/** * Add to, from, id and 'xml:lang' attributes * * @param xml the {@link XmlStringBuilder}. * @param enclosingNamespace the enclosing XML namespace. * @return the set namespace for this stanza. */ protected String addCommonAttributes(XmlStringBuilder xml, String enclosingNamespace) { String namespace; if (enclosingNamespace == null || !enclosingNamespace.equals(StreamOpen.CLIENT_NAMESPACE) || !enclosingNamespace.equals(StreamOpen.SERVER_NAMESPACE)) { namespace = StreamOpen.CLIENT_NAMESPACE; } else { namespace = enclosingNamespace; } xml.xmlnsAttribute(namespace); xml.optAttribute("to", getTo()); xml.optAttribute("from", getFrom()); xml.optAttribute("id", getStanzaId()); xml.xmllangAttribute(getLanguage()); return namespace; }
@Override public XmlStringBuilder toXML(String enclosingNamespace) { XmlStringBuilder xml = new XmlStringBuilder(); xml.halfOpenElement(getElementName()); // We always want to state 'xmlns' for stream open tags. if (enclosingNamespace == null) { enclosingNamespace = CLIENT_NAMESPACE; } xml.attribute("xmlns", enclosingNamespace); xml.attribute("to", to); xml.attribute("xmlns:stream", "http://etherx.jabber.org/streams"); xml.attribute("version", VERSION); xml.optAttribute("from", from); xml.optAttribute("id", id); xml.xmllangAttribute(lang); xml.rightAngleBracket(); return xml; }
public XmlStringBuilder optXmlLangAttribute(String lang) { if (!StringUtils.isNullOrEmpty(lang)) { xmllangAttribute(lang); } return this; }
/** * Add to, from, id and 'xml:lang' attributes * * @param xml the {@link XmlStringBuilder}. * @param enclosingNamespace the enclosing XML namespace. * @return the set namespace for this stanza. */ protected String addCommonAttributes(XmlStringBuilder xml, String enclosingNamespace) { String namespace; if (enclosingNamespace == null || !enclosingNamespace.equals(StreamOpen.CLIENT_NAMESPACE) || !enclosingNamespace.equals(StreamOpen.SERVER_NAMESPACE)) { namespace = StreamOpen.CLIENT_NAMESPACE; } else { namespace = enclosingNamespace; } xml.xmlnsAttribute(namespace); xml.optAttribute("to", getTo()); xml.optAttribute("from", getFrom()); xml.optAttribute("id", getStanzaId()); xml.xmllangAttribute(getLanguage()); return namespace; }
@Override public XmlStringBuilder toXML(String enclosingNamespace) { XmlStringBuilder xml = new XmlStringBuilder(); xml.halfOpenElement(getElementName()); // We always want to state 'xmlns' for stream open tags. xml.attribute("xmlns", enclosingNamespace); xml.attribute("to", to); xml.attribute("xmlns:stream", "http://etherx.jabber.org/streams"); xml.attribute("version", VERSION); xml.optAttribute("from", from); xml.optAttribute("id", id); xml.xmllangAttribute(lang); xml.rightAngleBracket(); return xml; }
@Override public XmlStringBuilder toXML() { final XmlStringBuilder buf = new XmlStringBuilder(); buf.halfOpenElement("presence"); buf.xmlnsAttribute(getXmlns()); buf.xmllangAttribute(getLanguage()); addCommonAttributes(buf); if (invisible) { buf.attribute("type", "invisible"); } else if (getType() != Type.available) { buf.attribute("type", getType()); } buf.rightAngelBracket(); buf.optElement("status", getStatus()); if (getPriority() != Integer.MIN_VALUE) { buf.element("priority", Integer.toString(getPriority())); } if (getMode() != null && getMode() != Mode.available) { buf.element("show", getMode()); } buf.append(getExtensionsXML()); // Add the error sub-packet, if there is one. final XMPPError error = getError(); if (error != null) { buf.append(error.toXML()); } buf.closeElement("presence"); return buf; }