public class ReadableSeekableToDeterminedSize extends Object implements IO.Readable.Seekable, IO.KnownSize
IO.Readable.Buffered, IO.Readable.SeekableIO.Seekable.SeekTypeIO.KnownSize, IO.OperationType, IO.OutputToInput, IO.PositionKnown, IO.Readable, IO.ReadableByteStream, IO.Resizable, IO.Writable, IO.WritableByteStream, IO.WriterAsyncCloseableListenable.Impl| Constructor and Description |
|---|
ReadableSeekableToDeterminedSize(IO.Readable.Seekable io)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCloseListener(Consumer<CloseableListenable> listener)
Add a listener to be called once this resource is closed.
|
void |
addCloseListener(Runnable listener)
Add a listener to be called once this resource is closed.
|
IAsync<IOException> |
canStartReading()
Return a synchronization point that is unblocked when data is ready to be read.
|
void |
close()
Close.
|
IAsync<IOException> |
closeAsync()
Close asynchronously.
|
long |
getPosition()
Return the current position.
|
byte |
getPriority()
Return the priority of asynchronous operations.
|
AsyncSupplier<Long,IOException> |
getSizeAsync()
Asynchronous operation to get the size of the IO.
|
long |
getSizeSync()
Synchronous operation to get the size of the IO.
|
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.
|
boolean |
isClosed()
Return true if closed.
|
boolean |
lockClose()
Calling this method avoid this resource to be closed.
|
AsyncSupplier<Integer,IOException> |
readAsync(ByteBuffer buffer,
Consumer<Pair<Integer,IOException>> ondone)
Asynchronous read operation.
|
AsyncSupplier<Integer,IOException> |
readAsync(long pos,
ByteBuffer buffer,
Consumer<Pair<Integer,IOException>> ondone)
Same as
IO.Readable.readAsync(ByteBuffer, Consumer) but read at the given position. |
AsyncSupplier<Integer,IOException> |
readFullyAsync(ByteBuffer buffer,
Consumer<Pair<Integer,IOException>> ondone)
Asynchronous read operation to fully fill the given buffer.
|
AsyncSupplier<Integer,IOException> |
readFullyAsync(long pos,
ByteBuffer buffer,
Consumer<Pair<Integer,IOException>> ondone)
Same as
IO.Readable.readFullyAsync(ByteBuffer, Consumer) but read at the given position. |
int |
readFullySync(ByteBuffer buffer)
Synchronous read operation to fully fill the given buffer.
|
int |
readFullySync(long pos,
ByteBuffer buffer)
Same as
IO.Readable.readFullySync(ByteBuffer) but read at the given position. |
int |
readSync(ByteBuffer buffer)
Read synchronously into the given buffer.
|
int |
readSync(long pos,
ByteBuffer buffer)
Same as
IO.Readable.readSync(ByteBuffer) but read at the given position. |
void |
removeCloseListener(Consumer<CloseableListenable> listener)
Remove a listener.
|
void |
removeCloseListener(Runnable listener)
Remove a listener.
|
AsyncSupplier<Long,IOException> |
seekAsync(IO.Seekable.SeekType type,
long move,
Consumer<Pair<Long,IOException>> ondone)
Returns the new position.
|
long |
seekSync(IO.Seekable.SeekType type,
long move)
Returns the new position.
|
void |
setPriority(byte priority)
Set the priority of asynchronous operations.
|
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.
|
void |
unlockClose()
Allow to close this resource, if this is the last lock on it.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadAsync, readFullyAsyncreadAsync, readFullyAsync, skipAsyncseekAsynccancelClosed, error, errorCancelledcloseAfterpublic ReadableSeekableToDeterminedSize(IO.Readable.Seekable io)
public String getSourceDescription()
IOgetSourceDescription in interface IOpublic IO getWrappedIO()
IOgetWrappedIO in interface IOpublic void close()
throws Exception
CloseableListenableclose in interface AutoCloseableclose in interface CloseableListenableExceptionpublic IAsync<IOException> closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseable<IOException>public boolean isClosed()
CloseableListenableisClosed in interface CloseableListenablepublic IAsync<IOException> canStartReading()
IO.ReadablecanStartReading in interface IO.Readablepublic void addCloseListener(Runnable listener)
CloseableListenableaddCloseListener in interface CloseableListenablepublic void addCloseListener(Consumer<CloseableListenable> listener)
CloseableListenableaddCloseListener in interface CloseableListenablepublic void removeCloseListener(Runnable listener)
CloseableListenableremoveCloseListener in interface CloseableListenablepublic void removeCloseListener(Consumer<CloseableListenable> listener)
CloseableListenableremoveCloseListener in interface CloseableListenablepublic boolean lockClose()
IConcurrentCloseablelockClose in interface IConcurrentCloseable<IOException>public void unlockClose()
IConcurrentCloseableunlockClose in interface IConcurrentCloseable<IOException>public byte getPriority()
IOgetPriority in interface IOpublic void setPriority(byte priority)
IOsetPriority in interface IOpublic TaskManager getTaskManager()
IOgetTaskManager in interface IOpublic int readSync(ByteBuffer buffer) throws IOException
IO.ReadablereadSync in interface IO.Readablebuffer - buffer to fillIOExceptionpublic int readSync(long pos,
ByteBuffer buffer)
throws IOException
IO.Readable.SeekableIO.Readable.readSync(ByteBuffer) but read at the given position.
The current position is changed to the given position plus the number of bytes read.readSync in interface IO.Readable.SeekableIOExceptionpublic AsyncSupplier<Integer,IOException> readAsync(ByteBuffer buffer, Consumer<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 AsyncSupplier<Integer,IOException> readAsync(long pos, ByteBuffer buffer, Consumer<Pair<Integer,IOException>> ondone)
IO.Readable.SeekableIO.Readable.readAsync(ByteBuffer, Consumer) but read at the given position.
The current position is changed to the given position plus the number of bytes read upon completion.readAsync in interface IO.Readable.Seekablepublic int readFullySync(ByteBuffer buffer) throws IOException
IO.ReadablereadFullySync in interface IO.Readablebuffer - the buffer to fillIOExceptionpublic int readFullySync(long pos,
ByteBuffer buffer)
throws IOException
IO.Readable.SeekableIO.Readable.readFullySync(ByteBuffer) but read at the given position.
The current position is changed to the given position plus the number of bytes read.readFullySync in interface IO.Readable.SeekableIOExceptionpublic AsyncSupplier<Integer,IOException> readFullyAsync(ByteBuffer buffer, Consumer<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 AsyncSupplier<Integer,IOException> readFullyAsync(long pos, ByteBuffer buffer, Consumer<Pair<Integer,IOException>> ondone)
IO.Readable.SeekableIO.Readable.readFullyAsync(ByteBuffer, Consumer) but read at the given position.
The current position is changed to the given position plus the number of bytes read upon completion.readFullyAsync in interface IO.Readable.Seekablepublic long getPosition()
throws IOException
IO.PositionKnowngetPosition in interface IO.PositionKnownIOExceptionpublic long seekSync(IO.Seekable.SeekType type, long move) throws IOException
IO.SeekableseekSync in interface IO.SeekableIOExceptionpublic AsyncSupplier<Long,IOException> seekAsync(IO.Seekable.SeekType type, long move, Consumer<Pair<Long,IOException>> ondone)
IO.SeekableseekAsync in interface IO.Seekablepublic long skipSync(long n)
throws IOException
IO.ReadableskipSync in interface IO.ReadableIOExceptionpublic AsyncSupplier<Long,IOException> skipAsync(long n, Consumer<Pair<Long,IOException>> ondone)
IO.ReadableskipAsync in interface IO.Readablepublic long getSizeSync()
throws IOException
IO.KnownSizegetSizeSync in interface IO.KnownSizeIOExceptionpublic AsyncSupplier<Long,IOException> getSizeAsync()
IO.KnownSizegetSizeAsync in interface IO.KnownSizeCopyright © 2019. All rights reserved.