Class XMLEscapeWriterBase

java.lang.Object
com.topologi.diffx.xml.esc.XMLEscapeWriterBase
All Implemented Interfaces:
XMLEscapeWriter
Direct Known Subclasses:
XMLEscapeWriterASCII, XMLEscapeWriterUTF8

abstract class XMLEscapeWriterBase extends Object implements XMLEscapeWriter
A base implementation for the XML writer escape classes.
Version:
14 May 2005
  • Field Details

    • encoding

      private final String encoding
      The encoding for the implementation.
    • w

      final Writer w
      The wrapped writer.
  • Constructor Details

    • XMLEscapeWriterBase

      XMLEscapeWriterBase(Writer writer, String encoding)
      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 is null.
  • Method Details

    • writeAttValue

      public final void writeAttValue(String value) throws IOException
      Default implementation calling the 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.

      Specified by:
      writeAttValue in interface XMLEscapeWriter
      Parameters:
      value - The value that needs to be attribute-escaped.
      Throws:
      IOException - If thrown by the underlying writer.
    • writeText

      public final void writeText(String value) throws IOException
      Default implementation calling the 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.

      Specified by:
      writeText in interface XMLEscapeWriter
      Parameters:
      value - The text that needs to be text-escaped.
      Throws:
      IOException - If thrown by the underlying writer.
    • writeText

      public void writeText(char[] ch, int off, int len) throws IOException
      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 '&amp' or '<.

      Specified by:
      writeText in interface XMLEscapeWriter
      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

      public final String getEncoding()
      Returns the encoding for this writer. Returns the encoding used by the implementing class.
      Specified by:
      getEncoding in interface XMLEscapeWriter
      Returns:
      The encoding used by the implementing class.