Maven module :un.api : api-encoding :
Class : un.api.io.DataInputStream
Extends/Implements : un.api.io.WrapInputStream
Subclasses : -

ByteInputStream handling number parsing in big or little endian.
author  Johann Sorel


Variables : LEFT_TO_RIGHT, RIGHT_TO_LEFT, encoding, bitDirection
Functions : DataInputStream, DataInputStream, getByteOffset, getEncoding, setEncoding, getBitsDirection, setBitsDirection, read, getBitOffset, readBits, readBits, readBits, readBits, readSignedBits, readSignedBits, read, readFully, readFully, readFully, readFully, skip, skipFully, skipToByteEnd, readByte, readUByte, readUByte, readUByte, readUByte, readShort, readShort, readShort, readShort, readShort, readShort, readShort, readShort, readUShort, readUShort, readUShort, readUShort, readUShort, readUShort, readUShort, readUShort, readInt24, readInt24, readInt24, readInt24, readInt24, readInt24, readInt24, readInt24, readUInt24, readUInt24, readUInt24, readUInt24, readUInt24, readUInt24, readUInt24, readUInt24, readInt, readInt, readInt, readInt, readInt, readInt, readInt, readInt, readUInt, readUInt, readUInt, readUInt, readUInt, readUInt, readUInt, readUInt, readVarLengthInt, readLong, readLong, readLong, readLong, readLong, readLong, readLong, readLong, readFloat, readFloat, readFloat, readFloat, readFloat, readFloat, readFloat, readFloat, readDouble, readDouble, readDouble, readDouble, readDouble, readDouble, readDouble, readDouble, readZeroTerminatedChars, readBlockZeroTerminatedChars, readBlockZeroTerminatedChars, realign, close



Indicate to read bit starting from the left most bit */
public int LEFT_TO_RIGHT


Indicate to read bit starting from the right most bit */
public int RIGHT_TO_LEFT

protected NumberEncoding encoding

protected int bitDirection



Create a DatainputStream with big endian number encoding.
param  in
public void DataInputStream (ByteInputStream in)

public void DataInputStream (ByteInputStream in, NumberEncoding encoding)

public long getByteOffset ()


Get default stream encoding.
return
public NumberEncoding getEncoding ()


Set default stream encoding
param  encoding
public void setEncoding (NumberEncoding encoding)


Get default bits direction.
return
public int getBitsDirection ()


Set default bits direction.
param  bitDirection
public void setBitsDirection (int bitDirection)

public int read ()


return  current bit offset, between 0 and 8.
public int getBitOffset ()


Read given number of bits, interpreted as int.
param  nbBits
return  int
throws  IOException
public int readBits (int nbBits)


Read given number of bits, interpreted as int.
param  nbBits : number of bits to read
param  startOrder : LEFT_TO_RIGHT or RIGHT_TO_LEFT
return  int
throws  IOException
public int readBits (int nbBits, int startOrder)

public int[] readBits (int[] buffer, int nbBits)

public int[] readBits (int[] buffer, int offset, int length, int nbBits)


Read given number of bits, the first bit is interpreted as the sign.
param  nbBits : number of bits to read
return  int
throws  IOException
public int readSignedBits (int nbBits)


Read given number of bits, the first bit is interpreted as the sign.
param  nbBits : number of bits to read
param  startOrder : LEFT_TO_RIGHT or RIGHT_TO_LEFT
return  int
throws  IOException
public int readSignedBits (int nbBits, int startOrder)

public int read (byte buffer, int offset, int length)

public byte[] readFully (byte[] buffer)

public byte[] readFully (byte[] buffer, int offset, int length)

public void readFully (Buffer buffer)

public void readFully (Buffer buffer, int offset, int length)

public long skip (long n)


Skip n bytes, do not return until the requested number of
bytes has been read.
param  length number of bytes to skip.
throws  IOException
public void skipFully (long length)


Skip remaining bits in current byte.
If the current bit offset is 0 this method does not skip the byte.
return  true if some bits have been skipped
public boolean skipToByteEnd ()

public byte readByte ()

public int readUByte ()

public int[] readUByte (int nb)

public int[] readUByte (int[] buffer)

public int[] readUByte (int[] buffer, int offset, int length)

public short readShort ()

public short readShort (NumberEncoding encoding)

public short[] readShort (int nb)

public short[] readShort (int nb, NumberEncoding encoding)

public short[] readShort (short[] buffer)

public short[] readShort (short[] buffer, int offset, int length)

public short[] readShort (short[] buffer, NumberEncoding encoding)

public short[] readShort (short[] buffer, int offset, int length, NumberEncoding encoding)

public int readUShort ()

public int readUShort (NumberEncoding encoding)

public int[] readUShort (int nb)

public int[] readUShort (int nb, NumberEncoding encoding)

