org.openadaptor.util
Interface OutputStreamComponent

All Known Subinterfaces:
SecurityOutputStreamComponent
All Known Implementing Classes:
AbstractSecurityOutputStreamComponent, Base64WriterOutputStream, DebugOutputStreamComponent, DigestOutputStreamComponent, EncryptionOutputStreamComponent, NullOutputStreamComponent, PipelineOutputStream, SignOutputStreamComponent, WriterOutputStream

public interface OutputStreamComponent

This interface defines a pipe component of an OutputStream. An OutputStreamComponent has a series of bytes written to it, which it transforms or operates on in some fashion, and writes the resultant bytes onto its OutputStream.

These bytes are assumed to part of a discrete block of data, so startDataBlock() and finishDataBlock() methods exist to allow header and footer information to be written to the OutputStream. Any bytes written to an OutputStreamComponent before it receives a startDataBlock() call should be passed through to its downstream component unchanged, as it will be header information for an upstream component. The startDataBlock() call should be passed to its downstream component after it has written any of its own header information to it. When a finishDataBlock() call is received, the component must finish its transformations and output any remaining bytes and/or padding in its buffers, then pass the finishDataBlock() call downstream. It must also reset itself to its initial state, i.e expecting a startDataBlock() call.

An abstract implementation of the interface is available:

See Also:
PipelineOutputStream

Method Summary
 java.io.OutputStream asOutputStream()
          Returns the receiver as an OutputStream.
 void close()
          Closes the output stream.
 void finishDataBlock()
          Finish off the current data block being output.
 void flush()
          Flushes the output stream and forces any buffered output bytes to be written out.
 OutputStreamComponent getOutputStream()
          Returns the output component.
 boolean isInDataBlock()
          Returns true if the Component is currently writing a data block
 void setOutputStream(OutputStreamComponent output)
          Sets the output component.
 void startDataBlock()
          Start processing a new data block.
 void write(byte[] bb)
          Writes bb.length bytes from the specified byte array to the output stream.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(int b)
          Writes the a byte to the output stream.
 

Method Detail

write

void write(int b)
           throws java.io.IOException
Writes the a byte to the output stream.

Parameters:
b - the byte.
Throws:
java.io.IOException - if an I/O error occurs.

write

void write(byte[] bb)
           throws java.io.IOException
Writes bb.length bytes from the specified byte array to the output stream.

Parameters:
bb - the bytes.
Throws:
java.io.IOException - if an I/O error occurs.

write

void write(byte[] b,
           int off,
           int len)
           throws java.io.IOException
Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters:
bb - the bytes.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if an I/O error occurs.

flush

void flush()
           throws java.io.IOException
Flushes the output stream and forces any buffered output bytes to be written out.

Throws:
java.io.IOException - if an I/O error occurs.

close

void close()
           throws java.io.IOException
Closes the output stream.

Throws:
java.io.IOException - if an I/O error occurs.

startDataBlock

void startDataBlock()
                    throws java.io.IOException
Start processing a new data block. Some components will need to write header information onto their output stream before writing any data; for example an Encryption Component may write out the name of the Encryption algorithm in a standard form e.g.
@Encrypt algo:DES

Throws:
java.io.IOException - if an I/O error occurs.

finishDataBlock

void finishDataBlock()
                     throws java.io.IOException
Finish off the current data block being output. Some components will need to write out 'footer' information; for instance a message signer will need to write the digital signature after the signed message; e.g.
@Signature: aabbccxxyyzz

Throws:
java.io.IOException

isInDataBlock

boolean isInDataBlock()
Returns true if the Component is currently writing a data block


asOutputStream

java.io.OutputStream asOutputStream()
Returns the receiver as an OutputStream. If the receiver is not a subclass of OutputStream, it must return an OutputStream subclass instance which writes to itself


setOutputStream

void setOutputStream(OutputStreamComponent output)
Sets the output component.

Parameters:
output - The output component.

getOutputStream

OutputStreamComponent getOutputStream()
Returns the output component.