Package org.apache.juneau.xml
Class XmlUtils
java.lang.Object
org.apache.juneau.xml.XmlUtils
XML utility methods.
 
See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic LinkedList<Object>collapseTextNodes(LinkedList<Object> value) Given a list of Strings and other Objects, combines Strings that are next to each other in the list.static Stringdecode(String value, StringBuilder sb) Translates any _x####_ sequences (introduced by the various encode methods) back into their original characters.static WriterencodeAttrName(Writer w, Object value) Serializes and encodes the specified object as valid XML attribute name.static WriterencodeAttrValue(Writer w, Object value, boolean trim) Encodes the specified attribute value and sends the results to the specified writer.static WriterencodeElementName(Writer w, Object value) Encodes any invalid XML element name characters to_x####_ sequences.static StringencodeElementName(Object value) Encodes any invalid XML element name characters to_x####_ sequences.static WriterencodeText(Writer w, Object value, boolean trim, boolean preserveWhitespace) Encodes the specified element text and sends the results to the specified writer.static StringescapeText(Object value) Escapes invalid XML text characters to_x####_ sequences.static NamespacefindNamespace(List<Xml> xmls, List<XmlSchema> schemas) Find the namespace given a list of@Xml and@XmlSchema annotations.static StringUtility method that converts the current event on the XML stream to something human-readable for debug purposes.
- 
Constructor Details- 
XmlUtilspublic XmlUtils()
 
- 
- 
Method Details- 
encodeElementNameEncodes any invalid XML element name characters to_x####_ sequences.- Parameters:
- w- The writer to send the output to.
- value- The object being encoded.
- Returns:
- The same writer passed in.
 
- 
encodeElementNameEncodes any invalid XML element name characters to_x####_ sequences.- Parameters:
- value- The object being encoded.
- Returns:
- The encoded element name string.
 
- 
escapeTextEscapes invalid XML text characters to_x####_ sequences.- Parameters:
- value- The object being encoded.
- Returns:
- The encoded string.
 
- 
encodeTextEncodes the specified element text and sends the results to the specified writer.Encodes any invalid XML text characters to _x####_ sequences and sends the response to the specified writer.
 Encodes'&' ,'<' , and'>' as XML entities.
 Encodes invalid XML text characters to_x####_ sequences.- Parameters:
- w- The writer to send the output to.
- value- The object being encoded.
- trim- Trim the text before serializing it.
- preserveWhitespace- Specifies whether we're in preserve-whitespace mode. (e.g.- XmlFormat.MIXED_PWSor- XmlFormat.TEXT_PWS. If- true , leading and trailing whitespace characters will be encoded.
- Returns:
- The same writer passed in.
 
- 
encodeAttrNameSerializes and encodes the specified object as valid XML attribute name.- Parameters:
- w- The writer to send the output to.
- value- The object being serialized.
- Returns:
- This object.
- Throws:
- IOException- If a problem occurred.
 
- 
encodeAttrValueEncodes the specified attribute value and sends the results to the specified writer.Encodes any invalid XML text characters to _x####_ sequences and sends the response to the specified writer.
 Encodes'&' ,'<' ,'>' ,'"' , and'\'' as XML entities.
 Encodes invalid XML text characters to_x####_ sequences.- Parameters:
- w- The writer to send the output to.
- value- The object being encoded.
- trim- Trim the text before serializing it. If- true , leading and trailing whitespace characters will be encoded.
- Returns:
- The same writer passed in.
 
- 
decodeTranslates any _x####_ sequences (introduced by the various encode methods) back into their original characters.- Parameters:
- value- The string being decoded.
- sb- The string builder to use as a scratch pad.
- Returns:
- The decoded string.
 
- 
collapseTextNodesGiven a list of Strings and other Objects, combines Strings that are next to each other in the list.- Parameters:
- value- The list of text nodes to collapse.
- Returns:
- The same list.
 
- 
findNamespaceFind the namespace given a list of@Xml and@XmlSchema annotations.The annotations should be a parent-to-child ordering of annotations found on a class or method. - Parameters:
- xmls- The list of- @Xml annotations.
- schemas- The list of- @XmlSchema annotations.
- Returns:
- The namespace, or null if it couldn't be found.
 
- 
toReadableEventUtility method that converts the current event on the XML stream to something human-readable for debug purposes.- Parameters:
- r- The XML stream reader whose current event is to be converted to a readable string.
- Returns:
- The event in human-readable form.
 
 
-