public int[] readUShort (int[] buffer)

public int[] readUShort (int[] buffer, int offset, int length)

public int[] readUShort (int[] buffer, NumberEncoding encoding)

public int[] readUShort (int[] buffer, int offset, int length, NumberEncoding encoding)

public int readInt24 ()

public int readInt24 (NumberEncoding encoding)

public int[] readInt24 (int nb)

public int[] readInt24 (int nb, NumberEncoding encoding)

public int[] readInt24 (int[] buffer)

public int[] readInt24 (int[] buffer, int offset, int length)

public int[] readInt24 (int[] buffer, NumberEncoding encoding)

public int[] readInt24 (int[] buffer, int offset, int length, NumberEncoding encoding)

public int readUInt24 ()

public int readUInt24 (NumberEncoding encoding)

public int[] readUInt24 (int nb)

public int[] readUInt24 (int nb, NumberEncoding encoding)

public int[] readUInt24 (int[] buffer)

public int[] readUInt24 (int[] buffer, int offset, int length)

public int[] readUInt24 (int[] buffer, NumberEncoding encoding)

public int[] readUInt24 (int[] buffer, int offset, int length, NumberEncoding encoding)

public int readInt ()

public int readInt (NumberEncoding encoding)

public int[] readInt (int nb)

public int[] readInt (int nb, NumberEncoding encoding)

public int[] readInt (int[] buffer)

public int[] readInt (int[] buffer, int offset, int length)

public int[] readInt (int[] buffer, NumberEncoding encoding)

public int[] readInt (int[] buffer, int offset, int length, NumberEncoding encoding)

public long readUInt ()

public long readUInt (NumberEncoding encoding)

public long[] readUInt (int nb)

public long[] readUInt (int nb, NumberEncoding encoding)

public long[] readUInt (long[] buffer)

public long[] readUInt (long[] buffer, int offset, int length)

public long[] readUInt (long[] buffer, NumberEncoding encoding)

public long[] readUInt (long[] buffer, int offset, int length, NumberEncoding encoding)


Read a vayring length int.
This is a commun method used to compress integer values.
The first bit of each byte indicate if the value continue on the next byte.
The 7 new bits contain the value.
There can be up to 5 bytes.
return  int
throws  IOException
public int readVarLengthInt ()

public long readLong ()

public long readLong (NumberEncoding encoding)

public long[] readLong (int nb)

public long[] readLong (int nb, NumberEncoding encoding)

public long[] readLong (long[] buffer)

public long[] readLong (long[] buffer, int offset, int length)

public long[] readLong (long[] buffer, NumberEncoding encoding)

public long[] readLong (long[] buffer, int offset, int length, NumberEncoding encoding)

public float readFloat ()

public float readFloat (NumberEncoding encoding)

public float[] readFloat (int nb)

public float[] readFloat (int nb, NumberEncoding encoding)

public float[] readFloat (float[] buffer)

public float[] readFloat (float[] buffer, int offset, int length)

public float[] readFloat (float[] buffer, NumberEncoding encoding)

public float[] readFloat (float[] buffer, int offset, int length, NumberEncoding encoding)

public double readDouble ()

public double readDouble (NumberEncoding encoding)

public double[] readDouble (int nb)

public double[] readDouble (int nb, NumberEncoding encoding)

public double[] readDouble (double[] buffer)

public double[] readDouble (double[] buffer, int offset, int length)

public double[] readDouble (double[] buffer, NumberEncoding encoding)

public double[] readDouble (double[] buffer, int offset, int length, NumberEncoding encoding)


Zero terminated string are common in most format.
param  maxSize : maximum size , 0 for no size limit
param  encoding : expected characters encoding
return  Chars
throws  IOException
public Chars readZeroTerminatedChars (int maxSize, CharEncoding encoding)


Zero terminated string are common in most format.
To obtain a constant size in some parts like header, string may be defined
in a given maximum number of bytes, if the string to not fill the max size
then 0 bytes are used.
param  blockSize : string block size
param  encoding : expected characters encoding
return  Chars
throws  IOException
public Chars readBlockZeroTerminatedChars (int blockSize, CharEncoding encoding)


Zero terminated string are common in most format.
To obtain a constant size in some parts like header, string may be defined
in a given maximum number of bytes, if the string to not fill the max size
then 0 bytes are used.
param  blockSize : string block size
param  encoding : expected characters encoding
param  validate : trim out any unfinished character.
return  Chars
throws  IOException
public Chars readBlockZeroTerminatedChars (int blockSize, CharEncoding encoding, boolean validate)


Align the stream, skip any bytes needed to match alignement value.
This method moves the cursor forward if needed.
param  alignByteSize
return
throws  un.api.io.IOException
public int realign (int alignByteSize)

public void close ()