Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mortbay.util
Class ByteArrayISO8859Writer  view ByteArrayISO8859Writer download ByteArrayISO8859Writer.java

java.lang.Object
  extended byjava.io.Writer
      extended byorg.mortbay.util.ByteArrayISO8859Writer

public class ByteArrayISO8859Writer
extends java.io.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.

Version:
$Revision: 1.12 $

Field Summary
private  ByteArrayOutputStream2 _bout
           
private  byte[] _buf
           
private  boolean _fixed
           
private  int _size
           
private  java.io.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()
          This method closes the stream.
 void destroy()
           
 void ensureSpareCapacity(int n)
           
 void finalize()
          Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed.
 void flush()
          This method forces any data that may have been buffered to be written to the underlying output device.
 byte[] getBuf()
           
 byte[] getByteArray()
           
 java.lang.Object getLock()
           
 void resetWriter()
           
 void setLength(int l)
           
 int size()
           
 int spareCapacity()
           
 void write(char c)
           
 void write(char[] ca)
          This method all the writes char from the passed array to the output stream.
 void write(char[] ca, int offset, int length)
          This method writes len char from the specified array buf starting at index offset into the array.
 void write(java.lang.String s)
          This method writes all the characters in a String to the output.
 void write(java.lang.String s, int offset, int length)
          This method writes len chars from the String starting at position offset.
private  void writeEncoded(char[] ca, int offset, int length)
           
 void writeTo(java.io.OutputStream out)
           
 
Methods inherited from class java.io.Writer
write
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_buf

private byte[] _buf

_size

private int _size

_bout

private ByteArrayOutputStream2 _bout

_writer

private java.io.OutputStreamWriter _writer

_fixed

private boolean _fixed
Constructor Detail

ByteArrayISO8859Writer

public ByteArrayISO8859Writer()
Constructor.


ByteArrayISO8859Writer

public ByteArrayISO8859Writer(int capacity)
Constructor.


ByteArrayISO8859Writer

public ByteArrayISO8859Writer(byte[] buf)
Method Detail

getLock

public java.lang.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(java.io.OutputStream out)
             throws java.io.IOException

write

public void write(char c)
           throws java.io.IOException

write

public void write(char[] ca)
           throws java.io.IOException
Description copied from class: java.io.Writer
This method all the writes char from the passed array to the output stream. This method is equivalent to write(buf, 0, buf.length) which is exactly how it is implemented in this class.


write

public void write(char[] ca,
                  int offset,
                  int length)
           throws java.io.IOException
Description copied from class: java.io.Writer
This method writes len char from the specified array buf starting at index offset into the array.

Subclasses must provide an implementation of this abstract method.


write

public void write(java.lang.String s)
           throws java.io.IOException
Description copied from class: java.io.Writer
This method writes all the characters in a String to the output.


write

public void write(java.lang.String s,
                  int offset,
                  int length)
           throws java.io.IOException
Description copied from class: java.io.Writer
This method writes len chars from the String starting at position offset.


writeEncoded

private void writeEncoded(char[] ca,
                          int offset,
                          int length)
                   throws java.io.IOException

flush

public void flush()
Description copied from class: java.io.Writer
This method forces any data that may have been buffered to be written to the underlying output device. Please note that the host environment might perform its own buffering unbeknowst to Java. In that case, a write made (for example, to a disk drive) might be cached in OS buffers instead of actually being written to disk.


resetWriter

public void resetWriter()

close

public void close()
Description copied from class: java.io.Writer
This method closes the stream. Any internal or native resources associated with this stream are freed. Any subsequent attempt to access the stream might throw an exception.

This method in this class does nothing.


destroy

public void destroy()

ensureSpareCapacity

public void ensureSpareCapacity(int n)
                         throws java.io.IOException

finalize

public void finalize()
Description copied from class: java.lang.Object
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed. You would think that this means it eventually is called on every Object, but this is not necessarily the case. If execution terminates abnormally, garbage collection does not always happen. Thus you cannot rely on this method to always work. For finer control over garbage collection, use references from the java.lang.ref package.

Virtual Machines are free to not call this method if they can determine that it does nothing important; for example, if your class extends Object and overrides finalize to do simply super.finalize().

finalize() will be called by a java.lang.Thread that has no locks on any Objects, and may be called concurrently. There are no guarantees on the order in which multiple objects are finalized. This means that finalize() is usually unsuited for performing actions that must be thread-safe, and that your implementation must be use defensive programming if it is to always work.

If an Exception is thrown from finalize() during garbage collection, it will be patently ignored and the Object will still be destroyed.

It is allowed, although not typical, for user code to call finalize() directly. User invocation does not affect whether automatic invocation will occur. It is also permitted, although not recommended, for a finalize() method to "revive" an object by making it reachable from normal code again.

Unlike constructors, finalize() does not get called for an object's superclass unless the implementation specifically calls super.finalize().

The default implementation does nothing.


getByteArray

public byte[] getByteArray()