com.caucho.vfs.i18n
Class EncodingWriter

java.lang.Object
  extended by com.caucho.vfs.i18n.EncodingWriter
Direct Known Subclasses:
ISO8859_1Writer, JAVAWriter, JDKWriter, UTF16Writer, UTF8Writer, WindowsHackWriter

public abstract class EncodingWriter
extends java.lang.Object

Abstract class for a character-to-byte encoding writer.

Implementations need to implement create and write() at minimum. Efficient implementations will also implement the write into a buffer.

Implementations should not buffer the bytes.


Field Summary
protected static java.util.logging.Logger log
           
 
Constructor Summary
EncodingWriter()
           
 
Method Summary
 EncodingWriter create()
          Returns a new encoding writer using the saved writer.
abstract  EncodingWriter create(java.lang.String javaEncoding)
          Returns a new encoding writer for the given stream and javaEncoding.
 java.lang.String getJavaEncoding()
          Returns the Java encoding for the writer.
 void setJavaEncoding(java.lang.String encoding)
          Sets the Java encoding for the writer.
abstract  void write(ByteAppendable os, char ch)
          Writes the next character using the correct encoding.
 void write(OutputStreamWithBuffer os, char[] cbuf, int off, int len)
          Writes a character buffer using the correct encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final java.util.logging.Logger log
Constructor Detail

EncodingWriter

public EncodingWriter()
Method Detail

getJavaEncoding

public java.lang.String getJavaEncoding()
Returns the Java encoding for the writer.


setJavaEncoding

public void setJavaEncoding(java.lang.String encoding)
Sets the Java encoding for the writer.


create

public abstract EncodingWriter create(java.lang.String javaEncoding)
Returns a new encoding writer for the given stream and javaEncoding.

Parameters:
javaEncoding - the JDK name for the encoding.
Returns:
the encoding writer

create

public EncodingWriter create()
Returns a new encoding writer using the saved writer.

Returns:
the encoding writer

write

public abstract void write(ByteAppendable os,
                           char ch)
                    throws java.io.IOException
Writes the next character using the correct encoding.

Parameters:
ch - the character to write
Throws:
java.io.IOException

write

public void write(OutputStreamWithBuffer os,
                  char[] cbuf,
                  int off,
                  int len)
           throws java.io.IOException
Writes a character buffer using the correct encoding.

Parameters:
cbuf - character buffer receiving the data.
off - starting offset into the buffer.
len - number of characters to write
Throws:
java.io.IOException