public final class XMLUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
XMLUtil.HTMLRendererReplacer
This
XMLUtil.ITagReplacer can be used to render HTML into a plain text. |
static interface |
XMLUtil.ITagReplacer
Instances of this interface are used in
replaceTags(String, ITagReplacer)
to replace an individual found tag. |
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTRIBUTE_ENCODING
Attribute name to store encodings.
|
static String |
LEADING_WHITE_SPACE_PER_LEVEL
The used leading white space in each level.
|
| Modifier | Constructor and Description |
|---|---|
private |
XMLUtil()
Forbid instances.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
appendAttribute(String attributeName,
String value,
StringBuffer sb)
Adds an XML attribute to the given
StringBuffer. |
static void |
appendEmptyTag(int level,
String tagName,
Map<String,String> attributeValues,
StringBuffer sb)
Appends an empty tag to the given
StringBuffer. |
static void |
appendEndTag(int level,
String tagName,
StringBuffer sb)
Appends an end tag to the given
StringBuffer. |
static void |
appendNewLine(StringBuffer sb)
Adds a line break to the given
StringBuffer. |
static void |
appendStartTag(int level,
String tagName,
Map<String,String> attributeValues,
StringBuffer sb)
Appends a start tag to the given
StringBuffer. |
static void |
appendWhiteSpace(int level,
StringBuffer sb)
Adds leading white space to the
StringBuffer. |
static void |
appendXmlHeader(String encoding,
StringBuffer sb)
Adds an XML header to the given
StringBuffer. |
static String |
encodeText(String text)
Encodes the given text in a way that it contains no XML elements
and can be used for instance as plain text or attribute value.
|
static boolean |
isEntityNameCharacter(char character)
Checks if the given character is valid to be used in entity names (between
&...;). |
static String |
removeTags(String text)
Removes all tags from the given text.
|
static String |
replaceTags(String text,
XMLUtil.ITagReplacer replacer)
Replaces all tags in the given text with help of the given
XMLUtil.ITagReplacer. |
public static final String ATTRIBUTE_ENCODING
public static final String LEADING_WHITE_SPACE_PER_LEVEL
public static String replaceTags(String text, XMLUtil.ITagReplacer replacer)
XMLUtil.ITagReplacer.text - The text to execute replacements on.replacer - The XMLUtil.ITagReplacer to use.public static String removeTags(String text)
text - The text to remove tags from.public static String encodeText(String text)
Encodes the given text in a way that it contains no XML elements and can be used for instance as plain text or attribute value.
The following signs are replaced:
" => "quot; & => "amp; ' => "apos; < => "lt; > => "gt;
text - The text to encode.public static boolean isEntityNameCharacter(char character)
&...;).character - The character to check.true is valid, false is not valid.public static void appendEmptyTag(int level,
String tagName,
Map<String,String> attributeValues,
StringBuffer sb)
StringBuffer.level - The level.tagName - The tag name.attributeValues - The attributes.sb - The StringBuffer to append to.public static void appendStartTag(int level,
String tagName,
Map<String,String> attributeValues,
StringBuffer sb)
StringBuffer.level - The level.tagName - The tag name.attributeValues - The attributes.sb - The StringBuffer to append to.public static void appendEndTag(int level,
String tagName,
StringBuffer sb)
StringBuffer.level - The level.tagName - The tag name.sb - The StringBuffer to append to.public static void appendWhiteSpace(int level,
StringBuffer sb)
StringBuffer.level - The level in the tree used for leading white space (formating).sb - The StringBuffer to write to.public static void appendAttribute(String attributeName, String value, StringBuffer sb)
StringBuffer.attributeName - The attribute name.value - The attribute value.sb - The StringBuffer to write to.public static void appendXmlHeader(String encoding, StringBuffer sb)
StringBuffer.encoding - The encoding to use.sb - The StringBuffer to write to.public static void appendNewLine(StringBuffer sb)
StringBuffer.sb - The StringBuffer to write to.