public class TransportCursor extends Object implements ByteCursor
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 IOException
isOpen in interface ByteCursorIOExceptionpublic boolean isReady()
throws IOException
isReady in interface ByteCursorIOExceptionpublic int ready()
throws IOException
ready in interface ByteCursorIOExceptionpublic int read(byte[] data)
throws IOException
read in interface ByteCursordata - this is the array to read the bytes in toIOExceptionpublic int read(byte[] data,
int off,
int len)
throws IOException
read in interface ByteCursordata - this is the array to read the bytes in tooff - this is the offset to begin writing the bytes tolen - this is the number of bytes that are requestedIOExceptionpublic void push(byte[] data)
throws IOException
reset method which will reset
the cursors position on a stream. Allowing data to be pushed
on to the cursor allows more flexibility.push in interface ByteCursordata - this is the data to be pushed on to the cursorIOExceptionpublic void push(byte[] data,
int off,
int len)
throws IOException
reset method which will reset
the cursors position on a stream. Allowing data to be pushed
on to the cursor allows more flexibility.push in interface ByteCursordata - this is the data to be pushed on to the cursoroff - this is the offset to begin reading the byteslen - this is the number of bytes that are to be usedIOExceptionpublic int reset(int size)
throws IOException
reset in interface ByteCursorsize - this is the number of bytes to reset backIOExceptionCopyright © 2025. All rights reserved.