|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.drew.lang.ByteArrayReader
public class ByteArrayReader
Provides methods to read specific values from a byte array, with a consistent, checked exception structure for issues.
By default, the reader operates with Motorola byte order (big endianness). This can be changed by callingsetMotorolaByteOrder(boolean).
| Constructor Summary | |
|---|---|
ByteArrayReader(byte[] buffer)
|
|
| Method Summary | |
|---|---|
byte[] |
getBytes(int index,
int count)
|
double |
getDouble64(int index)
|
float |
getFloat32(int index)
|
short |
getInt16(int index)
Returns a signed 16-bit int calculated from two bytes of data at the specified index (MSB, LSB). |
int |
getInt32(int index)
Returns a signed 32-bit integer from four bytes of data at the specified index the buffer. |
long |
getInt64(int index)
Get a signed 64-bit integer from the buffer. |
byte |
getInt8(int index)
Returns a signed 8-bit int calculated from one byte of data at the specified index. |
long |
getLength()
Returns the length of the buffer. |
String |
getNullTerminatedString(int index,
int maxLengthBytes)
Creates a String from the _data buffer starting at the specified index, and ending where byte=='\0' or where length==maxLength. |
float |
getS15Fixed16(int index)
|
String |
getString(int index,
int bytesRequested)
|
String |
getString(int index,
int bytesRequested,
String charset)
|
int |
getUInt16(int index)
Returns an unsigned 16-bit int calculated from two bytes of data at the specified index. |
long |
getUInt32(int index)
Get a 32-bit unsigned integer from the buffer, returning it as a long. |
short |
getUInt8(int index)
Returns an unsigned 8-bit int calculated from one byte of data at the specified index. |
boolean |
isMotorolaByteOrder()
Gets the endianness of this reader. |
void |
setMotorolaByteOrder(boolean motorolaByteOrder)
Sets the endianness of this reader. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteArrayReader(byte[] buffer)
| Method Detail |
|---|
public long getLength()
BufferReader
getLength in interface BufferReaderpublic void setMotorolaByteOrder(boolean motorolaByteOrder)
BufferReadertrue for Motorola (or big) endiannessfalse for Intel (or little) endianness
setMotorolaByteOrder in interface BufferReadermotorolaByteOrder - true for motorola/big endian, false for intel/little endianpublic boolean isMotorolaByteOrder()
BufferReadertrue for Motorola (or big) endiannessfalse for Intel (or little) endianness
isMotorolaByteOrder in interface BufferReader
public short getUInt8(int index)
throws BufferBoundsException
BufferReader
getUInt8 in interface BufferReaderindex - position within the data buffer to read byte
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative
public byte getInt8(int index)
throws BufferBoundsException
BufferReader
getInt8 in interface BufferReaderindex - position within the data buffer to read byte
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative
public int getUInt16(int index)
throws BufferBoundsException
BufferReader
getUInt16 in interface BufferReaderindex - position within the data buffer to read first byte
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative
public short getInt16(int index)
throws BufferBoundsException
BufferReader
getInt16 in interface BufferReaderindex - position within the data buffer to read first byte
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative
public long getUInt32(int index)
throws BufferBoundsException
BufferReader
getUInt32 in interface BufferReaderindex - position within the data buffer to read first byte
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative
public int getInt32(int index)
throws BufferBoundsException
BufferReader
getInt32 in interface BufferReaderindex - position within the data buffer to read first byte
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative
public long getInt64(int index)
throws BufferBoundsException
BufferReader
getInt64 in interface BufferReaderindex - position within the data buffer to read first byte
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative
public float getS15Fixed16(int index)
throws BufferBoundsException
getS15Fixed16 in interface BufferReaderBufferBoundsException
public float getFloat32(int index)
throws BufferBoundsException
getFloat32 in interface BufferReaderBufferBoundsException
public double getDouble64(int index)
throws BufferBoundsException
getDouble64 in interface BufferReaderBufferBoundsException
public byte[] getBytes(int index,
int count)
throws BufferBoundsException
getBytes in interface BufferReaderBufferBoundsException
public String getString(int index,
int bytesRequested)
throws BufferBoundsException
getString in interface BufferReaderBufferBoundsException
public String getString(int index,
int bytesRequested,
String charset)
throws BufferBoundsException
getString in interface BufferReaderBufferBoundsException
public String getNullTerminatedString(int index,
int maxLengthBytes)
throws BufferBoundsException
BufferReaderbyte=='\0' or where length==maxLength.
getNullTerminatedString in interface BufferReaderindex - The index within the buffer at which to start reading the string.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.
BufferBoundsException - The buffer does not contain enough bytes to satisfy this request.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||