public static class BufferedIO.ReadOnly extends BufferedIO implements IO.Readable.Seekable, IO.Readable.Buffered, IO.KnownSize
BufferedIO.Buffer, BufferedIO.ReadOnly, BufferedIO.ReadWriteIO.Seekable.SeekTypeIO.KnownSize, IO.OperationType, IO.OutputToInput, IO.PositionKnown, IO.Readable, IO.ReadableByteStream, IO.Resizable, IO.Writable, IO.WritableByteStream, IO.WriterAsyncCloseableListenable.ImplIO.Readable.Buffered, IO.Readable.Seekablebuffers, io, manager, pos, size, startReadSecondBufferWhenFirstBufferFullyRead| Constructor and Description |
|---|
ReadOnly(IO.Readable.Seekable io,
int firstBufferSize,
int bufferSize,
long size,
boolean startReadSecondBufferWhenFirstBufferFullyRead)
Constructor.
|
ReadOnly(IO.Readable.Seekable io,
int bufferSize,
long size)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
ISynchronizationPoint<IOException> |
canStartReading()
Return a synchronization point that is unblocked when data is ready to be read.
|
long |
getPosition()
Return the current position.
|
byte |
getPriority()
Return the priority.
|
AsyncWork<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.
|
int |
read()
Read next byte.
|
int |
read(byte[] buf,
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.
|
AsyncWork<Integer,IOException> |
readAsync(ByteBuffer buf,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Asynchronous read operation.
|
AsyncWork<Integer,IOException> |
readAsync(long pos,
ByteBuffer buf,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Same as
IO.Readable.readAsync(ByteBuffer, RunnableWithParameter) but read at the given position. |
int |
readFully(byte[] buf)
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 buf,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Asynchronous read operation to fully fill the given buffer.
|
AsyncWork<Integer,IOException> |
readFullyAsync(long pos,
ByteBuffer buf,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Same as
IO.Readable.readFullyAsync(ByteBuffer, RunnableWithParameter) but read at the given position. |
int |
readFullySync(ByteBuffer buf)
Synchronous read operation to fully fill the given buffer.
|
int |
readFullySync(long pos,
ByteBuffer buf)
Same as
IO.Readable.readFullySync(ByteBuffer) but read at the given position. |
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 buf)
Read synchronously into the given buffer.
|
int |
readSync(long pos,
ByteBuffer buf)
Same as
IO.Readable.readSync(ByteBuffer) but read at the given position. |
AsyncWork<Long,IOException> |
seekAsync(IO.Seekable.SeekType type,
long move,
RunnableWithParameter<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.
|
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 skip)
Returns the number of bytes skipped.
|
closeResources, closeUnderlyingResources, decreaseSize, flush, getBufferIndex, getBufferOffset, getBufferStart, increaseSize, loadBuffer, readFullyAsync, useBufferAsync, useBufferSync, write, write, writeAsync, writeSyncaddCloseListener, addCloseListener, close, closeAsync, isClosed, isClosing, lockClose, operation, operation, removeCloseListener, removeCloseListener, unlockCloseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadAsync, readFullyAsyncseekAsynclockClose, unlockCloseclosecloseAsyncaddCloseListener, addCloseListener, close, isClosed, removeCloseListener, removeCloseListenerreadNextBufferAsyncreadAsync, readFullyAsync, skipAsyncreadBytepublic ReadOnly(IO.Readable.Seekable io, int bufferSize, long size) throws IOException
IOExceptionpublic ReadOnly(IO.Readable.Seekable io, int firstBufferSize, int bufferSize, long size, boolean startReadSecondBufferWhenFirstBufferFullyRead) throws IOException
IOExceptionpublic ISynchronizationPoint<IOException> canStartReading()
IO.ReadablecanStartReading in interface IO.ReadablecanStartReading in interface IO.ReadableByteStreamcanStartReading in class BufferedIOpublic 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 IOpublic TaskManager getTaskManager()
IOgetTaskManager in interface IOpublic long getPosition()
IO.PositionKnowngetPosition in interface IO.PositionKnownpublic long getSizeSync()
IO.KnownSizegetSizeSync in interface IO.KnownSizepublic AsyncWork<Long,IOException> getSizeAsync()
IO.KnownSizegetSizeAsync in interface IO.KnownSizepublic int skip(int skip)
IO.ReadableByteStreamIO.Readable.skipSync(long) but limited to an integer.skip in interface IO.ReadableByteStreampublic long skipSync(long skip)
IO.ReadableskipSync in interface IO.Readablepublic long seekSync(IO.Seekable.SeekType type, long move)
IO.SeekableseekSync in interface IO.Seekablepublic AsyncWork<Long,IOException> seekAsync(IO.Seekable.SeekType type, long move, RunnableWithParameter<Pair<Long,IOException>> ondone)
IO.SeekableseekAsync in interface IO.Seekablepublic 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.ReadableByteStreamread in class BufferedIOIOExceptionpublic int read(byte[] buf,
int offset,
int len)
throws IOException
IO.ReadableByteStreamread in interface IO.ReadableByteStreamread in class BufferedIOIOExceptionpublic int readFully(byte[] buf)
throws IOException
IO.ReadableByteStreamreadFully in interface IO.ReadableByteStreamreadFully in class BufferedIOIOExceptionpublic int readSync(long pos,
ByteBuffer buf)
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.SeekablereadSync in class BufferedIOIOExceptionpublic int readSync(ByteBuffer buf) throws IOException
IO.ReadablereadSync in interface IO.Readablebuf - buffer to fillIOExceptionpublic int readAsync()
throws IOException
IO.Readable.BufferedreadAsync in interface IO.Readable.BufferedreadAsync in class BufferedIOIOExceptionpublic AsyncWork<Integer,IOException> readAsync(long pos, ByteBuffer buf, RunnableWithParameter<Pair<Integer,IOException>> ondone)
IO.Readable.SeekableIO.Readable.readAsync(ByteBuffer, RunnableWithParameter) 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.SeekablereadAsync in class BufferedIOpublic AsyncWork<Integer,IOException> readAsync(ByteBuffer buf, RunnableWithParameter<Pair<Integer,IOException>> ondone)
IO.ReadablereadAsync in interface IO.Readablebuf - 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.BufferedreadNextBufferAsync in class BufferedIOpublic int readFullySync(long pos,
ByteBuffer buf)
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.SeekablereadFullySync in class BufferedIOIOExceptionpublic int readFullySync(ByteBuffer buf) throws IOException
IO.ReadablereadFullySync in interface IO.Readablebuf - the buffer to fillIOExceptionpublic AsyncWork<Integer,IOException> readFullyAsync(long pos, ByteBuffer buf, RunnableWithParameter<Pair<Integer,IOException>> ondone)
IO.Readable.SeekableIO.Readable.readFullyAsync(ByteBuffer, RunnableWithParameter) 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 AsyncWork<Integer,IOException> readFullyAsync(ByteBuffer buf, RunnableWithParameter<Pair<Integer,IOException>> ondone)
IO.ReadablereadFullyAsync in interface IO.Readablebuf - the buffer to fillondone - called before the returned AsyncWork is unblocked and its listeners are called.Copyright © 2017. All rights reserved.