public abstract class SequentialReader
extends java.lang.Object
| Constructor and Description |
|---|
SequentialReader() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract byte |
getByte()
Gets the next byte in the sequence.
|
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.
|
java.lang.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.
|
java.lang.String |
getString(int bytesRequested) |
java.lang.String |
getString(int bytesRequested,
java.lang.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.
|
protected abstract byte getByte()
throws java.io.IOException
java.io.IOExceptionpublic abstract byte[] getBytes(int count)
throws java.io.IOException
count - The number of bytes to be returnedjava.io.IOExceptionpublic abstract void skip(long n)
throws java.io.IOException
EOFException is thrown.n - the number of byte to skip. Must be zero or greater.java.io.EOFException - the end of the sequence is reached.java.io.IOException - an error occurred reading from the underlying source.public abstract boolean trySkip(long n)
throws java.io.IOException
n - the number of byte to skip. Must be zero or greater.java.io.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 java.io.IOException
java.io.IOExceptionpublic byte getInt8()
throws java.io.IOException
java.io.IOExceptionpublic int getUInt16()
throws java.io.IOException
java.io.IOExceptionpublic short getInt16()
throws java.io.IOException
java.io.IOException - the buffer does not contain enough bytes to service the requestpublic long getUInt32()
throws java.io.IOException
java.io.IOException - the buffer does not contain enough bytes to service the requestpublic int getInt32()
throws java.io.IOException
java.io.IOException - the buffer does not contain enough bytes to service the requestpublic long getInt64()
throws java.io.IOException
java.io.IOException - the buffer does not contain enough bytes to service the requestpublic float getS15Fixed16()
throws java.io.IOException
This particular fixed point encoding has one sign bit, 15 numerator bits and 16 denominator bits.
java.io.IOException - the buffer does not contain enough bytes to service the requestpublic float getFloat32()
throws java.io.IOException
java.io.IOExceptionpublic double getDouble64()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getString(int bytesRequested)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getString(int bytesRequested,
java.lang.String charset)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getNullTerminatedString(int maxLengthBytes)
throws java.io.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.java.io.IOException - The buffer does not contain enough bytes to satisfy this request.Copyright © 2002-2016 Drew Noakes. All Rights Reserved.