org.ajax4jsf.io
Class FastBufferWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.ajax4jsf.io.FastBufferWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class FastBufferWriter
extends java.io.Writer

Class for writing to chain of char arrays extending Writer.

Author:
glory

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
FastBufferWriter()
          Creates instance of default initial capacity.
FastBufferWriter(CharBuffer firstBuffer)
          Creates instance for an already existing chain of char arrays.
FastBufferWriter(int initialSize)
          Creates instance with required initial capacity.
 
Method Summary
 void close()
           
 FastBufferOutputStream convertToOutputStream()
          Returns instance of FastBufferOutputStream containing all data written to this writer.
 FastBufferOutputStream convertToOutputStream(java.lang.String encoding)
          Returns instance of FastBufferOutputStream containing all data written to this writer.
 void flush()
           
 CharBuffer getFirstBuffer()
          Returns the first link of the chain of char arrays.
 int getLength()
          Returns the total number of written chars.
 void printTo(javax.servlet.ServletOutputStream outputStream)
           
 void reset()
          Resets writer to empty state
 char[] toCharArray()
          Writes all data written up to the moment to string buffer.
 void write(char[] cbuf)
           
 void write(char[] cbuf, int off, int len)
           
 void write(int c)
           
 void writeTo(java.io.Writer writer)
          Writes all data written up to the moment to out.
 
Methods inherited from class java.io.Writer
append, append, append, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastBufferWriter

public FastBufferWriter()
Creates instance of default initial capacity.


FastBufferWriter

public FastBufferWriter(int initialSize)
Creates instance with required initial capacity.

Parameters:
initialSize -

FastBufferWriter

public FastBufferWriter(CharBuffer firstBuffer)
Creates instance for an already existing chain of char arrays.

Parameters:
firstBuffer -
Method Detail

write

public void write(int c)
           throws java.io.IOException
Overrides:
write in class java.io.Writer
Throws:
java.io.IOException
See Also:
java.io.Writer.write(int c)

write

public void write(char[] cbuf)
           throws java.io.IOException
Overrides:
write in class java.io.Writer
Throws:
java.io.IOException
See Also:
java.io.Writer.write(char cbuf[])

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws java.io.IOException
Specified by:
write in class java.io.Writer
Throws:
java.io.IOException
See Also:
java.io.Writer.write(char cbuf[], int off, int len)

getLength

public int getLength()
Returns the total number of written chars.

Returns:

getFirstBuffer

public CharBuffer getFirstBuffer()
Returns the first link of the chain of char arrays.

Returns:

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Writer
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer
Throws:
java.io.IOException

toCharArray

public char[] toCharArray()
Writes all data written up to the moment to string buffer.

Parameters:
out -
Throws:
java.io.IOException

writeTo

public void writeTo(java.io.Writer writer)
             throws java.io.IOException
Writes all data written up to the moment to out.

Parameters:
out -
Throws:
java.io.IOException

printTo

public void printTo(javax.servlet.ServletOutputStream outputStream)
             throws java.io.IOException
Throws:
java.io.IOException

convertToOutputStream

public FastBufferOutputStream convertToOutputStream(java.lang.String encoding)
                                             throws java.io.UnsupportedEncodingException
Returns instance of FastBufferOutputStream containing all data written to this writer.

Parameters:
encoding -
Returns:
Throws:
java.io.UnsupportedEncodingException

convertToOutputStream

public FastBufferOutputStream convertToOutputStream()
Returns instance of FastBufferOutputStream containing all data written to this writer.

Returns:

reset

public void reset()
Resets writer to empty state

Since:
3.3.0


Copyright © 2010. All Rights Reserved.