Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * This file is part of the DiffX library.
  *
  * For licensing information please see the file license.txt included in the release.
  * A copy of this licence can also be found at
  *   http://www.opensource.org/licenses/artistic-license-2.0.php
  */
 package com.topologi.diffx.xml.esc;
 
A base implementation for the XML writer escape classes.

Author(s):
Christophe Lauret
Version:
14 May 2005
abstract class XMLEscapeWriterBase implements XMLEscapeWriter {

  
The encoding for the implementation.
  private final String encoding;

  
The wrapped writer.
  final Writer w;

  
Creates a new XML escape for writers.

Parameters:
writer The writer to wrap.
encoding The underlying character encoding for the writer.
Throws:
java.lang.NullPointerException If the specified writer is null.
  XMLEscapeWriterBase(Writer writerString encoding) {
    if (writer == null)
      throw new NullPointerException("Cannot construct XML escape for null writer.");
    this. = writer;
    this. = encoding;
  }

  
Default implementation calling the XMLEscapeWriter.writeAttValue(char[],int,int).
  public final void writeAttValue(String valuethrows IOException {
    if (value == null || "".equals(value)) return;
    writeAttValue(value.toCharArray(), 0, value.length());
  }

  
Default implementation calling the XMLEscapeWriter.writeAttValue(char[],int,int).
  public final void writeText(String valuethrows IOException {
    if (value == null || "".equals(value)) return;
    writeText(value.toCharArray(), 0, value.length());
  }

  
Replace characters which are invalid in element values, by the corresponding entity.

This method calls XMLEscapeWriter.writeText(char) for each character.

  public void writeText(char[] chint offint lenthrows IOException {
    for (int i = offi < off+leni++) {
      writeText(ch[i]);
    }
  }

  
Returns the encoding for this writer.
  public final String getEncoding() {
    return this.;
  }
New to GrepCode? Check out our FAQ X