Novell exteNd
Director 5.2 API

com.sssw.fw.util
Class EboByteBufferOutputStream

java.lang.Object
 |
 +--java.io.OutputStream
       |
       +--com.sssw.fw.util.EboByteBufferOutputStream

public class EboByteBufferOutputStream
extends OutputStream

EboByteBufferOutputStream This class is similar to the standard ByteArrayOutputStream. It differs in that the actual underlying storage mechanism is detachable from the stream object. This allows for efficient transfer of data from an output stream to an input stream without having to copy the data into another buffer (as with the ByteArray streams).


Constructor Summary
EboByteBufferOutputStream()
          Creates a new EboByteBufferOutputStream
EboByteBufferOutputStream(EboByteBuffer buffer)
          Creates a new EboByteBufferOutputStream using the specified EboByteBuffer
EboByteBufferOutputStream(EboByteBufferInputStream in)
          Creates a new EboByteBufferOutputStream using the specified ByteBufferInputStream''s underlying storage agent.
EboByteBufferOutputStream(InputStream in)
          Creates a new EboByteBufferOutputStream using the specified InputStream as data values.
 
Method Summary
 EboByteBuffer getBuffer()
          Return the underlying EboByteBuffer Storage agent.
 void reset()
          Re-set the stream to the empty state.
 EboByteBuffer setBuffer(EboByteBuffer newBuffer)
          Set this Stream objects underlying storage to the new ByteBuffer storage agent.
 int size()
          Get the current size of the stream.
 byte[] toByteArray()
          Get a copy of the in use portion of the buffer as a byte array
 String toString()
          Converts stream data to a String
 String toString(String urlEncoding)
          Converts stream data to a String, translating bytes into characters according to the specified character encoding.
 void write(byte[] bytes)
          Write the specified byte array to the buffer.
 void write(byte[] bytes, int offset, int len)
          Write the specified number of bytes to the buffer.
 void write(int b)
          Write the specified byte to the byte buffer stream.
 void writeTo(OutputStream out)
          Write the contents of this stream to the specified stream.
 
Methods inherited from class java.io.OutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EboByteBufferOutputStream

public EboByteBufferOutputStream()
Creates a new EboByteBufferOutputStream

EboByteBufferOutputStream

public EboByteBufferOutputStream(EboByteBuffer buffer)
Creates a new EboByteBufferOutputStream using the specified EboByteBuffer
Parameters:
buffer - the underlying storage for this stream

EboByteBufferOutputStream

public EboByteBufferOutputStream(EboByteBufferInputStream in)
Creates a new EboByteBufferOutputStream using the specified ByteBufferInputStream''s underlying storage agent. If the input stream does not have a storage agent, create one.
Parameters:
in - detach the ByteBuffer from the EboByteBufferInputStream and use it as our own storage agent.

EboByteBufferOutputStream

public EboByteBufferOutputStream(InputStream in)
                          throws IOException
Creates a new EboByteBufferOutputStream using the specified InputStream as data values.
Parameters:
in - Data Input Stream
Method Detail

write

public void write(int b)
Write the specified byte to the byte buffer stream.
Overrides:
write in class OutputStream
Parameters:
b - the byte to write to buffer

write

public void write(byte[] bytes)
Write the specified byte array to the buffer.
Overrides:
write in class OutputStream
Parameters:
bytes - byte array containing bytes to be written to buffer

write

public void write(byte[] bytes,
                  int offset,
                  int len)
Write the specified number of bytes to the buffer.
Overrides:
write in class OutputStream
Parameters:
bytes - byte array containing bytes to be written to buffer
offset - starting offset in the input byte array to use
len - number of bytes to be written

writeTo

public void writeTo(OutputStream out)
             throws IOException
Write the contents of this stream to the specified stream.
Parameters:
out - OutputStream to write out content

toByteArray

public byte[] toByteArray()
Get a copy of the in use portion of the buffer as a byte array
Returns:
byte array containing a copy of the buffer

reset

public void reset()
Re-set the stream to the empty state. This is for reuse of the underlying storage facility.

size

public int size()
Get the current size of the stream.
Returns:
the size of the stream

toString

public String toString()
Converts stream data to a String
Overrides:
toString in class Object
Returns:
String value of data

toString

public String toString(String urlEncoding)
                throws UnsupportedEncodingException
Converts stream data to a String, translating bytes into characters according to the specified character encoding.
Parameters:
urlEncoding - String which specifies character encoding
Returns:
String value of data

getBuffer

public EboByteBuffer getBuffer()
Return the underlying EboByteBuffer Storage agent. This method will permenantly detach the connection between the underlying storage mechanism and this Stream object.
Returns:
The underlying EboByteBuffer Store

setBuffer

public EboByteBuffer setBuffer(EboByteBuffer newBuffer)
Set this Stream objects underlying storage to the new ByteBuffer storage agent. Sever the connection to the old storage agent if it is set.
Returns:
The old EboByteBuffer Store or null if not set

Novell exteNd
Director 5.2 API