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
-
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 theDate
instance as its value, which will get formatted withXmppDateTime.formatXEP0082Date(Date)
.char
charAt
(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 theDate
instance as its content, which will get formatted withXmppDateTime.formatXEP0082Date(Date)
.emptyElement
(Enum<?> element) emptyElement
(String element) boolean
escape
(CharSequence text) escapeAttributeValue
(String value) escapedElement
(String name, String escapedContent) halfOpenElement
(String name) halfOpenElement
(NamedElement namedElement) int
hashCode()
jidAttribute
(Jid jid) int
length()
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) Add a new attribute to this builder, with theDate
instance as its value, which will get formatted withXmppDateTime.formatXEP0082Date(Date)
ifDate
instance is notnull
.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) Add a new element to this builder, with theDate
instance as its content, which will get formatted withXmppDateTime.formatXEP0082Date(Date)
ifDate
instance is notnull
.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
(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 XmlStringBuilder
protected XmlStringBuilder
prelude
(XmlElement pe) Add a right angle bracket '>'.static void
setAppendMethod
(org.jivesoftware.smack.util.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) void
write
(Writer writer, XmlEnvironment enclosingXmlEnvironment) Write the contents of thisXmlStringBuilder
to aWriter
.xmllangAttribute
(String value) xmlnsAttribute
(String value) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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 theDate
instance 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 theDate
instance as its content, which will get formatted withXmppDateTime.formatXEP0082Date(Date)
ifDate
instance 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 theDate
instance 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 theDate
instance as its value, which will get formatted withXmppDateTime.formatXEP0082Date(Date)
ifDate
instance 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
public static void setAppendMethod(org.jivesoftware.smack.util.XmlStringBuilder.AppendApproach appendApproach) Set the builders approach on how to append new char sequences.- Parameters:
appendApproach
- the append approach.
-
append
- Specified by:
append
in interfaceAppendable
-
append
- Specified by:
append
in interfaceAppendable
-
append
- Specified by:
append
in interfaceAppendable
-
length
- Specified by:
length
in interfaceCharSequence
-
charAt
- Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
equals
-
hashCode
-
write
Write the contents of thisXmlStringBuilder
to 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
-