public final class XmlEscape
extends Object
Utility class for performing XML escape/unescape operations.
Configuration of escape/unescape operationsEscape operations can be (optionally) configured by means of:
XmlEscapeLevel
enum.XmlEscapeType
enum.Unescape operations need no configuration parameters. Unescape operations will always perform complete unescape of CERs, decimal and hexadecimal references.
FeaturesThis class supports both XML 1.0 and XML 1.1 escape/unescape operations. Whichever the XML version used, only the five predefined XML character entities are supported: <, >, &, " and '. This means there is no support for DTD-defined or user-defined entities.
Each version of XML establishes a series of characters that are considered not-valid, even when escaped —for example, the \u0000 (null byte)—. Escape operations will automatically remove these chars.
Also, each version of XML establishes a series of control characters that, even if allowed as valid characters, should always appear escaped. For example: \u0001 to \u0008 in XML 1.1.
This class supports the whole Unicode character set: \u0000 to \u10FFFF, including characters not representable by only one char in Java (>\uFFFF).
Input/OutputThere are four different input/output modes that can be used in escape/unescape operations:
The following references apply:
Modifier and Type | Method | Description |
---|---|---|
static void |
escapeXml10(char[] text,
int offset,
int len,
java.io.Writer writer) |
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation
on a char[] input.
|
static void |
escapeXml10(char[] text,
int offset,
int len,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.0 escape operation on a char[] input.
|
static void |
escapeXml10(java.io.Reader reader,
java.io.Writer writer) |
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation
on a Reader input, writing results to a Writer.
|
static void |
escapeXml10(java.io.Reader reader,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.0 escape operation on a Reader input,
writing results to a Writer.
|
static String |
escapeXml10(String text) |
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation
on a String input.
|
static void |
escapeXml10(String text,
java.io.Writer writer) |
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation
on a String input, writing results to a Writer.
|
static void |
escapeXml10(String text,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.0 escape operation on a String input,
writing results to a Writer.
|
static String |
escapeXml10(String text,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.0 escape operation on a String input.
|
static void |
escapeXml10Attribute(char[] text,
int offset,
int len,
java.io.Writer writer) |
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation
on a char[] input meant to be an XML attribute value.
|
static void |
escapeXml10Attribute(char[] text,
int offset,
int len,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.0 escape operation on a char[] input
meant to be an XML attribute value.
|
static void |
escapeXml10Attribute(java.io.Reader reader,
java.io.Writer writer) |
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation
on a Reader input meant to be an XML attribute value, writing results to a Writer.
|
static void |
escapeXml10Attribute(java.io.Reader reader,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.0 escape operation on a Reader input
meant to be an XML attribute value, writing results to a Writer.
|
static String |
escapeXml10Attribute(String text) |
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation
on a String input meant to be an XML attribute value.
|
static void |
escapeXml10Attribute(String text,
java.io.Writer writer) |
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation
on a String input meant to be an XML attribute value, writing results to a Writer.
|
static void |
escapeXml10Attribute(String text,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.0 escape operation on a String input
meant to be an XML attribute value, writing results to a Writer.
|
static String |
escapeXml10Attribute(String text,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.0 escape operation on a String input
meant to be an XML attribute value.
|
static void |
escapeXml10AttributeMinimal(char[] text,
int offset,
int len,
java.io.Writer writer) |
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation
on a char[] input meant to be an XML attribute value.
|
static void |
escapeXml10AttributeMinimal(java.io.Reader reader,
java.io.Writer writer) |
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation
on a Reader input meant to be an XML attribute value, writing results to a Writer.
|
static String |
escapeXml10AttributeMinimal(String text) |
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation
on a String input meant to be an XML attribute value.
|
static void |
escapeXml10AttributeMinimal(String text,
java.io.Writer writer) |
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation
on a String input meant to be an XML attribute value, writing results to a Writer.
|
static void |
escapeXml10Minimal(char[] text,
int offset,
int len,
java.io.Writer writer) |
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation
on a char[] input.
|
static void |
escapeXml10Minimal(java.io.Reader reader,
java.io.Writer writer) |
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation
on a Reader input, writing results to a Writer.
|
static String |
escapeXml10Minimal(String text) |
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation
on a String input.
|
static void |
escapeXml10Minimal(String text,
java.io.Writer writer) |
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation
on a String input, writing results to a Writer.
|
static void |
escapeXml11(char[] text,
int offset,
int len,
java.io.Writer writer) |
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation
on a char[] input.
|
static void |
escapeXml11(char[] text,
int offset,
int len,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.1 escape operation on a char[] input.
|
static void |
escapeXml11(java.io.Reader reader,
java.io.Writer writer) |
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation
on a Reader input, writing results to a Writer.
|
static void |
escapeXml11(java.io.Reader reader,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.1 escape operation on a Reader input,
writing results to a Writer.
|
static String |
escapeXml11(String text) |
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation
on a String input.
|
static void |
escapeXml11(String text,
java.io.Writer writer) |
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation
on a String input, writing results to a Writer.
|
static void |
escapeXml11(String text,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.1 escape operation on a String input,
writing results to a Writer.
|
static String |
escapeXml11(String text,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.1 escape operation on a String input.
|
static void |
escapeXml11Attribute(char[] text,
int offset,
int len,
java.io.Writer writer) |
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation
on a char[] input meant to be an XML attribute value.
|
static void |
escapeXml11Attribute(char[] text,
int offset,
int len,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.1 escape operation on a char[] input
meant to be an XML attribute value.
|
static void |
escapeXml11Attribute(java.io.Reader reader,
java.io.Writer writer) |
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation
on a Reader input meant to be an XML attribute value, writing results to a Writer.
|
static void |
escapeXml11Attribute(java.io.Reader reader,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.1 escape operation on a Reader input
meant to be an XML attribute value, writing results to a Writer.
|
static String |
escapeXml11Attribute(String text) |
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation
on a String input meant to be an XML attribute value.
|
static void |
escapeXml11Attribute(String text,
java.io.Writer writer) |
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation
on a String input meant to be an XML attribute value, writing results to a Writer.
|
static void |
escapeXml11Attribute(String text,
java.io.Writer writer,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.1 escape operation on a String input
meant to be an XML attribute value, writing results to a Writer.
|
static String |
escapeXml11Attribute(String text,
XmlEscapeType type,
XmlEscapeLevel level) |
Perform a (configurable) XML 1.1 escape operation on a String input
meant to be an XML attribute value.
|
static void |
escapeXml11AttributeMinimal(char[] text,
int offset,
int len,
java.io.Writer writer) |
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation
on a char[] input meant to be an XML attribute value.
|
static void |
escapeXml11AttributeMinimal(java.io.Reader reader,
java.io.Writer writer) |
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation
on a Reader input meant to be an XML attribute value, writing results to a Writer.
|
static String |
escapeXml11AttributeMinimal(String text) |
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation
on a String input meant to be an XML attribute value.
|
static void |
escapeXml11AttributeMinimal(String text,
java.io.Writer writer) |
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation
on a String input meant to be an XML attribute value, writing results to a Writer.
|
static void |
escapeXml11Minimal(char[] text,
int offset,
int len,
java.io.Writer writer) |
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation
on a char[] input.
|
static void |
escapeXml11Minimal(java.io.Reader reader,
java.io.Writer writer) |
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation
on a Reader input, writing results to a Writer.
|
static String |
escapeXml11Minimal(String text) |
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation
on a String input.
|
static void |
escapeXml11Minimal(String text,
java.io.Writer writer) |
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation
on a String input, writing results to a Writer.
|
static void |
unescapeXml(char[] text,
int offset,
int len,
java.io.Writer writer) |
Perform an XML unescape operation on a char[] input.
|
static void |
unescapeXml(java.io.Reader reader,
java.io.Writer writer) |
Perform an XML unescape operation on a Reader input,
writing results to a Writer.
|
static String |
unescapeXml(String text) |
Perform an XML unescape operation on a String input.
|
static void |
unescapeXml(String text,
java.io.Writer writer) |
Perform an XML unescape operation on a String input,
writing results to a Writer.
|
public static String escapeXml10Minimal(String text)
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
This method calls escapeXml10(String, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.public static String escapeXml11Minimal(String text)
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
This method calls escapeXml11(String, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.public static String escapeXml10AttributeMinimal(String text)
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml10(String, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.public static String escapeXml11AttributeMinimal(String text)
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml11(String, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.public static String escapeXml10(String text)
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
This method calls escapeXml10(String, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.public static String escapeXml11(String text)
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
This method calls escapeXml11(String, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.public static String escapeXml10Attribute(String text)
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml10(String, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.public static String escapeXml11Attribute(String text)
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml11(String, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.public static String escapeXml10(String text, XmlEscapeType type, XmlEscapeLevel level)
Perform a (configurable) XML 1.0 escape operation on a String input.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
All other String-based escapeXml10*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the String to be escaped.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.public static String escapeXml11(String text, XmlEscapeType type, XmlEscapeLevel level)
Perform a (configurable) XML 1.1 escape operation on a String input.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
All other String-based escapeXml11*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the String to be escaped.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.public static String escapeXml10Attribute(String text, XmlEscapeType type, XmlEscapeLevel level)
Perform a (configurable) XML 1.0 escape operation on a String input meant to be an XML attribute value.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
All other String-based escapeXml10*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the String to be escaped.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.public static String escapeXml11Attribute(String text, XmlEscapeType type, XmlEscapeLevel level)
Perform a (configurable) XML 1.1 escape operation on a String input meant to be an XML attribute value.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
All other String-based escapeXml11*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the String to be escaped.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.public static void escapeXml10Minimal(String text, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input, writing results to a Writer.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
This method calls escapeXml10(String, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11Minimal(String text, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input, writing results to a Writer.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
This method calls escapeXml11(String, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10AttributeMinimal(String text, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml10(String, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11AttributeMinimal(String text, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml11(String, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10(String text, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input, writing results to a Writer.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
This method calls escapeXml10(String, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11(String text, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input, writing results to a Writer.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
This method calls escapeXml11(String, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10Attribute(String text, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml10(String, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11Attribute(String text, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml11(String, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10(String text, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.0 escape operation on a String input, writing results to a Writer.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
All other String/Writer-based escapeXml10*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11(String text, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.1 escape operation on a String input, writing results to a Writer.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
All other String/Writer-based escapeXml11*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the String to be escaped.type
- the type of escape operation to be performed, see XmlEscapeType
.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10Attribute(String text, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.0 escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
All other String/Writer-based escapeXml10*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the String to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11Attribute(String text, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.1 escape operation on a String input meant to be an XML attribute value, writing results to a Writer.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
All other String/Writer-based escapeXml11*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the String to be escaped.type
- the type of escape operation to be performed, see XmlEscapeType
.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10Minimal(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a Reader input, writing results to a Writer.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
This method calls escapeXml10(Reader, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11Minimal(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a Reader input, writing results to a Writer.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
This method calls escapeXml11(Reader, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10AttributeMinimal(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml10(Reader, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11AttributeMinimal(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml11(Reader, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
This method calls escapeXml10(Reader, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input, writing results to a Writer.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
This method calls escapeXml11(Reader, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10Attribute(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml10(Reader, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11Attribute(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml11(Reader, Writer, XmlEscapeType, XmlEscapeLevel)
with the following
preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10(java.io.Reader reader, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.0 escape operation on a Reader input, writing results to a Writer.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
All other Reader/Writer-based escapeXml10*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11(java.io.Reader reader, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.1 escape operation on a Reader input, writing results to a Writer.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
All other Reader/Writer-based escapeXml11*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
reader
- the Reader reading the text to be escaped.type
- the type of escape operation to be performed, see XmlEscapeType
.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10Attribute(java.io.Reader reader, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.0 escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
All other Reader/Writer-based escapeXml10*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
reader
- the Reader reading the text to be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11Attribute(java.io.Reader reader, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.1 escape operation on a Reader input meant to be an XML attribute value, writing results to a Writer.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
All other Reader/Writer-based escapeXml11*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
reader
- the Reader reading the text to be escaped.type
- the type of escape operation to be performed, see XmlEscapeType
.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10Minimal(char[] text, int offset, int len, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a char[] input.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
This method calls
escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel)
with the following preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11Minimal(char[] text, int offset, int len, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a char[] input.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
This method calls
escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel)
with the following preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10AttributeMinimal(char[] text, int offset, int len, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 1 (only markup-significant chars) escape operation on a char[] input meant to be an XML attribute value.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls
escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel)
with the following preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11AttributeMinimal(char[] text, int offset, int len, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 1 (only markup-significant chars) escape operation on a char[] input meant to be an XML attribute value.
Level 1 means this method will only escape the five markup-significant characters which are predefined as Character Entity References in XML: <, >, &, " and '.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls
escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel)
with the following preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_1_ONLY_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10(char[] text, int offset, int len, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
This method calls escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel)
with the following preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11(char[] text, int offset, int len, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
This method calls escapeXml11(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel)
with the following preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10Attribute(char[] text, int offset, int len, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.0 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input meant to be an XML attribute value.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml10(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel)
with the following preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11Attribute(char[] text, int offset, int len, java.io.Writer writer) throws java.io.IOException
Perform an XML 1.1 level 2 (markup-significant and all non-ASCII chars) escape operation on a char[] input meant to be an XML attribute value.
Level 2 means this method will escape:
This escape will be performed by replacing those chars by the corresponding XML Character Entity References (e.g. '<') when such CER exists for the replaced character, and replacing by a hexadecimal character reference (e.g. '␰') when there there is no CER for the replaced character.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
This method calls escapeXml11(char[], int, int, java.io.Writer, XmlEscapeType, XmlEscapeLevel)
with the following preconfigured values:
XmlEscapeType.CHARACTER_ENTITY_REFERENCES_DEFAULT_TO_HEXA
XmlEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_MARKUP_SIGNIFICANT
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10(char[] text, int offset, int len, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.0 escape operation on a char[] input.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
All other char[]-based escapeXml10*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11(char[] text, int offset, int len, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.1 escape operation on a char[] input.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
All other char[]-based escapeXml11*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml10Attribute(char[] text, int offset, int len, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.0 escape operation on a char[] input meant to be an XML attribute value.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
All other char[]-based escapeXml10*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static void escapeXml11Attribute(char[] text, int offset, int len, java.io.Writer writer, XmlEscapeType type, XmlEscapeLevel level) throws java.io.IOException
Perform a (configurable) XML 1.1 escape operation on a char[] input meant to be an XML attribute value.
This method will perform an escape operation according to the specified
XmlEscapeType
and XmlEscapeLevel
argument values.
Besides, being an attribute value also \t, \n and \r will be escaped to avoid white-space normalization from removing line feeds (turning them into white spaces) during future parsing operations.
All other char[]-based escapeXml11*(...) methods call this one with preconfigured type and level values.
This method is thread-safe.
text
- the char[] to be escaped.offset
- the position in text at which the escape operation should start.len
- the number of characters in text that should be escaped.writer
- the java.io.Writer to which the escaped result will be written. Nothing will
be written at all to this writer if input is null.type
- the type of escape operation to be performed, see XmlEscapeType
.level
- the escape level to be applied, see XmlEscapeLevel
.java.io.IOException
- if an input/output exception occurspublic static String unescapeXml(String text)
Perform an XML unescape operation on a String input.
No additional configuration arguments are required. Unescape operations will always perform complete XML 1.0/1.1 unescape of CERs, decimal and hexadecimal references.
This method is thread-safe.
text
- the String to be unescaped.public static void unescapeXml(String text, java.io.Writer writer) throws java.io.IOException
Perform an XML unescape operation on a String input, writing results to a Writer.
No additional configuration arguments are required. Unescape operations will always perform complete XML 1.0/1.1 unescape of CERs, decimal and hexadecimal references.
This method is thread-safe.
text
- the String to be unescaped.writer
- the java.io.Writer to which the unescaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void unescapeXml(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Perform an XML unescape operation on a Reader input, writing results to a Writer.
No additional configuration arguments are required. Unescape operations will always perform complete XML 1.0/1.1 unescape of CERs, decimal and hexadecimal references.
This method is thread-safe.
reader
- the Reader reading the text to be unescaped.writer
- the java.io.Writer to which the unescaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occurspublic static void unescapeXml(char[] text, int offset, int len, java.io.Writer writer) throws java.io.IOException
Perform an XML unescape operation on a char[] input.
No additional configuration arguments are required. Unescape operations will always perform complete XML 1.0/1.1 unescape of CERs, decimal and hexadecimal references.
This method is thread-safe.
text
- the char[] to be unescaped.offset
- the position in text at which the unescape operation should start.len
- the number of characters in text that should be unescaped.writer
- the java.io.Writer to which the unescaped result will be written. Nothing will
be written at all to this writer if input is null.java.io.IOException
- if an input/output exception occursCopyright © 2018 The UNBESCAPE team. All rights reserved.