public class IOInMemoryOrFile extends ConcurrentCloseable implements IO.Readable.Seekable, IO.Writable.Seekable, IO.KnownSize, IO.Resizable
IO.Readable.Buffered, IO.Readable.SeekableIO.Writable.Buffered, IO.Writable.SeekableIO.Seekable.SeekType| Constructor and Description |
|---|
IOInMemoryOrFile(int maxSizeInMemory,
byte priority,
String sourceDescription)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
ISynchronizationPoint<IOException> |
canStartReading()
Return a synchronization point that is unblocked when data is ready to be read.
|
ISynchronizationPoint<IOException> |
canStartWriting()
Return a synchronization point that is unblocked when data is ready to be written.
|
protected void |
closeResources(SynchronizationPoint<Exception> ondone) |
protected ISynchronizationPoint<?> |
closeUnderlyingResources() |
int |
getMaxInMemory() |
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.
|
AsyncWork<Integer,IOException> |
readAsync(ByteBuffer buffer,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Asynchronous read operation.
|
AsyncWork<Integer,IOException> |
readAsync(long pos,
ByteBuffer buffer,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Same as
IO.Readable.readAsync(ByteBuffer, RunnableWithParameter) but read at the given position. |
AsyncWork<Integer,IOException> |
readFullyAsync(ByteBuffer buffer,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Asynchronous read operation to fully fill the given buffer.
|
AsyncWork<Integer,IOException> |
readFullyAsync(long pos,
ByteBuffer buffer,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Same as
IO.Readable.readFullyAsync(ByteBuffer, RunnableWithParameter) 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. |
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.
|
AsyncWork<Void,IOException> |
setSizeAsync(long newSize)
Asynchronous resize.
|
void |
setSizeSync(long newSize)
Synchronous resize.
|
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.
|
AsyncWork<Integer,IOException> |
writeAsync(ByteBuffer buffer,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Write asynchronously all bytes available in the given buffer at the current position.
|
AsyncWork<Integer,IOException> |
writeAsync(long pos,
ByteBuffer buffer,
RunnableWithParameter<Pair<Integer,IOException>> ondone)
Same as
IO.Writable.writeAsync(ByteBuffer, RunnableWithParameter) but at the given position. |
int |
writeSync(ByteBuffer buffer)
Write synchronously all bytes available in the given buffer at the current position.
|
int |
writeSync(long pos,
ByteBuffer buffer)
Same as
IO.Writable.writeSync(ByteBuffer) but at the given position. |
addCloseListener, addCloseListener, close, closeAsync, isClosed, isClosing, lockClose, operation, operation, removeCloseListener, removeCloseListener, unlockCloseclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadAsync, readFullyAsyncreadAsync, readFullyAsync, skipAsyncwriteAsyncwriteAsyncseekAsyncpublic IOInMemoryOrFile(int maxSizeInMemory,
byte priority,
String sourceDescription)
public String getSourceDescription()
IOgetSourceDescription in interface IOpublic IO getWrappedIO()
IOgetWrappedIO in interface IOpublic int getMaxInMemory()
public TaskManager getTaskManager()
IOgetTaskManager in interface IOpublic ISynchronizationPoint<IOException> canStartReading()
IO.ReadablecanStartReading in interface IO.Readablepublic ISynchronizationPoint<IOException> canStartWriting()
IO.WritablecanStartWriting in interface IO.Writableprotected ISynchronizationPoint<?> closeUnderlyingResources()
closeUnderlyingResources in class ConcurrentCloseableprotected void closeResources(SynchronizationPoint<Exception> ondone)
closeResources in class ConcurrentCloseablepublic long getPosition()
IO.PositionKnowngetPosition in interface IO.PositionKnownpublic long seekSync(IO.Seekable.SeekType type, long move)
IO.SeekableseekSync in interface IO.Seekablepublic long skipSync(long n)
IO.ReadableskipSync in interface IO.Readablepublic 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 byte getPriority()
ConcurrentCloseablegetPriority in interface IOgetPriority in class ConcurrentCloseablepublic void setPriority(byte priority)
IOsetPriority in interface IOpublic long getSizeSync()
IO.KnownSizegetSizeSync in interface IO.KnownSizepublic AsyncWork<Long,IOException> getSizeAsync()
IO.KnownSizegetSizeAsync in interface IO.KnownSizepublic int writeSync(ByteBuffer buffer) throws IOException
IO.WritablewriteSync in interface IO.WritableIOExceptionpublic int writeSync(long pos,
ByteBuffer buffer)
throws IOException
IO.Writable.SeekableIO.Writable.writeSync(ByteBuffer) but at the given position.
Note that if the IO implements Resizable, the behaviour is different when writing at
the end or beyond the end of the IO: if not resizable, it must throw an exception,
while a resizable IO should accept it except if the resize operation fails.writeSync in interface IO.Writable.SeekableIOExceptionpublic AsyncWork<Integer,IOException> writeAsync(long pos, ByteBuffer buffer, RunnableWithParameter<Pair<Integer,IOException>> ondone)
IO.Writable.SeekableIO.Writable.writeAsync(ByteBuffer, RunnableWithParameter) but at the given position.
Note that if the IO implements Resizable, the behaviour is different when writing at
the end or beyond the end of the IO: if not resizable, it must throw an exception,
while a resizable IO should accept it except if the resize operation fails.writeAsync in interface IO.Writable.Seekablepublic AsyncWork<Integer,IOException> writeAsync(ByteBuffer buffer, RunnableWithParameter<Pair<Integer,IOException>> ondone)
IO.WritablewriteAsync in interface IO.Writablepublic void setSizeSync(long newSize)
throws IOException
IO.ResizablesetSizeSync in interface IO.ResizableIOExceptionpublic AsyncWork<Void,IOException> setSizeAsync(long newSize)
IO.ResizablesetSizeAsync in interface IO.Resizablepublic 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 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 AsyncWork<Integer,IOException> readAsync(long pos, ByteBuffer buffer, 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.Seekablepublic 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 AsyncWork<Integer,IOException> readFullyAsync(long pos, ByteBuffer buffer, 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 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.Copyright © 2018. All rights reserved.