|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface XMLEscapeWriter
An interface to escape XML character data onto a writer.
This interface mimics the XMLEscape
interface but is designed to
be more efficient for writers by wrapping a Writer
and writing
directly onto it.
This class is mostly concerned about producing well formed XML and not does attempt to produce valid data.
Method Summary | |
---|---|
String |
getEncoding()
Returns the encoding used by the implementing class. |
void |
writeAttValue(char[] ch,
int off,
int len)
Writes a well-formed attribute value. |
void |
writeAttValue(String value)
Writes a well-formed attribute value. |
void |
writeText(char c)
Writes the character so that the text value for the element remains well-formed. |
void |
writeText(char[] ch,
int off,
int len)
Writes a well-formed XML literal text value. |
void |
writeText(String text)
Writes the text string so that the text value for the element remains well-formed. |
Method Detail |
---|
void writeAttValue(char[] ch, int off, int len) throws IOException
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 any ampersand (#x26) or less than (#x3C) characters. This method will replace them by the corresponding named entity.
Quotes and apostrophes must also be escaped depending on what was used in the attribute markup. Since this method is not aware of which type of quotes was used, both are escaped. Double quotes (#x22) are escaped using a named character entity. In case the end result is HTML 4, single quotes (#x27) are escaped using a numeric character entity.
Characters in ranges (#x00-#x1F) and (#x80-#x9F) are silently ignored except for line feed (#x0A), carriage return (#x0D) and tab (#x09).
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.void writeAttValue(String value) throws IOException
Method provided for convenience, using the same specifications as
writeAttValue(char[], int, int)
.
value
- The value that needs to be attribute-escaped.
IOException
- If thrown by the underlying writer.void writeText(char[] ch, int off, int len) throws IOException
This method must replace any character in the specified text by the corresponding numeric character reference or the predefined XML general entities, if the character is not allowed or not in the encoding range.
Literal text values must not contain any 'ampersand' (#x26) or 'less than' (#x3C) characters. This method will replace them by the corresponding named entity.
Out of precaution this method may also encode the 'greater than' (#xCE) character, in case it follows "]]".
Characters in ranges (#x00-#x1F) and (#x80-#x9F) are silently ignored except for line feed (#x0A), carriage return (#x0D) and tab (#x09).
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.void writeText(String text) throws IOException
Method provided for convenience, using the same specifications as
writeText(char[], int, int)
.
This method should do nothing if the given value is null
.
text
- The text that needs to be text-escaped.
IOException
- If thrown by the underlying writer.void writeText(char c) throws IOException
Some implementations may unable to deal with java characters outside the Basic Multilingual Plane (BMP). As a result, java characters which correspond to UTF-16 surrogate pairs (#xD800 - 0xDFFF) in may be not be handled appropriately.
Unicode Transformation Format (UTF) implementation should copy the java character verbatim.
c
- The character that needs to be text-escaped.
IOException
- If thrown by the underlying writer.String getEncoding()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |