public class ReadBufferDataHandle extends AbstractHigherOrderHandle<Location>
DataHandle
. It buffers the underlying handle into
a fixed number of pages, swapping them out when necessary.DataHandle.ByteOrder
DEFAULT_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, length
conversionBuffer, getEncoding, getOrder, setEncoding, setOrder
get, set
supports
getInfo, getPriority, setInfo, setPriority, toString
context, getContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
available, 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, writeUTF
get, set
getIdentifier, log
context, getContext, setContext
compareTo, getPriority, setPriority
getInfo, setInfo
getLocation
getVersion
public 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
DataHandle
IOException
public int read(byte[] b, int targetOffset, int len) throws IOException
DataHandle
len
bytes of data from the stream into an array of
bytes.IOException
public byte readByte() throws IOException
IOException
public boolean isReadable()
DataHandle
isReadable
in interface DataHandle<Location>
isReadable
in class AbstractHigherOrderHandle<Location>
public long offset() throws IOException
DataHandle
IOException
protected void cleanup()
AbstractHigherOrderHandle
AbstractHigherOrderHandle.close()
method.cleanup
in class AbstractHigherOrderHandle<Location>
public void write(int b) throws IOException
IOException
public void write(byte[] b, int off, int len) throws IOException
IOException
public void setLength(long length) throws IOException
DataHandle
length
- New length.IOException
- If there is an error changing the handle's length.Copyright © 2015–2022 SciJava. All rights reserved.