public final class XMLEscapeWriterASCII extends Object implements XMLEscapeWriter
Constructor and Description |
---|
XMLEscapeWriterASCII(Writer writer)
Creates a new XML escape writer using the utf-8 encoding.
|
Modifier and Type | Method and Description |
---|---|
String |
getEncoding()
Returns the encoding for this writer.
|
void |
writeAttValue(char[] ch,
int off,
int len)
Replaces '<', '&', '"' and '\'' as well an any character that is not part of
the standard unicode range.
|
void |
writeAttValue(String value)
Default implementation calling the
XMLEscapeWriter.writeAttValue(char[], int, int) . |
void |
writeText(char c)
Replace characters which are invalid in element values,
by the corresponding entity in a given
String . |
void |
writeText(char[] ch,
int off,
int len)
Replace characters which are invalid in element values, by the corresponding
entity.
|
void |
writeText(String value)
Default implementation calling the
XMLEscapeWriter.writeAttValue(char[], int, int) . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEncoding, writeAttValue, writeText, writeText
public XMLEscapeWriterASCII(Writer writer) throws NullPointerException
writer
- The writer to wrap.NullPointerException
- if the writer is null
.public void writeAttValue(char[] ch, int off, int len) throws IOException
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]Writes a well-formed attribute value.
This method must replace any character in the specified value by the corresponding numeric character reference or the predefined XML general entities, if the character is not allowed or not in the encoding range.
Attribute values must not contain '&' or '<. Quotes and apostrophes must also be escaped by """ and "'" respectively.
writeAttValue
in interface XMLEscapeWriter
ch
- The value that needs to be attribute-escaped.off
- The start (offset) of the characters.len
- The length of characters to.IOException
- If thrown by the underlying writer.public void writeText(char c) throws IOException
String
.
these characters are:
Note: this function assumes that there are no entities in the given String. If there are existing entities, then the ampersand character will be escaped by the ampersand entity. Writes the character so that the text value for the element remains well-formed.
This method should return null
if the given
value is null
.
writeText
in interface XMLEscapeWriter
c
- The character that needs to be text-escaped.IOException
- If thrown by the underlying writer.public final void writeAttValue(String value) throws IOException
XMLEscapeWriter.writeAttValue(char[], int, int)
.
Writes a well-formed attribute value.
Method provided for convenience, using the same specifications as
XMLEscapeWriter.writeAttValue(char[], int, int)
.
This method should return null
if the given
value is null
.
writeAttValue
in interface XMLEscapeWriter
value
- The value that needs to be attribute-escaped.IOException
- If thrown by the underlying writer.public final void writeText(String value) throws IOException
XMLEscapeWriter.writeAttValue(char[], int, int)
.
Writes the text string so that the text value for the element remains well-formed.
Method provided for convenience, using the same specifications as
XMLEscapeWriter.writeText(char[], int, int)
.
This method should do nothing if the given value is null
.
writeText
in interface XMLEscapeWriter
value
- The text that needs to be text-escaped.IOException
- If thrown by the underlying writer.public void writeText(char[] ch, int off, int len) throws IOException
This method calls XMLEscapeWriter.writeText(char)
for each character.
Writes a well-formed text value for the element.
This method must replace any character in the specified value by the corresponding numeric character reference or the predefined XML general entities, if the character is not allowed or not in the encoding range.
The text of an element must not contain '&' or '<.
writeText
in interface XMLEscapeWriter
ch
- The value that needs to be attribute-escaped.off
- The start (offset) of the characters.len
- The length of characters to.IOException
- If thrown by the underlying writer.public final String getEncoding()
getEncoding
in interface XMLEscapeWriter
Copyright © 2007-2019. All Rights Reserved.