Package com.nomagic.magicreport.helper
Class XMLUtils
java.lang.Object
com.nomagic.magicreport.helper.XMLUtils
Provides utilities for XML.
- Since:
- Jan 10, 2006 5:27:40 PM
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringfilter(CharSequence value) Filter the specified string for characters that are sensitive to HTML interpreters, returning the string with these characters replaced by the corresponding character entities.static StringfilterExcludeLineBreak(String value) Same asfilter(CharSequence)but exclude line break.static StringfilterIncludeCustomLineBreak(String value, String lineBreakReplacement) Same asfilter(CharSequence)but replace linebreak with lineBreakReplacementstatic NodeListgetElementsByTagName(Element element, String tagName) Returns a List over the direct children of the given element with the given tag name.static StringhtmlPlainText(String xmlContent) Strip all tag element and convert all special characters to plain text.static voidskipBOM(InputStream inputStream) Skip the BOM character.static voidSkip the BOM character.static StringxmlPlainText(String xmlContent) Strip all tag element and convert all special characters to plain text.
-
Method Details
-
filter
Filter the specified string for characters that are sensitive to HTML interpreters, returning the string with these characters replaced by the corresponding character entities.- Parameters:
value- The string to be filtered and returned- Returns:
- string after filtered
-
filterExcludeLineBreak
Same asfilter(CharSequence)but exclude line break. e.g. \r and \n- Parameters:
value- The string to be filtered and returned- Returns:
- string after filtered
-
filterIncludeCustomLineBreak
Same asfilter(CharSequence)but replace linebreak with lineBreakReplacement- Parameters:
value- The string to be filtered and returnedlineBreakReplacement- string to replace the linebreak- Returns:
- string after filtered
-
htmlPlainText
Strip all tag element and convert all special characters to plain text.- Parameters:
xmlContent- the xml content- Returns:
- plain text.
-
xmlPlainText
Strip all tag element and convert all special characters to plain text.- Parameters:
xmlContent- the xml content- Returns:
- plain text.
-
getElementsByTagName
Returns a List over the direct children of the given element with the given tag name.Element.getElementsByTagName(String)gives the corresponding elements in the whole descendance. This method return only direct descendance of element.- Parameters:
element- The parent elementtagName- The name of the desired child- Returns:
- A List of children or zero length of List if children element is not found.
-
skipBOM
Skip the BOM character. Some XML may contains a byte-order mark (BOM). The XML parser will get the error if XML contains BOM character. This method also remove or mark skip byte when reader contain BOM.The BOM is the Unicode character at code point U+FEFF ("zero-width no-break space") when that character is used to denote the endianness of a string of UCS/Unicode characters encoded in UTF-16 or UTF-32.
- Parameters:
reader- Reader- Throws:
IOException- If the stream does not support mark(), or reset()
-
skipBOM
Skip the BOM character. Some XML may contains a byte-order mark (BOM). The XML parser will get the error if XML contains BOM character. This method also remove or mark skip byte when reader contain BOM.The BOM is the Unicode character at code point U+FEFF ("zero-width no-break space") when that character is used to denote the endianness of a string of UCS/Unicode characters encoded in UTF-16 or UTF-32.
- Parameters:
inputStream- InputStream- Throws:
IOException- If the stream does not support mark(), or reset()
-