Package com.topologi.diffx.xml.esc
Class XMLEscapeWriterBase
java.lang.Object
com.topologi.diffx.xml.esc.XMLEscapeWriterBase
- All Implemented Interfaces:
XMLEscapeWriter
- Direct Known Subclasses:
XMLEscapeWriterASCII,XMLEscapeWriterUTF8
A base implementation for the XML writer escape classes.
- Version:
- 14 May 2005
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXMLEscapeWriterBase(Writer writer, String encoding) Creates a new XML escape for writers. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringReturns the encoding for this writer.final voidwriteAttValue(String value) Default implementation calling theXMLEscapeWriter.writeAttValue(char[], int, int).voidwriteText(char[] ch, int off, int len) Replace characters which are invalid in element values, by the corresponding entity.final voidDefault implementation calling theXMLEscapeWriter.writeAttValue(char[], int, int).Methods 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
writeAttValue, writeText
-
Field Details
-
encoding
The encoding for the implementation. -
w
The wrapped writer.
-
-
Constructor Details
-
XMLEscapeWriterBase
Creates a new XML escape for writers.- Parameters:
writer- The writer to wrap.encoding- The underlying character encoding for the writer.- Throws:
NullPointerException- If the specified writer isnull.
-
-
Method Details
-
writeAttValue
Default implementation calling theXMLEscapeWriter.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
nullif the given value isnull.- Specified by:
writeAttValuein interfaceXMLEscapeWriter- Parameters:
value- The value that needs to be attribute-escaped.- Throws:
IOException- If thrown by the underlying writer.
-
writeText
Default implementation calling theXMLEscapeWriter.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.- Specified by:
writeTextin interfaceXMLEscapeWriter- Parameters:
value- The text that needs to be text-escaped.- Throws:
IOException- If thrown by the underlying writer.
-
writeText
Replace characters which are invalid in element values, by the corresponding entity.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 '<.
- Specified by:
writeTextin 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.
-
getEncoding
Returns the encoding for this writer. Returns the encoding used by the implementing class.- Specified by:
getEncodingin interfaceXMLEscapeWriter- Returns:
- The encoding used by the implementing class.
-