com.ibm.wbi.io
Class MegOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--com.ibm.wbi.io.MegOutputStream

public class MegOutputStream
extends java.io.OutputStream

The output stream used by a meg to write streamed request data.


Field Summary
static java.lang.String COPYRIGHT
          IBM copyright information.
 
Constructor Summary
MegOutputStream()
          Constructs a new meg ouput stream with no parameters.
MegOutputStream(com.ibm.wbi.io.MegDispatcher dispatcher, Meg meg, com.ibm.wbi.io.AbortRelay abortHandler, ByteStore store)
          Constructs a new meg output stream with the meg dispatcher and the meg.
 
Method Summary
 void abort()
          Abort the request.
 void close()
          Close the meg output stream.
 void flush()
          Flush the output stream.
 com.ibm.wbi.io.MegDataBuffer getMegDataBuffer()
          Get the meg data buffer where the data is stored.
 RequestInfo getRequestInfo()
          Deprecated. Do not call getRequestInfo() on Meg streams, use RequestEvent.getRequestInfo() instead.
 boolean isAborted()
          Determine if the request has been aborted.
 boolean isClosed()
          Determine if the meg output stream is closed.
 void setMeg(Meg meg)
          Set the meg to give to the dispatcher when the notifying it of a write.
 void setRequestInfo(RequestInfo requestInfo)
          Set the request info class in the meg data buffer.
 void write(byte[] buf)
          Write a byte array to the stream.
 void write(byte[] buf, int offset, int length)
          Write a portion of the passed byte buffer array.
 void write(ByteBuffer byteBuf)
          Write the bytes from the bytebuffer to the stream.
 void write(int iByte)
          Write a byte to the stream.
 void write(MegInputStream in)
          Write the data from the input stream.
 void write(java.lang.String buf)
          Write a string to the stream.
 void write(java.lang.String buf, int offset, int length)
          Write the a portion of a string to the stream.
 void write(java.lang.String buf, int offset, int length, java.lang.String enc)
          Write the a portion of a string to the stream.
 void write(java.lang.String buf, java.lang.String enc)
          Write a string to the stream using the specified encoding.
 void writeLine(byte[] buf)
          Write the byte array to the stream followed by the end of line sequence.
 void writeLine(byte[] buf, int offset, int length)
          Write a portion of the passed byte buffer array followed by the end of line sequence.
 void writeLine(ByteBuffer sb)
          Write the bytes from the bytebuffer to the stream followed by the end of line sequence.
 void writeLine(java.lang.String buf)
          Write a string to the stream followed by the end of line sequence.
 void writeLine(java.lang.String buf, int offset, int length)
          Write the a portion of a string to the stream followed by the end of line sequence.
 void writeLine(java.lang.String buf, int offset, int length, java.lang.String enc)
          Write the a portion of a string to the stream followed by the end of line sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
IBM copyright information.
Constructor Detail

MegOutputStream

public MegOutputStream()
Constructs a new meg ouput stream with no parameters. Uses a default ByteBuffer as the store.

MegOutputStream

public MegOutputStream(com.ibm.wbi.io.MegDispatcher dispatcher,
                       Meg meg,
                       com.ibm.wbi.io.AbortRelay abortHandler,
                       ByteStore store)
Constructs a new meg output stream with the meg dispatcher and the meg.
Parameters:
dispatcher - The dispatcher to notify when the first byte of data is written to the output stream through any of the write() calls.
meg - The meg to give to the dispatcher when the notifying it of a write.
abortHandler - The request abort handler.
store - Internal byte store.
Method Detail

isAborted

public boolean isAborted()
Determine if the request has been aborted.
Returns:
true if request aborted; else false.

abort

public void abort()
Abort the request.

setMeg

public void setMeg(Meg meg)
Set the meg to give to the dispatcher when the notifying it of a write.
Parameters:
meg - The meg writing to this stream.

getMegDataBuffer

public com.ibm.wbi.io.MegDataBuffer getMegDataBuffer()
Get the meg data buffer where the data is stored.
Returns:
The meg data buffer.

getRequestInfo

public RequestInfo getRequestInfo()
Deprecated. Do not call getRequestInfo() on Meg streams, use RequestEvent.getRequestInfo() instead.
Get request info class in the meg data buffer.
Returns:
The request info class.
See Also:
com.ibm.wbi.request.RequestEvent

setRequestInfo

public void setRequestInfo(RequestInfo requestInfo)
Set the request info class in the meg data buffer.
Parameters:
requestInfo - The request info object.

write

public void write(byte[] buf,
                  int offset,
                  int length)
           throws java.io.IOException
Write a portion of the passed byte buffer array.
Parameters:
buf - The byte buffer array.
offset - Offset in the array to start writing from.
length - The amount from offset to write.
Throws:
java.io.IOException - If unable to write to stream.
Overrides:
write in class java.io.OutputStream

