public class TransportCursor extends java.lang.Object implements Cursor
TransportCursor
object represents a cursor that
can read and buffer data from an underlying transport. If the
number of bytes read from the cursor is more than required for
the HTTP request then those bytes can be pushed back in to the
cursor using the reset
method. This will only allow
the last read to be reset within the cursor safely.Transport
Constructor and Description |
---|
TransportCursor(Transport transport)
Constructor for the
TransportCursor object. |
TransportCursor(Transport transport,
int size)
Constructor for the
TransportCursor object. |
Modifier and Type | Method and Description |
---|---|
boolean |
isOpen()
Determines whether the cursor is still open.
|
boolean |
isReady()
Determines whether the cursor is ready for reading.
|
void |
push(byte[] data)
Pushes the provided data on to the cursor.
|
void |
push(byte[] data,
int off,
int len)
Pushes the provided data on to the cursor.
|
int |
read(byte[] data)
Reads a block of bytes from the underlying stream.
|
int |
read(byte[] data,
int off,
int len)
Reads a block of bytes from the underlying stream.
|
int |
ready()
Provides the number of bytes that can be read from the stream
without blocking.
|
int |
reset(int size)
Moves the cursor backward within the stream.
|
public TransportCursor(Transport transport)
TransportCursor
object. This
requires a transport to read the bytes from. By default this
will create a buffer of of the specified size to read the
input in to which enabled bytes to be buffered internally.transport
- this is the underlying transport to usepublic TransportCursor(Transport transport, int size)
TransportCursor
object. This
requires a transport to read the bytes from. By default this
will create a buffer of of the specified size to read the
input in to which enabled bytes to be buffered internally.transport
- this is the underlying transport to usesize
- this is the size of the internal buffer to usepublic boolean isOpen() throws java.io.IOException
public boolean isReady() throws java.io.IOException
public int ready() throws java.io.IOException
public int read(byte[] data) throws java.io.IOException
public int read(byte[] data, int off, int len) throws java.io.IOException
public void push(byte[] data) throws java.io.IOException
reset
method which will reset
the cursors position on a stream. Allowing data to be pushed
on to the cursor allows more flexibility.public void push(byte[] data, int off, int len) throws java.io.IOException
reset
method which will reset
the cursors position on a stream. Allowing data to be pushed
on to the cursor allows more flexibility.public int reset(int size) throws java.io.IOException