public static class PositionKnownWrapper.Readable.Buffered extends PositionKnownWrapper<IO.Readable.Buffered> implements IO.Readable.Buffered, IO.PositionKnown
PositionKnownWrapper.ReadableIO.Readable.Buffered, IO.Readable.SeekableIO.KnownSize, IO.OperationType, IO.OutputToInput, IO.PositionKnown, IO.Readable, IO.ReadableByteStream, IO.Resizable, IO.Writable, IO.WritableByteStream, IO.WriterAsyncCloseableListenable.Implio, position| Constructor and Description |
|---|
Buffered(IO.Readable.Buffered io)
Constructor.
|
Buffered(IO.Readable.Buffered io,
long position)
Constructor with initial position.
|
| Modifier and Type | Method and Description |
|---|---|
IAsync<IOException> |
canStartReading()
Return a synchronization point that is unblocked when data is ready to be read.
|
int |
read()
Read next byte.
|
int |
read(byte[] buffer,
int offset,
int len)
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.
|
AsyncSupplier<Integer,IOException> |
readAsync(ByteBuffer buffer,
Consumer<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.
|
AsyncSupplier<Integer,IOException> |
readFullyAsync(ByteBuffer buffer,
Consumer<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.
|
AsyncSupplier<Integer,IOException> |
readFullySyncIfPossible(ByteBuffer buffer,
Consumer<Pair<Integer,IOException>> ondone)
While readAsync methods are supposed to do the job in a separate thread, this method
fills the given buffer synchronously if enough data is already buffered, else it finishes asynchronously.
|
ByteBuffer |
readNextBuffer()
Retrieve a buffer of bytes in the most efficient way depending on the implementation of Buffered.
Its returns the immediately available bytes with a minimum of operations. |
AsyncSupplier<ByteBuffer,IOException> |
readNextBufferAsync(Consumer<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 reads some bytes that are immediately available with a minimum of operations. |
int |
readSync(ByteBuffer buffer)
Read synchronously into the given buffer.
|
int |
skip(int skip)
Same as
IO.Readable.skipSync(long) but limited to an integer. |
AsyncSupplier<Long,IOException> |
skipAsync(long n,
Consumer<Pair<Long,IOException>> ondone)
Returns the number of bytes skipped.
|
long |
skipSync(long n)
Returns the number of bytes skipped.
|
addPositionChangedListener, addPositionChangedListener, closeResources, closeUnderlyingResources, getPosition, getPriority, getSourceDescription, getTaskManager, getWrappedIO, removePositionChangedListener, removePositionChangedListener, setPriorityaddCloseListener, addCloseListener, close, closeAsync, isClosed, isClosing, lockClose, operation, operation, removeCloseListener, removeCloseListener, unlockCloseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadFullySyncIfPossible, readNextBufferAsyncreadAsync, readFullyAsync, skipAsyncreadBytecancelClosed, error, errorCancelled, getPriority, getSourceDescription, getTaskManager, getWrappedIO, setPrioritylockClose, unlockCloseclosecloseAfter, closeAsyncaddCloseListener, addCloseListener, close, isClosed, removeCloseListener, removeCloseListenergetPositionpublic Buffered(IO.Readable.Buffered io, long position)
public Buffered(IO.Readable.Buffered io)
public IAsync<IOException> canStartReading()
IO.ReadablecanStartReading in interface IO.ReadablecanStartReading in interface IO.ReadableByteStreamcanStartReading in class PositionKnownWrapper<IO.Readable.Buffered>public int readSync(ByteBuffer buffer) throws IOException
IO.ReadablereadSync in interface IO.ReadablereadSync in class PositionKnownWrapper<IO.Readable.Buffered>buffer - buffer to fillIOExceptionpublic int readAsync()
throws IOException
IO.Readable.BufferedreadAsync in interface IO.Readable.BufferedreadAsync in class PositionKnownWrapper<IO.Readable.Buffered>IOExceptionpublic AsyncSupplier<Integer,IOException> readAsync(ByteBuffer buffer, Consumer<Pair<Integer,IOException>> ondone)
IO.ReadablereadAsync in interface IO.ReadablereadAsync in class PositionKnownWrapper<IO.Readable.Buffered>buffer - 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.ReadablereadFullySync in class PositionKnownWrapper<IO.Readable.Buffered>buffer - the buffer to fillIOExceptionpublic AsyncSupplier<Integer,IOException> readFullyAsync(ByteBuffer buffer, Consumer<Pair<Integer,IOException>> ondone)
IO.ReadablereadFullyAsync in interface IO.ReadablereadFullyAsync in class PositionKnownWrapper<IO.Readable.Buffered>buffer - the buffer to fillondone - called before the returned AsyncWork is unblocked and its listeners are called.public long skipSync(long n)
throws IOException
IO.ReadableskipSync in interface IO.ReadableskipSync in class PositionKnownWrapper<IO.Readable.Buffered>IOExceptionpublic AsyncSupplier<Long,IOException> skipAsync(long n, Consumer<Pair<Long,IOException>> ondone)
IO.ReadableskipAsync in interface IO.ReadableskipAsync in class PositionKnownWrapper<IO.Readable.Buffered>public int read()
throws IOException
IO.ReadableByteStreamread in interface IO.ReadableByteStreamread in class PositionKnownWrapper<IO.Readable.Buffered>IOExceptionpublic int read(byte[] buffer,
int offset,
int len)
throws IOException
IO.ReadableByteStreamread in interface IO.ReadableByteStreamread in class PositionKnownWrapper<IO.Readable.Buffered>IOExceptionpublic int readFully(byte[] buffer)
throws IOException
IO.ReadableByteStreamreadFully in interface IO.ReadableByteStreamreadFully in class PositionKnownWrapper<IO.Readable.Buffered>IOExceptionpublic int skip(int skip)
throws IOException
IO.ReadableByteStreamIO.Readable.skipSync(long) but limited to an integer.skip in interface IO.ReadableByteStreamskip in class PositionKnownWrapper<IO.Readable.Buffered>IOExceptionpublic AsyncSupplier<ByteBuffer,IOException> readNextBufferAsync(Consumer<Pair<ByteBuffer,IOException>> ondone)
IO.Readable.BufferedreadNextBufferAsync in interface IO.Readable.BufferedreadNextBufferAsync in class PositionKnownWrapper<IO.Readable.Buffered>public ByteBuffer readNextBuffer() throws IOException
IO.Readable.BufferedreadNextBuffer in interface IO.Readable.BufferedreadNextBuffer in class PositionKnownWrapper<IO.Readable.Buffered>IOExceptionpublic AsyncSupplier<Integer,IOException> readFullySyncIfPossible(ByteBuffer buffer, Consumer<Pair<Integer,IOException>> ondone)
IO.Readable.BufferedreadFullySyncIfPossible in interface IO.Readable.BufferedreadFullySyncIfPossible in class PositionKnownWrapper<IO.Readable.Buffered>Copyright © 2019. All rights reserved.