write

public void write(int iByte)
           throws java.io.IOException
Write a byte to the stream.
Parameters:
iByte - The byte to write.
Throws:
java.io.IOException - If unable to write to stream.
Overrides:
write in class java.io.OutputStream

write

public void write(byte[] buf)
           throws java.io.IOException
Write a byte array to the stream.
Parameters:
buf - The byte array to write.
Throws:
java.io.IOException - If unable to write to stream.
Overrides:
write in class java.io.OutputStream

write

public void write(java.lang.String buf)
           throws java.io.IOException
Write a string to the stream.
Parameters:
buf - The string to write using (8859_1 encoding).
Throws:
java.io.IOException - If unable to write to stream.

write

public void write(java.lang.String buf,
                  java.lang.String enc)
           throws java.io.IOException,
                  java.io.UnsupportedEncodingException
Write a string to the stream using the specified encoding.
Parameters:
buf - The string to write.
enc - The encoding to use.
Throws:
java.io.IOException - If unable to write to stream.
java.io.UnsupportedEncodingException - If the encoding is not supported.

write

public void write(ByteBuffer byteBuf)
           throws java.io.IOException
Write the bytes from the bytebuffer to the stream.
Parameters:
byteBuf - The bytebuffer.
Throws:
java.io.IOException - If unable to write to stream.

write

public void write(java.lang.String buf,
                  int offset,
                  int length)
           throws java.io.IOException
Write the a portion of a string to the stream.
Parameters:
buf - The string.
offset - Offset in the string to start writing.
length - The length from offset to write.
Throws:
java.io.IOException - If unable to write to stream.

write

public void write(java.lang.String buf,
                  int offset,
                  int length,
                  java.lang.String enc)
           throws java.io.IOException,
                  java.io.UnsupportedEncodingException
Write the a portion of a string to the stream.
Parameters:
buf - The string.
offset - Offset in the string to start writing.
length - The length from offset to write.
enc - The encoding of the string.
Throws:
java.io.IOException - If unable to write to stream.
java.io.UnsupportedEncodingException - If the encoding is not supported.

write

public void write(MegInputStream in)
           throws java.io.IOException
Write the data from the input stream. This effectively skips a data buffer.
Parameters:
in - The input stream.
Throws:
java.io.IOException - An error occurs.

writeLine

public void writeLine(byte[] buf)
               throws java.io.IOException
Write the byte array to the stream followed by the end of line sequence.
Parameters:
buf - The byte array.
Throws:
java.io.IOException - If unable to write to stream.

writeLine

public void writeLine(byte[] buf,
                      int offset,
                      int length)
               throws java.io.IOException
Write a portion of the passed byte buffer array followed by the end of line sequence.
Parameters:
buf - The byte buffer array.
offset - Offset in the array to start writing from.
length - The amount from offset to write.
Throws:
java.io.IOException - If unable to write to stream.

writeLine

public void writeLine(java.lang.String buf)
               throws java.io.IOException
Write a string to the stream followed by the end of line sequence.
Parameters:
buf - The string to write using (8859_1 encoding).
Throws:
java.io.IOException - If unable to write to stream.

writeLine

public void writeLine(ByteBuffer sb)
               throws java.io.IOException
Write the bytes from the bytebuffer to the stream followed by the end of line sequence.
Parameters:
byteBuf - The bytebuffer.
Throws:
java.io.IOException - If unable to write to stream.

writeLine

public void writeLine(java.lang.String buf,
                      int offset,
                      int length)
               throws java.io.IOException
Write the a portion of a string to the stream followed by the end of line sequence.
Parameters:
buf - The string.
offset - Offset in the string to start writing.
length - The length from offset to write.
Throws:
java.io.IOException - If unable to write to stream.

writeLine

public void writeLine(java.lang.String buf,
                      int offset,
                      int length,
                      java.lang.String enc)
               throws java.io.IOException,
                      java.io.UnsupportedEncodingException
Write the a portion of a string to the stream followed by the end of line sequence.
Parameters:
buf - The string.
offset - Offset in the string to start writing.
length - The length from offset to write.
enc - The encoding of the string.
Throws:
java.io.IOException - If unable to write to stream.
java.io.UnsupportedEncodingException - If the encoding is not supported.

close

public void close()
           throws java.io.IOException
Close the meg output stream.
Throws:
java.io.IOException - If error occurred closing stream.
Overrides:
close in class java.io.OutputStream

isClosed

public boolean isClosed()
Determine if the meg output stream is closed.
Returns:
true if closed.

flush

public void flush()
Flush the output stream.
Overrides:
flush in class java.io.OutputStream