Save This Page
Home » poi-src-3.2-FINAL-20081019 » org.apache » poi » util » [javadoc | source]
org.apache.poi.util
public class: LittleEndian [javadoc | source]
java.lang.Object
   org.apache.poi.util.LittleEndian

All Implemented Interfaces:
    LittleEndianConsts

a utility class for handling little-endian numbers, which the 80x86 world is replete with. The methods are all static, and input/output is from/to byte arrays, or from InputStreams.
Nested Class Summary:
public static class  LittleEndian.BufferUnderrunException  Exception to handle buffer underruns 
Method from org.apache.poi.util.LittleEndian Summary:
getByteArray,   getDouble,   getDouble,   getInt,   getInt,   getLong,   getLong,   getShort,   getShort,   getShortArray,   getSimpleShortArray,   getUInt,   getUInt,   getULong,   getUShort,   getUShort,   getUnsignedByte,   getUnsignedByte,   putByte,   putDouble,   putDouble,   putInt,   putInt,   putLong,   putLong,   putShort,   putShort,   putShortArray,   putUShort,   readFromStream,   readInt,   readLong,   readShort,   ubyteToInt
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.poi.util.LittleEndian Detail:
 public static byte[] getByteArray(byte[] data,
    int offset,
    int size) 
    Copy a portion of a byte array
 public static double getDouble(byte[] data) 
    get a double value from the beginning of a byte array
 public static double getDouble(byte[] data,
    int offset) 
    get a double value from a byte array, reads it in little endian format then converts the resulting revolting IEEE 754 (curse them) floating point number to a happy java double
 public static int getInt(byte[] data) 
    get an int value from the beginning of a byte array
 public static int getInt(byte[] data,
    int offset) 
    get an int value from a byte array
 public static long getLong(byte[] data) 
    get a long value from the beginning of a byte array
 public static long getLong(byte[] data,
    int offset) 
    get a long value from a byte array
 public static short getShort(byte[] data) 
    get a short value from the beginning of a byte array
 public static short getShort(byte[] data,
    int offset) 
    get a short value from a byte array
 public static short[] getShortArray(byte[] data,
    int offset) 
    get a short array from a byte array. The short array is assumed to start with a word describing the length of the array.
 public static short[] getSimpleShortArray(byte[] data,
    int offset,
    int size) 
    get a short array from a byte array.
 public static long getUInt(byte[] data) 
    get an unsigned int value from a byte array
 public static long getUInt(byte[] data,
    int offset) 
    get an unsigned int value from a byte array
 public static long getULong(byte[] data,
    int offset) 

    Gets an unsigned int value (8 bytes) from a byte array.

 public static int getUShort(byte[] data) 
    get an unsigned short value from the beginning of a byte array
 public static int getUShort(byte[] data,
    int offset) 
    get an unsigned short value from a byte array
 public static int getUnsignedByte(byte[] data) 
    get the unsigned value of a byte.
 public static int getUnsignedByte(byte[] data,
    int offset) 
    get the unsigned value of a byte.
 public static  void putByte(byte[] data,
    int offset,
    int value) 
    executes:

    data[offset] = (byte)value;

    Added for consistency with other put~() methods
 public static  void putDouble(byte[] data,
    double value) 
    put a double value into beginning of a byte array
 public static  void putDouble(byte[] data,
    int offset,
    double value) 
    put a double value into a byte array
 public static  void putInt(byte[] data,
    int value) 
    put an int value into beginning of a byte array
 public static  void putInt(byte[] data,
    int offset,
    int value) 
    put an int value into a byte array
 public static  void putLong(byte[] data,
    long value) 
    put a long value into beginning of a byte array
 public static  void putLong(byte[] data,
    int offset,
    long value) 
    put a long value into a byte array
 public static  void putShort(byte[] data,
    short value) 
    put a short value into beginning of a byte array
 public static  void putShort(byte[] data,
    int offset,
    short value) 
    put a short value into a byte array
 public static  void putShortArray(byte[] data,
    int offset,
    short[] value) 
    put a array of shorts into a byte array
 public static  void putUShort(byte[] data,
    int offset,
    int value) 
    put an unsigned short value into a byte array
 public static byte[] readFromStream(InputStream stream,
    int size) throws IOException, LittleEndian.BufferUnderrunException 
    Read the appropriate number of bytes from the stream and return them to the caller.

    However, for the purposes of the POI project, this risk is deemed negligible. It is, however, so noted.

 public static int readInt(InputStream stream) throws IOException, LittleEndian.BufferUnderrunException 
    get an int value from an InputStream
 public static long readLong(InputStream stream) throws IOException, LittleEndian.BufferUnderrunException 
    get a long value from an InputStream
 public static short readShort(InputStream stream) throws IOException, LittleEndian.BufferUnderrunException 
    get a short value from an InputStream
 public static int ubyteToInt(byte b) 
    Convert an 'unsigned' byte to an integer. ie, don't carry across the sign.