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 intprivate static final char -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCan this text be stored into a CDATA block?static booleanisWhiteSpace(String text) Checks if this text purely consists of the white space characters ' ', TAB, NEWLINE.private static charstatic booleanneedsEncoding(String text) Checks if this text needs encoding in order to be represented in XML.static booleanneedsEncoding(String data, boolean checkForAttr) Checks if this text needs encoding in order to be represented in XML.static StringxmlDecodeTextToCDATA(String pcdata) Make CDATA out of possibly encoded PCDATA.static StringxmlEncodeText(String text) Encodes text as XML in the most suitable way, either CDATA block or PCDATA.static voidxmlEncodeText(String text, Writer writer) static StringReturns string as CDATA block if possible, otherwise null.static StringxmlEncodeTextAsPCDATA(String text) Encodes any text as PCDATA.static StringxmlEncodeTextAsPCDATA(String text, boolean forAttribute) Encodes any text as PCDATA.static StringxmlEncodeTextAsPCDATA(String text, boolean forAttribute, char quoteChar) Encodes any text as PCDATA.static voidxmlEncodeTextAsPCDATA(String text, boolean forAttribute, char quoteChar, Writer n) static StringxmlEncodeTextForAttribute(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 thischaris 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. SetcheckForAttrif 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
-