com.ibm.wbi.io
Class MegInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--com.ibm.wbi.io.MegInputStream

public class MegInputStream
extends java.io.InputStream

The input stream used by a meg to read streamed request data.


Field Summary
static java.lang.String COPYRIGHT
          IBM copyright information.
 
Constructor Summary
MegInputStream(MegInputStream other)
          Construct a new meg input stream given another meg input stream.
MegInputStream(RequestInfo info)
          Constructs a new input stream using a default ByteBuffer as the store.
MegInputStream(java.lang.String id, com.ibm.wbi.io.MegDataBuffer buffer)
          Constructs a new meg input stream given the specified data buffer to extract the streamed data from.
 
Method Summary
 void abort()
          Abort the request.
 int available()
          Determine amount of byte currently available.
 void close()
          Close the input stream.
 com.ibm.wbi.io.MegDataBuffer getMegDataBuffer()
          Get the data buffer used to get the streamed data from.
 RequestInfo getRequestInfo()
          Deprecated. Do not call getRequestInfo() on Meg streams, use RequestEvent.getRequestInfo() instead.
 java.lang.String getRequestString()
          Get the request string.
 boolean isAborted()
          Determine if the request has been aborted.
 boolean isClosed()
          Determines if the input stream is closed.
 int peek()
          Peek a byte from the input stream.
 int peek(byte[] buf)
          Peek bytes from the input stream filling the specified byte array.
 int peek(byte[] buf, int offset, int length)
          Peek multiple bytes from the input stream.
 int peek(ByteBuffer sb, int length)
          Peek bytes from the input stream filling the specified byte buffer.
 int read()
          Read a byte from the input stream.
 int read(byte[] buf)
          Read bytes from the input stream filling the specified byte array.
 int read(byte[] buf, int offset, int length)
          Read multiple bytes from the input stream.
 int read(ByteBuffer sb, int length)
          Read bytes from the input stream filling the specified byte buffer.
 void reset()
          Reset the reader in the byte buffer back to the starting position.
 
Methods inherited from class java.io.InputStream
mark, markSupported, skip
 
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

MegInputStream

public MegInputStream(RequestInfo info)
Constructs a new input stream using a default ByteBuffer as the store.
Parameters:
info - The request info.

MegInputStream

public MegInputStream(java.lang.String id,
                      com.ibm.wbi.io.MegDataBuffer buffer)
Constructs a new meg input stream given the specified data buffer to extract the streamed data from.
Parameters:
id - The request id string.
buffer - The data buffer to get the streamed data from.

MegInputStream

public MegInputStream(MegInputStream other)
Construct a new meg input stream given another meg input stream. The buffer is then common to the two input streams but a new reader at the same offset.
Parameters:
id - The request id string.
other - The meg input stream to copy.
Method Detail

getMegDataBuffer

public com.ibm.wbi.io.MegDataBuffer getMegDataBuffer()
Get the data buffer used to get the streamed data from.
Returns:
The meg data buffer.

getRequestInfo

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

reset

public void reset()
Reset the reader in the byte buffer back to the starting position.
Overrides:
reset in class java.io.InputStream

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.

read

public int read()
         throws java.io.IOException
Read a byte from the input stream. Blocks if no data available and end of stream not yet reached. The value of byte is as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.
Returns:
The next byte from the stream.
Throws:
java.io.IOException - If stream closed.
Overrides:
read in class java.io.InputStream

read

public int read(byte[] buf,
                int offset,
                int length)
         throws java.io.IOException
Read multiple bytes from the input stream. Blocks if no data available and end of stream not yet reached.
Parameters:
buf - The byte buffer to populate.
offset - The offset in buf to starting writing to.
length - The amount of bytes to write.
Returns:
The amount of bytes read, or -1 if no more bytes available to read.
Throws:
java.io.IOException - If stream closed.
Overrides:
read in class java.io.InputStream

read

public int read(byte[] buf)
         throws java.io.IOException
Read bytes from the input stream filling the specified byte array. Blocks if no data available and end of stream not yet reached.
Parameters:
buf - The byte buffer to populate.
Returns:
The amount of bytes read, or -1 if no more bytes available to read.
Throws:
java.io.IOException - If stream closed.
Overrides:
read in class java.io.InputStream

read

public int read(ByteBuffer sb,
                int length)
         throws java.io.IOException
Read bytes from the input stream filling the specified byte buffer. Blocks if no data available and end of stream not yet reached.
Parameters:
sb - The byte buffer to populate.
length - The amount to read.
Returns:
The amount of bytes read, or -1 if no more bytes available to read.
Throws:
java.io.IOException - If stream closed.

peek

public int peek()
         throws java.io.IOException
Peek a byte from the input stream. Blocks if no data available and end of stream not yet reached.
Returns:
The next byte from the stream.
Throws:
java.io.IOException - If stream closed.

peek

public int peek(byte[] buf,
                int offset,
                int length)
         throws java.io.IOException
Peek multiple bytes from the input stream. Blocks if no data available and end of stream not yet reached.
Parameters:
buf - The byte buffer to populate.
offset - The offset in buf to starting writing to.
length - The amount of bytes to write.
Returns:
The amount of bytes read, or -1 if no more bytes available to read.
Throws:
java.io.IOException - If stream closed.

peek

public int peek(byte[] buf)
         throws java.io.IOException
Peek bytes from the input stream filling the specified byte array. Blocks if no data available and end of stream not yet reached.
Parameters:
buf - The byte buffer to populate.
Returns:
The amount of bytes read, or -1 if no more bytes available to read.
Throws:
java.io.IOException - If stream closed.

peek

public int peek(ByteBuffer sb,
                int length)
         throws java.io.IOException
Peek bytes from the input stream filling the specified byte buffer. Blocks if no data available and end of stream not yet reached.
Parameters:
sb - The byte buffer to populate.
length - The amount to read.
Returns:
The amount of bytes read, or -1 if no more bytes available to read.
Throws:
java.io.IOException - If stream closed.

close

public void close()
Close the input stream. If the stream is already closed, this method has not effect.
Overrides:
close in class java.io.InputStream

isClosed

public boolean isClosed()
Determines if the input stream is closed.
Returns:
true if stream closed; else false.

available

public int available()
              throws java.io.IOException
Determine amount of byte currently available.
Returns:
The amount of bytes available.
Throws:
java.io.IOException - If stream closed.
Overrides:
available in class java.io.InputStream

getRequestString

public java.lang.String getRequestString()
Get the request string.
Returns:
The request string.