Constructor and Description |
---|
XmlUtils() |
Modifier and Type | Method and Description |
---|---|
static LinkedList<Object> |
collapseTextNodes(LinkedList<Object> l)
Given a list of Strings and other Objects, combines Strings that are next to each other in the list.
|
static String |
decode(String s,
StringBuilder sb)
Translates any _x####_ sequences (introduced by the various encode methods) back into their original characters.
|
static Writer |
encodeAttrName(Writer w,
Object o)
Serializes and encodes the specified object as valid XML attribute name.
|
static Writer |
encodeAttrValue(Writer w,
Object o,
boolean trim)
Encodes the specified attribute value and sends the results to the specified writer.
|
static String |
encodeElementName(Object o)
Encodes any invalid XML element name characters to
|
static Writer |
encodeElementName(Writer w,
Object o)
Encodes any invalid XML element name characters to
|
static Writer |
encodeText(Writer w,
Object o,
boolean trim,
boolean preserveWhitespace)
Encodes the specified element text and sends the results to the specified writer.
|
static String |
escapeText(Object o)
Escapes invalid XML text characters to
|
static Namespace |
findNamespace(List<Xml> xmls,
List<XmlSchema> schemas)
Find the namespace given a list of
|
static String |
toReadableEvent(XMLStreamReader r)
Utility method that converts the current event on the XML stream to something human-readable for debug purposes.
|
public XmlUtils()
public static final Writer encodeElementName(Writer w, Object o) throws IOException
w
- The writer to send the output to.o
- The object being encoded.IOException
- Throw by the writer.public static final String encodeElementName(Object o)
o
- The object being encoded.public static final String escapeText(Object o)
o
- The object being encoded.public static final Writer encodeText(Writer w, Object o, boolean trim, boolean preserveWhitespace) throws IOException
Encodes any invalid XML text characters to
Encodes
Encodes invalid XML text characters to
w
- The writer to send the output to.o
- The object being encoded.trim
- Trim the text before serializing it.preserveWhitespace
- Specifies whether we're in preserve-whitespace mode.
(e.g. XmlFormat.MIXED_PWS
or XmlFormat.TEXT_PWS
.
If IOException
- Thrown from the writer.public static final Writer encodeAttrName(Writer w, Object o) throws IOException
w
- The writer to send the output to.o
- The object being serialized.IOException
- If a problem occurred.public static final Writer encodeAttrValue(Writer w, Object o, boolean trim) throws IOException
Encodes any invalid XML text characters to
Encodes
Encodes invalid XML text characters to
w
- The writer to send the output to.o
- The object being encoded.trim
- Trim the text before serializing it.
If IOException
- Thrown from the writer.public static final String decode(String s, StringBuilder sb)
s
- The string being decoded.sb
- The string builder to use as a scratch pad.public static LinkedList<Object> collapseTextNodes(LinkedList<Object> l)
l
- The list of text nodes to collapse.public static Namespace findNamespace(List<Xml> xmls, List<XmlSchema> schemas)
The annotations should be a child-to-parent ordering of annotations found on a class or method.
xmls
- The list of schemas
- The list of public static final String toReadableEvent(XMLStreamReader r)
r
- The XML stream reader whose current event is to be converted to a readable string.Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.