public class SimpleBufferedReadable extends ConcurrentCloseable implements IO.Readable.Buffered
IO.Readable.Buffered, IO.Readable.SeekableIO.KnownSize, IO.OperationType, IO.OutputToInput, IO.PositionKnown, IO.Readable, IO.ReadableByteStream, IO.Resizable, IO.Writable, IO.WritableByteStream, IO.WriterAsyncCloseableListenable.Impl| Constructor and Description |
|---|
SimpleBufferedReadable(IO.Readable io,
int bufferSize)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
ISynchronizationPoint<IOException> |
canStartReading()
Return a synchronization point that is unblocked when data is ready to be read.
|
protected void |
closeResources(SynchronizationPoint<Exception> ondone) |
protected ISynchronizationPoint<?> |
closeUnderlyingResources() |
byte |
getPriority()
Return the priority.
|
String |
getSourceDescription()
Describe the IO, which can be used for logging or debugging purposes.
|
TaskManager |
getTaskManager()
Return the TaskManager used for asynchronous operations.
|
IO |
getWrappedIO()
If this IO is wrapping another one (such as adding Buffered capabilities), this method returns it,
or null if it does not wrap another IO.
|
int |
read()
Read next byte.
|
int |
read(byte[] buffer,
int offset,
int l)
Read bytes into the given buffer, starting to store them at the given offset, and with the given maximum number of bytes.
|
int |
readAsync()
Read a single byte if possible.
|
AsyncWork<Integer,IOException> |
readAsync(ByteBuffer buffer,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Asynchronous read operation.
|
int |
readFully(byte[] buffer)
Read bytes to fill the given buffer, and return the number of bytes read which is less than the
size of the buffer only if the end of the IO is reached, and so may return 0.
|
AsyncWork<Integer,IOException> |
readFullyAsync(ByteBuffer buffer,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Asynchronous read operation to fully fill the given buffer.
|
int |
readFullySync(ByteBuffer buffer)
Synchronous read operation to fully fill the given buffer.
|
AsyncWork<ByteBuffer,IOException> |
readNextBufferAsync(RunnableWithParameter<Pair<ByteBuffer,IOException>> ondone)
Retrieve a buffer of bytes in the most efficient way depending on the implementation of Buffered.
This method is similar to readAsync, it read some bytes that are immediately available with a minimum of operations. |
int |
readSync(ByteBuffer buffer)
Read synchronously into the given buffer.
|
void |
setPriority(byte priority)
Set the priority of asynchronous operations.
|
int |
skip(int skip)
Same as
IO.Readable.skipSync(long) but limited to an integer. |
AsyncWork<Long,IOException> |
skipAsync(long n,
RunnableWithParameter<Pair<Long,IOException>> ondone)
Returns the number of bytes skipped.
|
long |
skipSync(long n)
Returns the number of bytes skipped.
|
void |
stop()
Stop any pending read, and block until they are cancelled or done.
|
addCloseListener, addCloseListener, close, closeAsync, isClosed, isClosing, lockClose, operation, operation, removeCloseListener, removeCloseListener, unlockCloseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadNextBufferAsyncreadAsync, readFullyAsync, skipAsyncreadBytelockClose, unlockCloseclosecloseAsyncaddCloseListener, addCloseListener, close, isClosed, removeCloseListener, removeCloseListenerpublic SimpleBufferedReadable(IO.Readable io, int bufferSize)
public ISynchronizationPoint<IOException> canStartReading()
IO.ReadablecanStartReading in interface IO.ReadablecanStartReading in interface IO.ReadableByteStreampublic TaskManager getTaskManager()
IOgetTaskManager in interface IOpublic IO getWrappedIO()
IOgetWrappedIO in interface IOpublic String getSourceDescription()
IOgetSourceDescription in interface IOpublic byte getPriority()
ConcurrentCloseablegetPriority in interface IOgetPriority in class ConcurrentCloseablepublic void setPriority(byte priority)
IOsetPriority in interface IOprotected ISynchronizationPoint<?> closeUnderlyingResources()
closeUnderlyingResources in class ConcurrentCloseableprotected void closeResources(SynchronizationPoint<Exception> ondone)
closeResources in class ConcurrentCloseablepublic void stop()
public int readSync(ByteBuffer buffer) throws IOException
IO.ReadablereadSync in interface IO.Readablebuffer - buffer to fillIOExceptionpublic int readAsync()
IO.Readable.BufferedreadAsync in interface IO.Readable.Bufferedpublic AsyncWork<Integer,IOException> readAsync(ByteBuffer buffer, RunnableWithParameter<Pair<Integer,IOException>> ondone)
IO.ReadablereadAsync in interface IO.Readablebuffer - buffer to fillondone - called before the returned AsyncWork is unblocked and its listeners are called.public int readFullySync(ByteBuffer buffer) throws IOException
IO.ReadablereadFullySync in interface IO.Readablebuffer - the buffer to fillIOExceptionpublic AsyncWork<Integer,IOException> readFullyAsync(ByteBuffer buffer, RunnableWithParameter<Pair<Integer,IOException>> ondone)
IO.ReadablereadFullyAsync in interface IO.Readablebuffer - the buffer to fillondone - called before the returned AsyncWork is unblocked and its listeners are called.public AsyncWork<ByteBuffer,IOException> readNextBufferAsync(RunnableWithParameter<Pair<ByteBuffer,IOException>> ondone)
IO.Readable.BufferedreadNextBufferAsync in interface IO.Readable.Bufferedpublic int skip(int skip)
throws IOException
IO.ReadableByteStreamIO.Readable.skipSync(long) but limited to an integer.skip in interface IO.ReadableByteStreamIOExceptionpublic long skipSync(long n)
throws IOException
IO.ReadableskipSync in interface IO.ReadableIOExceptionpublic AsyncWork<Long,IOException> skipAsync(long n, RunnableWithParameter<Pair<Long,IOException>> ondone)
IO.ReadableskipAsync in interface IO.Readablepublic int read()
throws IOException
IO.ReadableByteStreamread in interface IO.ReadableByteStreamIOExceptionpublic int read(byte[] buffer,
int offset,
int l)
throws IOException
IO.ReadableByteStreamread in interface IO.ReadableByteStreamIOExceptionpublic int readFully(byte[] buffer)
throws IOException
IO.ReadableByteStreamreadFully in interface IO.ReadableByteStreamIOExceptionCopyright © 2018. All rights reserved.