net.officefloor.plugin.stream.impl
Class OutputBufferStreamImpl

java.lang.Object
  extended by net.officefloor.plugin.stream.impl.OutputBufferStreamImpl
All Implemented Interfaces:
OutputBufferStream

public class OutputBufferStreamImpl
extends Object
implements OutputBufferStream

OutputBufferStream implementation.

Author:
Daniel Sagenschneider

Constructor Summary
OutputBufferStreamImpl(BufferStream bufferStream)
          Initiate.
 
Method Summary
 void append(BufferSquirt squirt)
           Appends the BufferSquirt to the BufferStream.
 void append(ByteBuffer buffer)
           Appends the ByteBuffer to the BufferStream.
 void close()
          Closes the stream releasing resources.
 OutputStream getOutputStream()
           Obtains an OutputStream that writes content to the BufferStream.
 void write(BufferPopulator populator)
          Writes content to a ByteBuffer of the BufferStream.
 void write(byte[] bytes)
           Writes the bytes to the BufferStream.
 void write(byte[] data, int offset, int length)
           Writes the bytes to the BufferStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputBufferStreamImpl

public OutputBufferStreamImpl(BufferStream bufferStream)
Initiate.

Parameters:
bufferStream - BufferStream.
Method Detail

getOutputStream

public OutputStream getOutputStream()
Description copied from interface: OutputBufferStream

Obtains an OutputStream that writes content to the BufferStream.

This allows use of existing stream implementations.

Specified by:
getOutputStream in interface OutputBufferStream
Returns:
OutputStream.

write

public void write(byte[] bytes)
           throws IOException
Description copied from interface: OutputBufferStream

Writes the bytes to the BufferStream.

The bytes are copied into the BufferStream so that the input array is no longer required.

Specified by:
write in interface OutputBufferStream
Parameters:
bytes - Bytes to be written to the BufferStream.
Throws:
IOException - If fails to write the bytes.

write

public void write(byte[] data,
                  int offset,
                  int length)
           throws IOException
Description copied from interface: OutputBufferStream

Writes the bytes to the BufferStream.

The bytes are copied into the BufferStream so that the input array is no longer required.

Specified by:
write in interface OutputBufferStream
Parameters:
data - Bytes to be written to the BufferStream.
offset - Offset into the data to start obtaining bytes to write.
length - Number of bytes to write from the data.
Throws:
IOException - If fails to write the bytes.

write

public void write(BufferPopulator populator)
           throws IOException
Description copied from interface: OutputBufferStream
Writes content to a ByteBuffer of the BufferStream.

Specified by:
write in interface OutputBufferStream
Parameters:
populator - BufferPopulator to write data to the ByteBuffer.
Throws:
IOException - If fails to write data to ByteBuffer.

append

public void append(ByteBuffer buffer)
            throws IOException
Description copied from interface: OutputBufferStream

Appends the ByteBuffer to the BufferStream.

The ByteBuffer is used directly by the BufferStream and must not be changed until the BufferStream is no longer being used. This should only be used when the ByteBuffer never changes (contains static information).

Use OutputBufferStream.append(BufferSquirt) over this method to know when the ByteBuffer can be modified again.

Specified by:
append in interface OutputBufferStream
Parameters:
buffer - ByteBuffer ready to be read from.
Throws:
IOException - If fails to append to the BufferStream.

append

public void append(BufferSquirt squirt)
            throws IOException
Description copied from interface: OutputBufferStream

Appends the BufferSquirt to the BufferStream.

BufferSquirt.close() is invoked when the BufferStream no longer requires the BufferSquirt.

Specified by:
append in interface OutputBufferStream
Parameters:
squirt - BufferSquirt to append to the BufferStream.
Throws:
IOException - If fails to append to the BufferStream.

close

public void close()
Description copied from interface: OutputBufferStream
Closes the stream releasing resources.

Specified by:
close in interface OutputBufferStream


Copyright © 2005-2011. All Rights Reserved.