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

The following examples show how to use org.jivesoftware.smack.util.XmlStringBuilder#xmlnsAttribute() . 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: StreamManagement.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Override
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
    if (condition == null && textElements.isEmpty()) {
        xml.closeEmptyElement();
    } else {
        if (condition != null) {
            xml.rightAngleBracket();
            xml.append(condition.toString());
            xml.xmlnsAttribute(StanzaError.ERROR_CONDITION_AND_TEXT_NAMESPACE);
            xml.closeEmptyElement();
        }
        xml.append(textElements);
        xml.closeElement(ELEMENT);
    }
    return xml;
}
 
Example 2
Source File: StanzaError.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Override
public XmlStringBuilder toXML(XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
    xml.attribute("type", type.toString());
    xml.optAttribute("by", errorGenerator);
    xml.rightAngleBracket();

    xml.halfOpenElement(condition.toString());
    xml.xmlnsAttribute(ERROR_CONDITION_AND_TEXT_NAMESPACE);
    if (conditionText != null) {
        xml.rightAngleBracket();
        xml.escape(conditionText);
        xml.closeElement(condition.toString());
    }
    else {
        xml.closeEmptyElement();
    }

    addDescriptiveTextsAndExtensions(xml);

    xml.closeElement(this);
    return xml;
}
 
Example 3
Source File: BoBExtension.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.rightAngleBracket();

    xml.halfOpenElement(Message.BODY);
    xml.xmlnsAttribute(XHTMLText.NAMESPACE);
    xml.rightAngleBracket();

    xml.openElement(XHTMLText.P);
    xml.optEscape(paragraph);

    xml.halfOpenElement(XHTMLText.IMG);
    xml.optAttribute("alt", alt);
    xml.attribute("src", bobHash.toSrc());
    xml.closeEmptyElement();

    xml.closeElement(XHTMLText.P);
    xml.closeElement(Message.BODY);
    xml.closeElement(this);
    return xml;
}
 
Example 4
Source File: PublishCommentExtension.java    From mangosta-android with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence toXML() {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.attribute("node", NODE + "/" + blogPostId);
    xml.rightAngleBracket();

    xml.halfOpenElement("item");
    xml.attribute("id", id);
    xml.rightAngleBracket();

    xml.halfOpenElement("entry");
    xml.xmlnsAttribute("http://www.w3.org/2005/Atom");
    xml.rightAngleBracket();

    xml.openElement("author");
    xml.element("name", authorName);
    xml.element("uri", "xmpp:" + authorJid);
    xml.closeElement("author");

    xml.halfOpenElement("title");
    xml.attribute("type", "text");
    xml.rightAngleBracket();
    xml.escape(content);
    xml.closeElement("title");

    xml.element("published", published);

    xml.closeElement("entry");
    xml.closeElement("item");
    xml.closeElement(this);
    return xml;
}
 
Example 5
Source File: PublishPostExtension.java    From mangosta-android with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence toXML() {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.attribute("node", NODE);
    xml.rightAngleBracket();

    xml.halfOpenElement("item");
    xml.attribute("id", id);
    xml.rightAngleBracket();

    xml.halfOpenElement("entry");
    xml.xmlnsAttribute("http://www.w3.org/2005/Atom");
    xml.rightAngleBracket();

    xml.halfOpenElement("title");
    xml.attribute("type", "text");
    xml.rightAngleBracket();
    xml.escape(title);
    xml.closeElement("title");

    Date today = Calendar.getInstance().getTime();
    String timeStamp = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(today);
    String idTag = "tag:" + jid.getDomain() + "," + timeStamp + ":posts-" + id;
    xml.element("id", idTag);

    xml.element("published", today);

    xml.element("updated", today);

    xml.closeElement("entry");
    xml.closeElement("item");
    xml.closeElement(this);
    return xml;
}
 
Example 6
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;
}