Java Code Examples for org.jivesoftware.smack.util.XmlStringBuilder#xmllangAttribute()

The following examples show how to use org.jivesoftware.smack.util.XmlStringBuilder#xmllangAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamOpen.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Override
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
    XmlStringBuilder xml = new XmlStringBuilder();
    xml.halfOpenElement(getElementName());

    String namespace = CLIENT_NAMESPACE;
    // We always want to state 'xmlns' for stream open tags.
    if (enclosingXmlEnvironment != null) {
        namespace = enclosingXmlEnvironment.getEffectiveNamespaceOrUse(CLIENT_NAMESPACE);
    }
    xml.attribute("xmlns", namespace);

    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;
}
 
Example 2
Source File: CustomPresence.java    From League-of-Legends-XMPP-Chat-Library with MIT License 5 votes vote down vote up
@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;
}
 
Example 3
Source File: DiscoverInfo.java    From Smack with Apache License 2.0 5 votes vote down vote up
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;
}