micromod
Class DataReader

java.lang.Object
  extended bymicromod.DataReader

public class DataReader
extends java.lang.Object

The DataReader contains methods to convert data on an implementation of DataInput into a more useful format. DataInput is only used to read bytes and arrays of bytes to aid portability.


Field Summary
protected static int CONVERT_BUFFER_SIZE
           
protected  byte[] convertBuffer
           
protected  java.io.DataInput input
           
 
Constructor Summary
DataReader(java.io.DataInput input)
          Constructor
 
Method Summary
static int readInt32(java.io.DataInput input)
          Read a signed 32 bit integer.
static short readSigned16Bit(java.io.DataInput input)
          Read a single signed 16 bit word.
 void readSigned16BitArray(short[] array, int offset, int length)
          Read length 16 bit signed, big endian words from the DataInput device into the specified array.
static byte readSigned8Bit(java.io.DataInput input)
          Read a single signed byte.
static void readSigned8BitArray(java.io.DataInput input, byte[] array, int offset, int length)
          Read length 8 bit signed words from the DataInput device into the specified array.
static java.lang.String readText(java.io.DataInput input, int count)
          Simple method to read ASCII text and convert nulls to spaces.
static int readUnsigned16Bit(java.io.DataInput input)
          Read a single unsigned 16 bit word.
static byte readUnsigned7Bit(java.io.DataInput input)
          Read a positive number from a byte between 0 and 127.
static int readUnsigned8Bit(java.io.DataInput input)
          Read a single unsigned byte.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONVERT_BUFFER_SIZE

protected static final int CONVERT_BUFFER_SIZE
See Also:
Constant Field Values

convertBuffer

protected byte[] convertBuffer

input

protected java.io.DataInput input
Constructor Detail

DataReader

public DataReader(java.io.DataInput input)
Constructor

Method Detail

readSigned16BitArray

public void readSigned16BitArray(short[] array,
                                 int offset,
                                 int length)
                          throws java.io.IOException
Read length 16 bit signed, big endian words from the DataInput device into the specified array.

Throws:
java.io.IOException

readInt32

public static int readInt32(java.io.DataInput input)
                     throws java.io.IOException
Read a signed 32 bit integer.

Throws:
java.io.IOException

readUnsigned7Bit

public static byte readUnsigned7Bit(java.io.DataInput input)
                             throws java.io.IOException
Read a positive number from a byte between 0 and 127.

Throws:
java.io.IOException

readSigned8Bit

public static byte readSigned8Bit(java.io.DataInput input)
                           throws java.io.IOException
Read a single signed byte.

Throws:
java.io.IOException

readUnsigned8Bit

public static int readUnsigned8Bit(java.io.DataInput input)
                            throws java.io.IOException
Read a single unsigned byte.

Throws:
java.io.IOException

readSigned8BitArray

public static void readSigned8BitArray(java.io.DataInput input,
                                       byte[] array,
                                       int offset,
                                       int length)
                                throws java.io.IOException
Read length 8 bit signed words from the DataInput device into the specified array.

Throws:
java.io.IOException

readSigned16Bit

public static short readSigned16Bit(java.io.DataInput input)
                             throws java.io.IOException
Read a single signed 16 bit word.

Throws:
java.io.IOException

readUnsigned16Bit

public static int readUnsigned16Bit(java.io.DataInput input)
                             throws java.io.IOException
Read a single unsigned 16 bit word.

Throws:
java.io.IOException

readText

public static java.lang.String readText(java.io.DataInput input,
                                        int count)
                                 throws java.io.IOException
Simple method to read ASCII text and convert nulls to spaces.

Throws:
java.io.IOException