Class XMLEscapeWriterUTF8
- All Implemented Interfaces:
XMLEscapeWriter
- Version:
- 14 May 2005
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringThe encoding used for this instance.Fields inherited from class com.topologi.diffx.xml.esc.XMLEscapeWriterBase
w -
Constructor Summary
ConstructorsConstructorDescriptionXMLEscapeWriterUTF8(Writer writer) Creates a new XML escape writer using the utf-8 encoding. -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidDoes nothing.voidwriteAttValue(char[] ch, int off, int len) Replaces '<', '&', '"' and '\'' as well an any character that is not part of the standard unicode range.voidwriteText(char c) Replace characters which are invalid in element values, by the corresponding entity in a givenString.Methods inherited from class com.topologi.diffx.xml.esc.XMLEscapeWriterBase
getEncoding, writeAttValue, writeText, writeTextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.topologi.diffx.xml.esc.XMLEscapeWriter
getEncoding, writeAttValue, writeText, writeText
-
Field Details
-
ENCODING
The encoding used for this instance.- See Also:
-
-
Constructor Details
-
XMLEscapeWriterUTF8
Creates a new XML escape writer using the utf-8 encoding.- Parameters:
writer- The writer to wrap.- Throws:
NullPointerException- if the writer isnull.
-
-
Method Details
-
writeAttValue
Replaces '<', '&', '"' and '\'' as well an any character that is not part of the standard unicode range.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.
- Specified by:
writeAttValuein interfaceXMLEscapeWriter- Parameters:
ch- The value that needs to be attribute-escaped.off- The start (offset) of the characters.len- The length of characters to.- Throws:
IOException- If thrown by the underlying writer.
-
writeText
Replace characters which are invalid in element values, by the corresponding entity in a givenString.these characters are:
- '&' by the ampersand entity "&"
- '<' by the entity "<"
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
nullif the given value isnull.- Specified by:
writeTextin interfaceXMLEscapeWriter- Parameters:
c- The character that needs to be text-escaped.- Throws:
IOException- If thrown by the underlying writer.
-
doNothing
private static void doNothing()Does nothing.This method exists so that we can explicitly say that we should do nothing in certain conditions.
-