org.mortbay.util
Class ByteArrayISO8859Writer

java.lang.Object
  extended by java.io.Writer
      extended by org.mortbay.util.ByteArrayISO8859Writer
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class ByteArrayISO8859Writer
extends Writer

Byte Array ISO 8859 writer. This class combines the features of a OutputStreamWriter for ISO8859 encoding with that of a ByteArrayOutputStream. It avoids many inefficiencies associated with these standard library classes. It has been optimized for standard ASCII characters.

Author:
Greg Wilkins (gregw)

Field Summary
private  ByteArrayOutputStream2 _bout
           
private  byte[] _buf
           
private  boolean _fixed
           
private  int _size
           
private  OutputStreamWriter _writer
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
ByteArrayISO8859Writer()
          Constructor.
ByteArrayISO8859Writer(byte[] buf)
           
ByteArrayISO8859Writer(int capacity)
          Constructor.
 
Method Summary
 int capacity()
           
 void close()
           
 void destroy()
           
 void ensureSpareCapacity(int n)
           
 void flush()
           
 byte[] getBuf()
           
 byte[] getByteArray()
           
 Object getLock()
           
 void resetWriter()
           
 void setLength(int l)
           
 int size()
           
 int spareCapacity()
           
 void write(char c)
           
 void write(char[] ca)
           
 void write(char[] ca, int offset, int length)
           
 void write(String s)
           
 void write(String s, int offset, int length)
           
private  void writeEncoded(char[] ca, int offset, int length)
           
 void writeTo(OutputStream out)
           
 
Methods inherited from class java.io.Writer
append, append, append, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_buf

private byte[] _buf

_size

private int _size

_bout

private ByteArrayOutputStream2 _bout

_writer

private OutputStreamWriter _writer

_fixed

private boolean _fixed
Constructor Detail

ByteArrayISO8859Writer

public ByteArrayISO8859Writer()
Constructor.


ByteArrayISO8859Writer

public ByteArrayISO8859Writer(int capacity)
Constructor.

Parameters:
capacity - Buffer capacity

ByteArrayISO8859Writer

public ByteArrayISO8859Writer(byte[] buf)
Method Detail

getLock

public Object getLock()

size

public int size()

capacity

public int capacity()

spareCapacity

public int spareCapacity()

setLength

public void setLength(int l)

getBuf

public byte[] getBuf()

writeTo

public void writeTo(OutputStream out)
             throws IOException
Throws:
IOException

write

public void write(char c)
           throws IOException
Throws:
IOException

write

public void write(char[] ca)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException

write

public void write(char[] ca,
                  int offset,
                  int length)
           throws IOException
Specified by:
write in class Writer
Throws:
IOException

write

public void write(String s)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException

write

public void write(String s,
                  int offset,
                  int length)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException

writeEncoded

private void writeEncoded(char[] ca,
                          int offset,
                          int length)
                   throws IOException
Throws:
IOException

flush

public void flush()
Specified by:
flush in interface Flushable
Specified by:
flush in class Writer

resetWriter

public void resetWriter()

close

public void close()
Specified by:
close in interface Closeable
Specified by:
close in class Writer

destroy

public void destroy()

ensureSpareCapacity

public void ensureSpareCapacity(int n)
                         throws IOException
Throws:
IOException

getByteArray

public byte[] getByteArray()