public abstract class SequentialReader extends Object
Constructor and Description |
---|
SequentialReader() |
Modifier and Type | Method and Description |
---|---|
abstract int |
available()
Returns an estimate of the number of bytes that can be read (or skipped
over) from this
SequentialReader without blocking by the next
invocation of a method for this input stream. |
abstract byte |
getByte()
Gets the next byte in the sequence.
|
abstract void |
getBytes(byte[] buffer,
int offset,
int count)
Retrieves bytes, writing them into a caller-provided buffer.
|
abstract byte[] |
getBytes(int count)
Returns the required number of bytes from the sequence.
|
double |
getDouble64() |
float |
getFloat32() |
short |
getInt16()
Returns a signed 16-bit int calculated from two bytes of data (MSB, LSB).
|
int |
getInt32()
Returns a signed 32-bit integer from four bytes of data.
|
long |
getInt64()
Get a signed 64-bit integer from the buffer.
|
byte |
getInt8()
Returns a signed 8-bit int calculated from the next byte the sequence.
|
byte[] |
getNullTerminatedBytes(int maxLengthBytes)
Returns the sequence of bytes punctuated by a
\0 value. |
String |
getNullTerminatedString(int maxLengthBytes,
Charset charset)
Creates a String from the stream, ending where
byte=='\0' or where length==maxLength . |
StringValue |
getNullTerminatedStringValue(int maxLengthBytes,
Charset charset)
Creates a String from the stream, ending where
byte=='\0' or where length==maxLength . |
abstract long |
getPosition() |
float |
getS15Fixed16()
Gets a s15.16 fixed point float from the buffer.
|
String |
getString(int bytesRequested) |
String |
getString(int bytesRequested,
Charset charset) |
String |
getString(int bytesRequested,
String charset) |
StringValue |
getStringValue(int bytesRequested,
Charset charset) |
int |
getUInt16()
Returns an unsigned 16-bit int calculated from the next two bytes of the sequence.
|
long |
getUInt32()
Get a 32-bit unsigned integer from the buffer, returning it as a long.
|
short |
getUInt8()
Returns an unsigned 8-bit int calculated from the next byte of the sequence.
|
boolean |
isMotorolaByteOrder()
Gets the endianness of this reader.
|
void |
setMotorolaByteOrder(boolean motorolaByteOrder)
Sets the endianness of this reader.
|
abstract void |
skip(long n)
Skips forward in the sequence.
|
abstract boolean |
trySkip(long n)
Skips forward in the sequence, returning a boolean indicating whether the skip succeeded, or whether the sequence ended.
|
public abstract long getPosition() throws IOException
IOException
public abstract byte getByte() throws IOException
IOException
public abstract byte[] getBytes(int count) throws IOException
count
- The number of bytes to be returnedIOException
public abstract void getBytes(byte[] buffer, int offset, int count) throws IOException
buffer
- The array to write bytes to.offset
- The starting position within buffer to write to.count
- The number of bytes to be written.IOException
public abstract void skip(long n) throws IOException
EOFException
is thrown.n
- the number of byte to skip. Must be zero or greater.EOFException
- the end of the sequence is reached.IOException
- an error occurred reading from the underlying source.public abstract boolean trySkip(long n) throws IOException
n
- the number of byte to skip. Must be zero or greater.IOException
- an error occurred reading from the underlying source.public abstract int available()
SequentialReader
without blocking by the next
invocation of a method for this input stream. A single read or skip of
this many bytes will not block, but may read or skip fewer bytes.
Note that while some implementations of SequentialReader
like
SequentialByteArrayReader
will return the total remaining number
of bytes in the stream, others will not. It is never correct to use the
return value of this method to allocate a buffer intended to hold all
data in this stream.
SequentialReader
without blocking or
0
when it reaches the end of the input stream.public void setMotorolaByteOrder(boolean motorolaByteOrder)
true
for Motorola (or big) endianness (also known as network byte order), with MSB before LSB.false
for Intel (or little) endianness, with LSB before MSB.motorolaByteOrder
- true
for Motorola/big endian, false
for Intel/little endianpublic boolean isMotorolaByteOrder()
true
for Motorola (or big) endianness (also known as network byte order), with MSB before LSB.false
for Intel (or little) endianness, with LSB before MSB.public short getUInt8() throws IOException
IOException
public byte getInt8() throws IOException
IOException
public int getUInt16() throws IOException
IOException
public short getInt16() throws IOException
IOException
- the buffer does not contain enough bytes to service the requestpublic long getUInt32() throws IOException
IOException
- the buffer does not contain enough bytes to service the requestpublic int getInt32() throws IOException
IOException
- the buffer does not contain enough bytes to service the requestpublic long getInt64() throws IOException
IOException
- the buffer does not contain enough bytes to service the requestpublic float getS15Fixed16() throws IOException
This particular fixed point encoding has one sign bit, 15 numerator bits and 16 denominator bits.
IOException
- the buffer does not contain enough bytes to service the requestpublic float getFloat32() throws IOException
IOException
public double getDouble64() throws IOException
IOException
public String getString(int bytesRequested) throws IOException
IOException
public String getString(int bytesRequested, String charset) throws IOException
IOException
public String getString(int bytesRequested, Charset charset) throws IOException
IOException
public StringValue getStringValue(int bytesRequested, Charset charset) throws IOException
IOException
public String getNullTerminatedString(int maxLengthBytes, Charset charset) throws IOException
byte=='\0'
or where length==maxLength
.maxLengthBytes
- The maximum number of bytes to read. If a zero-byte is not reached within this limit,
reading will stop and the string will be truncated to this length.IOException
- The buffer does not contain enough bytes to satisfy this request.public StringValue getNullTerminatedStringValue(int maxLengthBytes, Charset charset) throws IOException
byte=='\0'
or where length==maxLength
.maxLengthBytes
- The maximum number of bytes to read. If a \0
byte is not reached within this limit,
reading will stop and the string will be truncated to this length.charset
- The Charset
to register with the returned StringValue
, or null
if the encoding
is unknownIOException
- The buffer does not contain enough bytes to satisfy this request.public byte[] getNullTerminatedBytes(int maxLengthBytes) throws IOException
\0
value.maxLengthBytes
- The maximum number of bytes to read. If a \0
byte is not reached within this limit,
the returned array will be maxLengthBytes
long.IOException
- The buffer does not contain enough bytes to satisfy this request.Copyright © 2010 - 2020 Adobe. All Rights Reserved