org.apache.ws.commons.tcpmon.core.filter
Class ReadOnlyStream

java.lang.Object
  extended by org.apache.ws.commons.tcpmon.core.filter.ReadOnlyStream
All Implemented Interfaces:
Stream

public class ReadOnlyStream
extends Object
implements Stream


Constructor Summary
ReadOnlyStream(Stream parent)
           
 
Method Summary
 int available()
          Get the number of bytes currently available in the stream.
 byte discard()
          Discard the byte at the current position in the stream.
 void discard(int len)
          Discard a given number of bytes from the stream, starting at the current position.
 void error(String description)
           
 int get()
          Get the byte at the current position in the stream.
 int get(int lookahead)
          Get the byte at a given distance from the current position in the stream.
 void insert(byte b)
          Insert a byte at the current position in the stream.
 void insert(byte[] buffer, int offset, int length)
          Insert a byte sequence at the current position in the stream.
 void insert(ByteBuffer buffer)
          Insert the content of a byte buffer at the current position in the stream.
 boolean isEndOfStream()
          Check if the end of the stream has been reached.
 void popFilter()
           
 void pushFilter(StreamFilter filter)
           
 int read(byte[] buffer, int offset, int length)
          Read data from the stream into a byte array, starting from the current position in the stream.
 int read(ByteBuffer buffer)
          Read data from the stream into a byte buffer, starting from the current position in the stream.
 void readAll(OutputStream out)
          Read all currently available data from the stream and copy it to an OutputStream object.
 byte skip()
          Skip the byte at the current position in the stream.
 void skip(int len)
          Skip a given number of bytes in the stream, starting from the current position.
 void skipAll()
          Skip all the bytes currently available in the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyStream

public ReadOnlyStream(Stream parent)
Method Detail

available

public int available()
Description copied from interface: Stream
Get the number of bytes currently available in the stream.

Specified by:
available in interface Stream
Returns:
the number of available bytes

discard

public byte discard()
Description copied from interface: Stream
Discard the byte at the current position in the stream. This method increments the current position without copying the byte to the next filter in the pipeline.

Specified by:
discard in interface Stream
Returns:
the byte at the current position in the stream

discard

public void discard(int len)
Description copied from interface: Stream
Discard a given number of bytes from the stream, starting at the current position.

Specified by:
discard in interface Stream
Parameters:
len - the number of bytes to discard

get

public int get()
Description copied from interface: Stream
Get the byte at the current position in the stream. Calling this method will not modify the current position in the stream.

Specified by:
get in interface Stream
Returns:
the byte at the current position in the stream or -1 if the end of the stream has been reached

get

public int get(int lookahead)
Description copied from interface: Stream
Get the byte at a given distance from the current position in the stream.

Specified by:
get in interface Stream
Parameters:
lookahead - the distance from the current position
Returns:
the byte at the given position, or -1 if the position is past the end of the stream

insert

public void insert(byte b)
Description copied from interface: Stream
Insert a byte at the current position in the stream. The logical position after invocation of this method will be just after the inserted byte, i.e. the inserted byte can't be read, discarded or skipped.

Specified by:
insert in interface Stream
Parameters:
b - the byte to insert

insert

public void insert(byte[] buffer,
                   int offset,
                   int length)
Description copied from interface: Stream
Insert a byte sequence at the current position in the stream. The logical position after invocation of this method will be just after the last inserted byte.

Specified by:
insert in interface Stream
Parameters:
buffer - a byte array containing the sequence to be inserted in the stream
offset - the start offset in the byte array
length - the number of bytes to insert

insert

public void insert(ByteBuffer buffer)
Description copied from interface: Stream
Insert the content of a byte buffer at the current position in the stream. The logical position after invocation of this method will be just after the last inserted byte.

Specified by:
insert in interface Stream
Parameters:
buffer - the byte buffer containing the sequence to be inserted in the stream

isEndOfStream

public boolean isEndOfStream()
Description copied from interface: Stream
Check if the end of the stream has been reached.

Specified by:
isEndOfStream in interface Stream
Returns:
true if the end of the stream has been reached

read

public int read(byte[] buffer,
                int offset,
                int length)
Description copied from interface: Stream
Read data from the stream into a byte array, starting from the current position in the stream. Calling this method will not modify the current position in the stream.

Specified by:
read in interface Stream
Parameters:
buffer - the buffer into which the data is read
offset - the start offset in array buffer at which the data is written
length - the maximum number of bytes to read
Returns:
the total number of bytes read into the buffer

read

public int read(ByteBuffer buffer)
Description copied from interface: Stream
Read data from the stream into a byte buffer, starting from the current position in the stream. Calling this method will not modify the current position in the stream. The number of bytes read is only limited by the number of available bytes in the stream and the remaining bytes in the buffer (as returned by Buffer.remaining().

Specified by:
read in interface Stream
Parameters:
buffer - the buffer into which the data is read
Returns:
the total number of bytes read into the buffer

readAll

public void readAll(OutputStream out)
             throws IOException
Description copied from interface: Stream
Read all currently available data from the stream and copy it to an OutputStream object. Calling this method will not modify the current position in the stream.

Specified by:
readAll in interface Stream
Parameters:
out - the output stream to write the data to
Throws:
IOException - if an I/O error occurred when writing to the output stream

skip

public byte skip()
Description copied from interface: Stream
Skip the byte at the current position in the stream. This will increment the current position and copy the byte to the next filter.

Specified by:
skip in interface Stream
Returns:
the byte at the current position in the stream

skip

public void skip(int len)
Description copied from interface: Stream
Skip a given number of bytes in the stream, starting from the current position.

Specified by:
skip in interface Stream
Parameters:
len - the number of bytes to skip

skipAll

public void skipAll()
Description copied from interface: Stream
Skip all the bytes currently available in the stream. The instruction s.skipAll() is equivalent to s.skip(s.available()).

Specified by:
skipAll in interface Stream

pushFilter

public void pushFilter(StreamFilter filter)
Specified by:
pushFilter in interface Stream

popFilter

public void popFilter()
Specified by:
popFilter in interface Stream

error

public void error(String description)
Specified by:
error in interface Stream


Copyright © The Apache Software Foundation. All Rights Reserved.