Class XMLEncode
java.lang.Object
org.apache.maven.shared.utils.xml.XMLEncode
Collection of XML encoding/decoding helpers.
This is all about the special characters & and <, and for attributes " and '. These must be encoded/decoded from/to XML.
This is all about the special characters & and <, and for attributes " and '. These must be encoded/decoded from/to XML.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final char
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Can this text be stored into a CDATA block?static boolean
isWhiteSpace
(String text) Checks if this text purely consists of the white space characters ' ', TAB, NEWLINE.private static char
static boolean
needsEncoding
(String text) Checks if this text needs encoding in order to be represented in XML.static boolean
needsEncoding
(String data, boolean checkForAttr) Checks if this text needs encoding in order to be represented in XML.static String
xmlDecodeTextToCDATA
(String pcdata) Make CDATA out of possibly encoded PCDATA.static String
xmlEncodeText
(String text) Encodes text as XML in the most suitable way, either CDATA block or PCDATA.static void
xmlEncodeText
(String text, Writer writer) static String
Returns string as CDATA block if possible, otherwise null.static String
xmlEncodeTextAsPCDATA
(String text) Encodes any text as PCDATA.static String
xmlEncodeTextAsPCDATA
(String text, boolean forAttribute) Encodes any text as PCDATA.static String
xmlEncodeTextAsPCDATA
(String text, boolean forAttribute, char quoteChar) Encodes any text as PCDATA.static void
xmlEncodeTextAsPCDATA
(String text, boolean forAttribute, char quoteChar, Writer n) static String
xmlEncodeTextForAttribute
(String text, char quoteChar) Makes any text fit into XML attributes.
-
Field Details
-
CDATA_BLOCK_THRESHOLD_LENGTH
private static final int CDATA_BLOCK_THRESHOLD_LENGTH- See Also:
-
DEFAULT_QUOTE_CHAR
private static final char DEFAULT_QUOTE_CHAR- See Also:
-
-
Constructor Details
-
XMLEncode
XMLEncode()
-
-
Method Details
-
isWhiteSpace
Checks if this text purely consists of the white space characters ' ', TAB, NEWLINE. -
xmlEncodeTextForAttribute
Makes any text fit into XML attributes. -
xmlEncodeText
Encodes text as XML in the most suitable way, either CDATA block or PCDATA. -
xmlEncodeText
-
xmlEncodeTextAsPCDATA
Encodes any text as PCDATA. -
xmlEncodeTextAsPCDATA
Encodes any text as PCDATA.- Parameters:
forAttribute
- if you want quotes and apostrophes specially treated for attributes
-
xmlEncodeTextAsPCDATA
Encodes any text as PCDATA.- Parameters:
forAttribute
- if you want quotes and apostrophes specially treated for attributesquoteChar
- if this is for attributes thischar
is used to quote the attribute value
-
xmlEncodeTextAsPCDATA
-
xmlEncodeTextAsCDATABlock
Returns string as CDATA block if possible, otherwise null. -
needsEncoding
Checks if this text needs encoding in order to be represented in XML. -
needsEncoding
Checks if this text needs encoding in order to be represented in XML. SetcheckForAttr
if you want to check for storability in an attribute. -
isCompatibleWithCDATABlock
Can this text be stored into a CDATA block? -
xmlDecodeTextToCDATA
Make CDATA out of possibly encoded PCDATA.
E.g. make '&' out of '&' -
lookAhead
-