public abstract class SequentialReader extends Object
Constructor and Description |
---|
SequentialReader() |
Modifier and Type | Method and Description |
---|---|
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.
|
String |
getNullTerminatedString(int maxLengthBytes)
Creates a String from the stream, ending where
byte=='\0' or where length==maxLength . |
float |
getS15Fixed16()
Gets a s15.16 fixed point float from the buffer.
|
String |
getString(int bytesRequested) |
String |
getString(int bytesRequested,
String 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 byte[] getBytes(int count) throws IOException
count
- The number of bytes to be returnedIOException
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 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 getNullTerminatedString(int maxLengthBytes) 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.Copyright © 2002-2015 Drew Noakes. All Rights Reserved.