final class XMLEncode
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static int |
CDATA_BLOCK_THRESHOLD_LENGTH |
private static char |
DEFAULT_QUOTE_CHAR |
Constructor and Description |
---|
XMLEncode() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isCompatibleWithCDATABlock(java.lang.String text)
Can this text be stored into a CDATA block?
|
static boolean |
isWhiteSpace(java.lang.String text)
Checks if this text purely consists of the white space characters
' ', TAB, NEWLINE.
|
private static char |
lookAhead(int la,
int offset,
java.lang.String data) |
static boolean |
needsEncoding(java.lang.String text)
Checks if this text needs encoding in order to be represented in XML.
|
static boolean |
needsEncoding(java.lang.String data,
boolean checkForAttr)
Checks if this text needs encoding in order to be represented in XML.
|
static java.lang.String |
xmlDecodeTextToCDATA(java.lang.String pcdata)
Make CDATA out of possibly encoded PCDATA.
|
static java.lang.String |
xmlEncodeText(java.lang.String text)
Encodes text as XML in the most suitable way, either CDATA block or PCDATA.
|
static void |
xmlEncodeText(java.lang.String text,
java.io.Writer writer) |
static java.lang.String |
xmlEncodeTextAsCDATABlock(java.lang.String text)
Returns string as CDATA block if possible, otherwise null.
|
static java.lang.String |
xmlEncodeTextAsPCDATA(java.lang.String text)
Encodes any text as PCDATA.
|
static java.lang.String |
xmlEncodeTextAsPCDATA(java.lang.String text,
boolean forAttribute)
Encodes any text as PCDATA.
|
static java.lang.String |
xmlEncodeTextAsPCDATA(java.lang.String text,
boolean forAttribute,
char quoteChar)
Encodes any text as PCDATA.
|
static void |
xmlEncodeTextAsPCDATA(java.lang.String text,
boolean forAttribute,
char quoteChar,
java.io.Writer n) |
static java.lang.String |
xmlEncodeTextForAttribute(java.lang.String text,
char quoteChar)
Makes any text fit into XML attributes.
|
private static final int CDATA_BLOCK_THRESHOLD_LENGTH
private static final char DEFAULT_QUOTE_CHAR
public static boolean isWhiteSpace(java.lang.String text)
public static java.lang.String xmlEncodeTextForAttribute(java.lang.String text, char quoteChar)
public static java.lang.String xmlEncodeText(java.lang.String text)
public static void xmlEncodeText(java.lang.String text, java.io.Writer writer)
public static java.lang.String xmlEncodeTextAsPCDATA(java.lang.String text)
public static java.lang.String xmlEncodeTextAsPCDATA(java.lang.String text, boolean forAttribute)
forAttribute
- if you want
quotes and apostrophes specially treated for attributespublic static java.lang.String xmlEncodeTextAsPCDATA(java.lang.String text, boolean forAttribute, char quoteChar)
forAttribute
- if you want
quotes and apostrophes specially treated for attributesquoteChar
- if this is for attributes this char
is used to quote the attribute valuepublic static void xmlEncodeTextAsPCDATA(java.lang.String text, boolean forAttribute, char quoteChar, java.io.Writer n)
public static java.lang.String xmlEncodeTextAsCDATABlock(java.lang.String text)
public static boolean needsEncoding(java.lang.String text)
public static boolean needsEncoding(java.lang.String data, boolean checkForAttr)
checkForAttr
if you want to check for storability in
an attribute.public static boolean isCompatibleWithCDATABlock(java.lang.String text)
public static java.lang.String xmlDecodeTextToCDATA(java.lang.String pcdata)
private static char lookAhead(int la, int offset, java.lang.String data)