com.ls.util.io
Class BufferedOutputSource

java.lang.Object
  |
  +--com.ls.util.io.BufferedOutputSource

public class BufferedOutputSource
extends Object

The OutputSource class writes byte wise data into a buffer. If the buffer is full the data is appended to a StringBuffer. This is done due to performance reasons.

Version:
$Revision: 1.2 $
Author:
Last modified by $Author: JBogenschuetz $

Field Summary
protected  byte[] buffer
          byte array to write the bytes in.
protected  int bufferIndex
          the index of the byte array buffer
protected  int index
          the index of the output source
 
Constructor Summary
BufferedOutputSource()
          Constructor with no additional method calls.
 
Method Summary
protected  void fillStringBuffer()
          fills the internal StringBuffer with the bytes from the byte array ('internal cache' buffer to speed up the performance)
 byte[] getBuffer()
          gets the 'internal cache' (buffer) of this BufferedOutputSource object
 int getBufferIndex()
          gets the index of the 'internal cache' (bufferIndex)
 int getIndex()
          gets the index of this BufferedOutputSource object
 StringBuffer getStringBuffer()
          returns the complete content of this BufferedOutputSource object.
 void reset()
          resets this BufferedOutputSource object (empties all buffers)
 String toString()
          returns the complete content of this BufferedOutputSource object.
 void writeByte(byte byteToAdd)
          writes the given byte into this BufferedOutputSource instance
 void writeByte(char charToAdd)
          writes the given char into this BufferedOutputSource instance
 void writeSource(BufferedOutputSource outputSource)
          writes the content of the given BufferedOutputSource object into this BufferedOutputSource instance
 void writeString(String string)
          writes the content of the given String into this BufferedOutputSource instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buffer

protected byte[] buffer
byte array to write the bytes in. It is the 'internal cache' to speed up the performance. If a certain quantity is reached, the content is moved into the 'main' StringBuffer.

bufferIndex

protected int bufferIndex
the index of the byte array buffer

index

protected int index
the index of the output source
Constructor Detail

BufferedOutputSource

public BufferedOutputSource()
Constructor with no additional method calls.
Method Detail

fillStringBuffer

protected void fillStringBuffer()
fills the internal StringBuffer with the bytes from the byte array ('internal cache' buffer to speed up the performance)

writeSource

public void writeSource(BufferedOutputSource outputSource)
writes the content of the given BufferedOutputSource object into this BufferedOutputSource instance
Parameters:
outputSource - This is the BufferedOutputSource object whose content is added to this BufferedOutputSource instance

writeString

public void writeString(String string)
writes the content of the given String into this BufferedOutputSource instance
Parameters:
string - which is added to this BufferedOutputSource instance

writeByte

public void writeByte(char charToAdd)
writes the given char into this BufferedOutputSource instance
Parameters:
charToAdd - is the character which is added to this BufferedOutputSource instance

writeByte

public void writeByte(byte byteToAdd)
writes the given byte into this BufferedOutputSource instance
Parameters:
byteToAdd - is the byte which is added to this BufferedOutputSource instance

reset

public void reset()
resets this BufferedOutputSource object (empties all buffers)

getBuffer

public byte[] getBuffer()
gets the 'internal cache' (buffer) of this BufferedOutputSource object
Returns:
the content of the 'internal cache' as byte array.

getBufferIndex

public int getBufferIndex()
gets the index of the 'internal cache' (bufferIndex)
Returns:
the index of the 'internal cache' as int

getIndex

public int getIndex()
gets the index of this BufferedOutputSource object
Returns:
the index of this BufferedOutputSource object as int

toString

public String toString()
returns the complete content of this BufferedOutputSource object.
Overrides:
toString in class Object
Returns:
the complete content of this BufferedOutputSource object as String

getStringBuffer

public StringBuffer getStringBuffer()
returns the complete content of this BufferedOutputSource object.
Returns:
the complete content of this BufferedOutputSource object as StringBuffer