Package org.jivesoftware.smack.util
Class XmlStringBuilder
java.lang.Object
org.jivesoftware.smack.util.XmlStringBuilder
- All Implemented Interfaces:
Appendable,CharSequence,Element
- Direct Known Subclasses:
IQ.IQChildElementXmlStringBuilder
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXmlStringBuilder(String elementName, String xmlNs, String xmlLang, XmlEnvironment enclosingXmlEnvironment) XmlStringBuilder(XmlElement element, XmlEnvironment enclosingXmlEnvironment) -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) append(CharSequence csq) append(CharSequence csq, int start, int end) append(Collection<? extends Element> elements) append(XmlStringBuilder xsb) <E extends Enum<?>>
XmlStringBuilderattribute(String name, CharSequence value) Does nothing if value is null.Add a new attribute to this builder, with theDateinstance as its value, which will get formatted withXmppDateTime.formatXEP0082Date(Date).charcharAt(int index) closeElement(String name) condAttribute(boolean condition, String name, String value) condEmptyElement(boolean condition, String element) element(String name, CharSequence content) Add a new element to this builder.Add a new element to this builder.Add a new element to this builder, with theDateinstance as its content, which will get formatted withXmppDateTime.formatXEP0082Date(Date).emptyElement(Enum<?> element) emptyElement(String element) booleanescape(CharSequence text) escapeAttributeValue(String value) escapedElement(String name, String escapedContent) halfOpenElement(String name) halfOpenElement(NamedElement namedElement) inthashCode()jidAttribute(org.jxmpp.jid.Jid jid) intlength()openElement(String name) optAppend(Collection<? extends Element> elements) optAttribute(String name, CharSequence value) optAttribute(String name, Enum<?> value) optAttribute(String name, Long value) optAttribute(String name, Number number) optAttribute(String name, String value) optAttribute(String name, Date value) optAttributeCs(String name, CharSequence value) Same asoptAttribute(String, CharSequence), but with a different method name.optBooleanAttribute(String name, boolean bool) optBooleanAttributeDefaultTrue(String name, boolean bool) optElement(String name, CharSequence content) optElement(String name, Enum<?> content) optElement(String name, Object object) optElement(String name, String content) optElement(String name, Date content) optElement(Element element) optEscape(CharSequence text) optIntAttribute(String name, int value) Add the given attribute ifvalue => 0.optIntAttribute(String name, Integer value) If the provided Integer argument is not null, then add a new XML attribute with the given name and the Integer as value.optIntElement(String name, int value) optJidAttribute(org.jxmpp.jid.Jid jid) optLongAttribute(String name, Long value) Add the given attribute if value not null andvalue => 0.optTextChild(CharSequence sqc, NamedElement parentElement) optXmlLangAttribute(String lang) protected XmlStringBuilderprotected XmlStringBuilderprelude(XmlElement pe) Add a right angle bracket '>'.static voidsetAppendMethod(XmlStringBuilder.AppendApproach appendApproach) Set the builders approach on how to append new char sequences.subSequence(int start, int end) text(CharSequence text) toList(XmlEnvironment enclosingXmlEnvironment) toString()toXML(XmlEnvironment enclosingXmlEnvironment) voidwrite(Writer writer, XmlEnvironment enclosingXmlEnvironment) Write the contents of thisXmlStringBuilderto aWriter.xmllangAttribute(String value) xmlnsAttribute(String value) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints
-
Field Details
-
RIGHT_ANGLE_BRACKET
-
-
Constructor Details
-
XmlStringBuilder
public XmlStringBuilder() -
XmlStringBuilder
-
XmlStringBuilder
-
XmlStringBuilder
-
XmlStringBuilder
public XmlStringBuilder(String elementName, String xmlNs, String xmlLang, XmlEnvironment enclosingXmlEnvironment)
-
-
Method Details
-
getXmlEnvironment
-
escapedElement
-
element
Add a new element to this builder.- Parameters:
name- TODO javadoc me pleasecontent- TODO javadoc me please- Returns:
- the XmlStringBuilder
-
element
Add a new element to this builder, with theDateinstance as its content, which will get formatted withXmppDateTime.formatXEP0082Date(Date).- Parameters:
name- element namecontent- content of element- Returns:
- this XmlStringBuilder
-
element
Add a new element to this builder.- Parameters:
name- TODO javadoc me pleasecontent- TODO javadoc me please- Returns:
- the XmlStringBuilder
-
element
-
optElement
-
optElement
Add a new element to this builder, with theDateinstance as its content, which will get formatted withXmppDateTime.formatXEP0082Date(Date)ifDateinstance is notnull.- Parameters:
name- element namecontent- content of element- Returns:
- this XmlStringBuilder
-
optElement
-
optElement
-
optElement
-
optElement
-
optIntElement
-
halfOpenElement
-
halfOpenElement
-
openElement
-
closeElement
-
closeElement
-
closeEmptyElement
-
rightAngleBracket
Add a right angle bracket '>'.- Returns:
- a reference to this object.
-
attribute
Does nothing if value is null.- Parameters:
name- TODO javadoc me pleasevalue- TODO javadoc me please- Returns:
- the XmlStringBuilder
-
attribute
-
attribute
Add a new attribute to this builder, with theDateinstance as its value, which will get formatted withXmppDateTime.formatXEP0082Date(Date).- Parameters:
name- name of attributevalue- value of attribute- Returns:
- this XmlStringBuilder
-
attribute
-
attribute
-
attribute
-
attribute
-
attribute
-
jidAttribute
-
optJidAttribute
-
optAttribute
-
optAttribute
-
optAttribute
Add a new attribute to this builder, with theDateinstance as its value, which will get formatted withXmppDateTime.formatXEP0082Date(Date)ifDateinstance is notnull.- Parameters:
name- attribute namevalue- value of this attribute- Returns:
- this XmlStringBuilder
-
optAttribute
-
optAttribute
-
optAttribute
-
optAttributeCs
Same asoptAttribute(String, CharSequence), but with a different method name. This method can be used if the provided attribute value argument type causes ambiguity in method overloading. For example if the type is a subclass of Number and CharSequence.- Parameters:
name- the name of the attribute.value- the value of the attribute.- Returns:
- a reference to this object.
- Since:
- 4.5
-
optIntAttribute
Add the given attribute ifvalue => 0.- Parameters:
name- TODO javadoc me pleasevalue- TODO javadoc me please- Returns:
- a reference to this object
-
optIntAttribute
If the provided Integer argument is not null, then add a new XML attribute with the given name and the Integer as value.- Parameters:
name- the XML attribute name.value- the optional integer to use as the attribute's value.- Returns:
- a reference to this object.
- Since:
- 4.4.1
-
optLongAttribute
Add the given attribute if value not null andvalue => 0.- Parameters:
name- TODO javadoc me pleasevalue- TODO javadoc me please- Returns:
- a reference to this object
-
optBooleanAttribute
-
optBooleanAttributeDefaultTrue
-
xmlnsAttribute
-
xmllangAttribute
-
optXmlLangAttribute
-
text
-
escape
-
escapeAttributeValue
-
optEscape
-
escape
-
prelude
-
prelude
-
optAppend
-
optAppend
-
optTextChild
-
append
-
append
-
append
-
emptyElement
-
emptyElement
-
condEmptyElement
-
condAttribute
-
setAppendMethod
Set the builders approach on how to append new char sequences.- Parameters:
appendApproach- the append approach.
-
append
- Specified by:
appendin interfaceAppendable
-
append
- Specified by:
appendin interfaceAppendable
-
append
- Specified by:
appendin interfaceAppendable
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
equals
-
hashCode
public int hashCode() -
write
Write the contents of thisXmlStringBuilderto aWriter. This will write the single parts one-by-one, avoiding allocation of a big continuous memory block holding the XmlStringBuilder contents.- Parameters:
writer- TODO javadoc me pleaseenclosingXmlEnvironment- the enclosing XML environment.- Throws:
IOException- if an I/O error occurred.
-
toList
-
toXML
-