com.drew.lang
Interface BufferReader

All Known Implementing Classes:
ByteArrayReader, RandomAccessFileReader

public interface BufferReader


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.
 

Method Detail

getLength

long getLength()
Returns the length of the buffer. This value represents the total number of bytes in the underlying source.

Returns:
The number of bytes in the buffer.

setMotorolaByteOrder

void setMotorolaByteOrder(boolean motorolaByteOrder)
Sets the endianness of this reader.

Parameters:
motorolaByteOrder - true for motorola/big endian, false for intel/little endian

isMotorolaByteOrder

boolean isMotorolaByteOrder()
Gets the endianness of this reader.


getUInt8

short getUInt8(int index)
               throws BufferBoundsException
Returns an unsigned 8-bit int calculated from one byte of data at the specified index.

Parameters:
index - position within the data buffer to read byte
Returns:
the 8 bit int value, between 0 and 255
Throws:
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative

getInt8

byte getInt8(int index)
             throws BufferBoundsException
Returns a signed 8-bit int calculated from one byte of data at the specified index.

Parameters:
index - position within the data buffer to read byte
Returns:
the 8 bit int value, between 0x00 and 0xFF
Throws:
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative

getUInt16

int getUInt16(int index)
              throws BufferBoundsException
Returns an unsigned 16-bit int calculated from two bytes of data at the specified index.

Parameters:
index - position within the data buffer to read first byte
Returns:
the 16 bit int value, between 0x0000 and 0xFFFF
Throws:
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative

getInt16

short getInt16(int index)
               throws BufferBoundsException
Returns a signed 16-bit int calculated from two bytes of data at the specified index (MSB, LSB).

Parameters:
index - position within the data buffer to read first byte
Returns:
the 16 bit int value, between 0x0000 and 0xFFFF
Throws:
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative

getUInt32

long getUInt32(int index)
               throws BufferBoundsException
Get a 32-bit unsigned integer from the buffer, returning it as a long.

Parameters:
index - position within the data buffer to read first byte
Returns:
the unsigned 32-bit int value as a long, between 0x00000000 and 0xFFFFFFFF
Throws:
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative

getInt32

int getInt32(int index)
             throws BufferBoundsException
Returns a signed 32-bit integer from four bytes of data at the specified index the buffer.

Parameters:
index - position within the data buffer to read first byte
Returns:
the signed 32 bit int value, between 0x00000000 and 0xFFFFFFFF
Throws:
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative

getInt64

long getInt64(int index)
              throws BufferBoundsException
Get a signed 64-bit integer from the buffer.

Parameters:
index - position within the data buffer to read first byte
Returns:
the 64 bit int value, between 0x0000000000000000 and 0xFFFFFFFFFFFFFFFF
Throws:
BufferBoundsException - the buffer does not contain enough bytes to service the request, or index is negative

getS15Fixed16

float getS15Fixed16(int index)
                    throws BufferBoundsException
Throws:
BufferBoundsException

getFloat32

float getFloat32(int index)
                 throws BufferBoundsException
Throws:
BufferBoundsException

getDouble64

double getDouble64(int index)
                   throws BufferBoundsException
Throws:
BufferBoundsException

getBytes

byte[] getBytes(int index,
                int count)
                throws BufferBoundsException
Throws:
BufferBoundsException

getString

String getString(int index,
                 int bytesRequested)
                 throws BufferBoundsException
Throws:
BufferBoundsException

getString

String getString(int index,
                 int bytesRequested,
                 String charset)
                 throws BufferBoundsException
Throws:
BufferBoundsException

getNullTerminatedString

String getNullTerminatedString(int index,
                               int maxLengthBytes)
                               throws BufferBoundsException
Creates a String from the _data buffer starting at the specified index, and ending where byte=='\0' or where length==maxLength.

Parameters:
index - 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.
Returns:
The read string.
Throws:
BufferBoundsException - The buffer does not contain enough bytes to satisfy this request.


Copyright © 2012. All Rights Reserved.