public interface DataHandle<L extends Location> extends WrapperPlugin<L>, DataInput, DataOutput, Closeable
Location
.DataHandleInputStream
,
DataHandleOutputStream
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BLOCK_SIZE
Default block size to use when searching through the stream.
|
static int |
MAX_SEARCH_SIZE
Default bound on bytes to search when searching through the stream.
|
Modifier and Type | Method and Description |
---|---|
default String |
findString(boolean saveString,
int blockSize,
String... terminators)
Reads or skips a string ending with one of the given terminating
substrings, using the specified block size for buffering.
|
default String |
findString(boolean saveString,
String... terminators)
Reads or skips a string ending with one of the given terminating
substrings.
|
default String |
findString(int blockSize,
String... terminators)
Reads a string ending with one of the given terminating substrings, using
the specified block size for buffering.
|
default String |
findString(String... terminators)
Reads a string ending with one of the given terminating substrings.
|
String |
getEncoding()
Gets the native encoding of the stream.
|
ByteOrder |
getOrder()
Returns the current order of the stream.
|
default boolean |
isLittleEndian()
Gets the endianness of the stream.
|
long |
length()
Returns the length of the stream.
|
long |
offset()
Returns the current offset in the stream.
|
int |
read()
Reads the next byte of data from the stream.
|
default int |
read(byte[] b)
Reads up to b.length bytes of data from the stream into an array of bytes.
|
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from the stream into an array of bytes.
|
default int |
read(ByteBuffer buf)
Reads up to
buf.remaining() bytes of data from the stream into a
ByteBuffer . |
default int |
read(ByteBuffer buf,
int len)
Reads up to
len bytes of data from the stream into a
ByteBuffer . |
default String |
readCString()
Reads a string of arbitrary length, terminated by a null char.
|
default String |
readString(int n)
Reads a string of up to length n.
|
default String |
readString(String lastChars)
Reads a string ending with one of the characters in the given string.
|
void |
seek(long pos)
Sets the stream pointer offset, measured from the beginning of the stream,
at which the next read or write occurs.
|
void |
setEncoding(String encoding)
Sets the native encoding of the stream.
|
default void |
setOrder(boolean little)
Sets the endianness of the stream.
|
void |
setOrder(ByteOrder order)
Sets the byte order of the stream.
|
default long |
skip(long n)
Skips over and discards
n bytes of data from the stream. |
default void |
write(ByteBuffer buf)
Writes up to
buf.remaining() bytes of data from the given
ByteBuffer to the stream. |
default void |
write(ByteBuffer buf,
int len)
Writes up to len bytes of data from the given ByteBuffer to the stream.
|
get, set
getIdentifier, log
context, getContext, setContext
compareTo, getPriority, setPriority
getInfo, setInfo
getLocation
getVersion
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes
write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
static final int DEFAULT_BLOCK_SIZE
static final int MAX_SEARCH_SIZE
long offset() throws IOException
IOException
long length() throws IOException
IOException
ByteOrder getOrder()
default boolean isLittleEndian()
void setOrder(ByteOrder order)
order
- Order to set.default void setOrder(boolean little)
String getEncoding()
void setEncoding(String encoding)
default int read(ByteBuffer buf) throws IOException
buf.remaining()
bytes of data from the stream into a
ByteBuffer
.IOException
default int read(ByteBuffer buf, int len) throws IOException
len
bytes of data from the stream into a
ByteBuffer
.IOException
void seek(long pos) throws IOException
IOException
default void write(ByteBuffer buf) throws IOException
buf.remaining()
bytes of data from the given
ByteBuffer
to the stream.IOException
default void write(ByteBuffer buf, int len) throws IOException
IOException
default String readCString() throws IOException
IOException
default String readString(int n) throws IOException
IOException
default String readString(String lastChars) throws IOException
IOException
findString(String...)
default String findString(String... terminators) throws IOException
terminators
- The strings for which to search.IOException
default String findString(boolean saveString, String... terminators) throws IOException
saveString
- Whether to collect the string from the current file
pointer to the terminating bytes, and return it. If false, returns
null.terminators
- The strings for which to search.IOException
- If saveString flag is set and the maximum search length
(512 MB) is exceeded.default String findString(int blockSize, String... terminators) throws IOException
blockSize
- The block size to use when reading bytes in chunks.terminators
- The strings for which to search.IOException
default String findString(boolean saveString, int blockSize, String... terminators) throws IOException
saveString
- Whether to collect the string from the current file
pointer to the terminating bytes, and return it. If false, returns
null.blockSize
- The block size to use when reading bytes in chunks.terminators
- The strings for which to search.IOException
- If saveString flag is set and the maximum search length
(512 MB) is exceeded.int read() throws IOException
IOException
- - if an I/O error occurs.default int read(byte[] b) throws IOException
IOException
int read(byte[] b, int off, int len) throws IOException
IOException
default long skip(long n) throws IOException
n
bytes of data from the stream. The
skip
method may, for a variety of reasons, end up skipping over
some smaller number of bytes, possibly 0
. This may result from any
of a number of conditions; reaching end of file before n
bytes have
been skipped is only one possibility. The actual number of bytes skipped is
returned. If n
is negative, no bytes are skipped.n
- - the number of bytes to be skipped.IOException
- - if an I/O error occurs.Copyright © 2009–2017 SciJava. All rights reserved.