public class ReadBufferDataHandle extends AbstractHigherOrderHandle<Location>
DataHandle. It buffers the underlying handle into
a fixed number of pages, swapping them out when necessary.DataHandle.ByteOrderDEFAULT_BLOCK_SIZE, MAX_SEARCH_SIZE| Constructor and Description |
|---|
ReadBufferDataHandle(DataHandle<Location> handle)
Creates a
ReadBufferDataHandle wrapping the provided handle using the
default values for the size of the pages ( byte)
and number of pages (DEFAULT_NUM_PAGES). |
ReadBufferDataHandle(DataHandle<Location> handle,
int pageSize)
Creates a
ReadBufferDataHandle wrapping the provided handle using the
default value for the number of pages (DEFAULT_NUM_PAGES). |
ReadBufferDataHandle(DataHandle<Location> handle,
int pageSize,
int numPages)
Creates a
ReadBufferDataHandle wrapping the provided handle. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cleanup()
Clean up data structures after a handle has been closed in the
AbstractHigherOrderHandle.close() method. |
boolean |
isReadable()
Gets whether reading from this handle is supported.
|
long |
offset()
Returns the current offset in the stream.
|
int |
read(byte[] b,
int targetOffset,
int len)
Reads up to
len bytes of data from the stream into an array of
bytes. |
byte |
readByte() |
void |
seek(long pos)
Sets the stream offset, measured from the beginning of the stream, at which
the next read or write occurs.
|
void |
setLength(long length)
Sets the new length of the handle.
|
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
close, ensureOpen, exists, getType, handle, isWritable, lengthconversionBuffer, getEncoding, getOrder, setEncoding, setOrderget, setsupportsgetInfo, getPriority, setInfo, setPriority, toStringcontext, getContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitavailable, checksum, ensureReadable, ensureWritable, findString, findString, findString, findString, isBigEndian, isLittleEndian, lastModified, read, read, readBoolean, readChar, readCString, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readString, readString, readUnsignedByte, readUnsignedShort, readUTF, setLittleEndian, skip, skipBytes, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLine, writeLong, writeShort, writeUTFget, setgetIdentifier, logcontext, getContext, setContextcompareTo, getPriority, setPrioritygetInfo, setInfogetLocationgetVersionpublic ReadBufferDataHandle(DataHandle<Location> handle)
ReadBufferDataHandle wrapping the provided handle using the
default values for the size of the pages ( byte)
and number of pages (DEFAULT_NUM_PAGES).handle - the handle to wrappublic ReadBufferDataHandle(DataHandle<Location> handle, int pageSize)
ReadBufferDataHandle wrapping the provided handle using the
default value for the number of pages (DEFAULT_NUM_PAGES).handle - the handle to wrappageSize - the size of the used pagespublic ReadBufferDataHandle(DataHandle<Location> handle, int pageSize, int numPages)
ReadBufferDataHandle wrapping the provided handle.handle - the handle to wrappageSize - the size of the used pagesnumPages - the number of pages to usepublic void seek(long pos)
throws IOException
DataHandleIOExceptionpublic int read(byte[] b,
int targetOffset,
int len)
throws IOException
DataHandlelen bytes of data from the stream into an array of
bytes.IOExceptionpublic byte readByte()
throws IOException
IOExceptionpublic boolean isReadable()
DataHandleisReadable in interface DataHandle<Location>isReadable in class AbstractHigherOrderHandle<Location>public long offset()
throws IOException
DataHandleIOExceptionprotected void cleanup()
AbstractHigherOrderHandleAbstractHigherOrderHandle.close() method.cleanup in class AbstractHigherOrderHandle<Location>public void write(int b)
throws IOException
IOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
IOExceptionpublic void setLength(long length)
throws IOException
DataHandlelength - New length.IOException - If there is an error changing the handle's length.Copyright © 2015–2022 SciJava. All rights reserved.