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

The following examples show how to use org.jivesoftware.smack.util.XmlStringBuilder#closeElement() . 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: 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 2
Source File: Session.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    if (optional) {
        xml.rightAngleBracket();
        xml.emptyElement(OPTIONAL_ELEMENT);
        xml.closeElement(this);
    } else {
        xml.closeEmptyElement();
    }
    return xml;
}
 
Example 3
Source File: SubscriptionsExtension.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
protected void addXml(XmlStringBuilder xml) {
    if ((items == null) || (items.size() == 0)) {
        xml.closeEmptyElement();
        return;
    }
    xml.rightAngleBracket();
    xml.append(items);
    xml.closeElement(this);
}
 
Example 4
Source File: CarbonExtension.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.rightAngleBracket();
    xml.append(fwd.toXML());
    xml.closeElement(this);
    return xml;
}
 
Example 5
Source File: EventElement.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.rightAngleBracket();
    xml.append(ext.toXML());
    xml.closeElement(this);
    return xml;
}
 
Example 6
Source File: Failure.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
    xml.rightAngleBracket();

    xml.emptyElement(compressFailureError);
    xml.optElement(stanzaError);

    xml.closeElement(this);
    return xml;
}
 
Example 7
Source File: Base64BinaryChunk.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.attribute("streamId", streamId);
    xml.attribute("nr", nr);
    xml.optBooleanAttribute("last", last);
    xml.rightAngleBracket();
    xml.append(text);
    xml.closeElement(this);
    return xml;
}
 
Example 8
Source File: JingleContentDescription.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    addExtraAttributes(xml);
    xml.rightAngleBracket();

    xml.append(payloads);

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

    for (MarkupChildElement child : getChildElements()) {
        xml.append(child.toXML());
    }

    xml.closeElement(this);
    return xml;
}
 
Example 10
Source File: AbstractTextElement.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
    xml.rightAngleBracket();
    xml.escape(text);
    xml.closeElement(this);
    return xml;
}
 
Example 11
Source File: Mechanisms.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.rightAngleBracket();
    for (String mechanism : mechanisms) {
        xml.element("mechanism", mechanism);
    }
    xml.closeElement(this);
    return xml;
}
 
Example 12
Source File: MUCUser.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this);
    xml.rightAngleBracket();
    xml.optElement(getInvite());
    xml.optElement(getDecline());
    xml.optElement(getItem());
    xml.optElement("password", getPassword());
    xml.append(statusCodes);
    xml.optElement(getDestroy());
    xml.closeElement(this);
    return xml;
}
 
Example 13
Source File: Bytestream.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
    xml.rightAngleBracket();
    xml.escape(getTarget());
    xml.closeElement(this);
    return xml;
}
 
Example 14
Source File: OmemoHeaderElement.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
    XmlStringBuilder sb = new XmlStringBuilder(this, enclosingXmlEnvironment);
    sb.attribute(ATTR_SID, getSid()).rightAngleBracket();

    for (OmemoKeyElement k : getKeys()) {
        sb.append(k);
    }

    sb.openElement(ATTR_IV).append(Base64.encodeToString(getIv())).closeElement(ATTR_IV);

    return sb.closeElement(this);
}
 
Example 15
Source File: TimestampElement.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
    xml.attribute("value", date);
    xml.rightAngleBracket();

    xml.append(fields);

    xml.closeElement(this);
    return xml;
}
 
Example 16
Source File: OpenPgpContentElement.java    From Smack with Apache License 2.0 5 votes vote down vote up
protected void addCommonXml(XmlStringBuilder xml) {
    for (Jid toJid : to != null ? to : Collections.<Jid>emptySet()) {
        xml.halfOpenElement(ELEM_TO).attribute(ATTR_JID, toJid).closeEmptyElement();
    }

    ensureTimestampStringSet();
    xml.halfOpenElement(ELEM_TIME).attribute(ATTR_STAMP, timestampString).closeEmptyElement();

    xml.openElement(ELEM_PAYLOAD);
    for (ExtensionElement element : payload.values()) {
        xml.append(element.toXML(getNamespace()));
    }
    xml.closeElement(ELEM_PAYLOAD);
}
 
Example 17
Source File: Header.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    // Upcast to NamedElement since we don't want a xmlns attribute
    XmlStringBuilder xml = new XmlStringBuilder((NamedElement) this);
    xml.attribute("name", name);
    xml.rightAngleBracket();
    xml.escape(value);
    xml.closeElement(this);
    return xml;
}
 
Example 18
Source File: AffiliationsExtension.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
protected void addXml(XmlStringBuilder xml) {
    if ((items == null) || (items.size() == 0)) {
        xml.closeEmptyElement();
        return;
    }

    xml.rightAngleBracket();
    xml.append(items);
    xml.closeElement(this);
}
 
Example 19
Source File: OptionsExtension.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
protected void addXml(XmlStringBuilder xml) {
    xml.rightAngleBracket();

    xml.halfOpenElement(getElementName());
    xml.attribute("jid", jid);
    xml.optAttribute("node", getNode());
    xml.optAttribute("subid", id);

    xml.closeEmptyElement();
    xml.closeElement(this);
}
 
Example 20
Source File: Checksum.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
    XmlStringBuilder sb = new XmlStringBuilder(this);
    sb.optAttribute(ATTR_CREATOR, creator);
    sb.optAttribute(ATTR_NAME, name);
    sb.rightAngleBracket();
    sb.append(file);
    sb.closeElement(this);
    return sb;
}