Class RMDataReader

java.lang.Object
com.reportmill.base.RMDataReader

public class RMDataReader extends Object
This class helps read encoded basic data types, from a raw byte stream. Types include signed or unsigned, big-endian or little endian, chars, shorts and ints.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RMDataReader(byte[] bytes)
    Creates a data reader from the given bytes.
    RMDataReader(byte[] bytes, int offset, int length)
    Creates a data reader from the given bytes with the given offset and length.
  • Method Summary

    Modifier and Type
    Method
    Description
    short[]
    bigShortArrayAt(int index, int len)
    Returns the array of big endian shorts at the given byte index with the given length.
    short
    bigShortAtIndex(int index)
    Returns the short at the given index (assumed to be in big endian format).
    long
    bigUIntAtIndex(int index)
    Returns the big endian unsigned int at the given byte index.
    int[]
    bigUShortArrayAt(int index, int len)
    Returns the array of big endian unsigned shorts at the given byte index with the given length.
    int
    bigUShortAtIndex(int index)
    Returns the big endian unsigned short at the given byte index.
    byte
    byteAt(int index)
    Returns the specific byte at the given index.
    byte[]
    Returns the bytes.
    char[]
    charArrayAt(int index, int len)
    Returns the char array at the given byte index with the given length.
    void
    getBytes(byte[] bytes, int start, int end)
    Copies bytes from this to given byte array in given range.
    void
    getBytes(byte[] bytes, int start, int end, int destStart)
    Copies bytes from this to given byte array in given range.
    getReader(Object aSource)
    Returns a data reader from the given source File, String path, InputStream, byte[], etc.
    getReader(Object aSource, int offset, int length)
    Returns a data reader from the given source File, String path, InputStream, byte[], etc.
    int
    Returns the length of the bytes for the given reader.
    short
    littleShortAtIndex(int index)
    Returns the little endian short at the given byte index.
    long
    littleUIntAtIndex(int index)
    Returns the little endian unsigned int at the given byte index.
    int
    Returns the little endian unsigned short at the given byte index.
    int
    Returns the offset of the bytes for the reader.
    byte[]
    Returns a byte array for the reader.
    byte[]
    toByteArray(int start, int end)
    Returns a byte array for the reader.
    Returns the reader's bytes as a string.
    toString(int start, int end, String encoding)
    Returns the reader's bytes as a string in the given encoding.
    short
    ubyteAt(int index)
    Returns the specific unsigned byte at the given index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RMDataReader

      public RMDataReader(byte[] bytes)
      Creates a data reader from the given bytes.
    • RMDataReader

      public RMDataReader(byte[] bytes, int offset, int length)
      Creates a data reader from the given bytes with the given offset and length.
  • Method Details

    • getReader

      public static RMDataReader getReader(Object aSource)
      Returns a data reader from the given source File, String path, InputStream, byte[], etc.
    • getReader

      public static RMDataReader getReader(Object aSource, int offset, int length)
      Returns a data reader from the given source File, String path, InputStream, byte[], etc.
    • bytes

      public byte[] bytes()
      Returns the bytes.
    • byteAt

      public byte byteAt(int index)
      Returns the specific byte at the given index.
    • ubyteAt

      public short ubyteAt(int index)
      Returns the specific unsigned byte at the given index.
    • offset

      public int offset()
      Returns the offset of the bytes for the reader.
    • length

      public int length()
      Returns the length of the bytes for the given reader.
    • toByteArray

      public byte[] toByteArray()
      Returns a byte array for the reader.
    • toByteArray

      public byte[] toByteArray(int start, int end)
      Returns a byte array for the reader.
    • getBytes

      public void getBytes(byte[] bytes, int start, int end)
      Copies bytes from this to given byte array in given range.
    • getBytes

      public void getBytes(byte[] bytes, int start, int end, int destStart)
      Copies bytes from this to given byte array in given range.
    • toString

      public String toString()
      Returns the reader's bytes as a string.
      Overrides:
      toString in class Object
    • toString

      public String toString(int start, int end, String encoding)
      Returns the reader's bytes as a string in the given encoding.
    • bigShortAtIndex

      public short bigShortAtIndex(int index)
      Returns the short at the given index (assumed to be in big endian format).
    • bigUShortAtIndex

      public int bigUShortAtIndex(int index)
      Returns the big endian unsigned short at the given byte index.
    • littleShortAtIndex

      public short littleShortAtIndex(int index)
      Returns the little endian short at the given byte index.
    • littleUShortAtIndex

      public int littleUShortAtIndex(int index)
      Returns the little endian unsigned short at the given byte index.
    • bigUIntAtIndex

      public long bigUIntAtIndex(int index)
      Returns the big endian unsigned int at the given byte index.
    • littleUIntAtIndex

      public long littleUIntAtIndex(int index)
      Returns the little endian unsigned int at the given byte index.
    • charArrayAt

      public char[] charArrayAt(int index, int len)
      Returns the char array at the given byte index with the given length.
    • bigShortArrayAt

      public short[] bigShortArrayAt(int index, int len)
      Returns the array of big endian shorts at the given byte index with the given length.
    • bigUShortArrayAt

      public int[] bigUShortArrayAt(int index, int len)
      Returns the array of big endian unsigned shorts at the given byte index with the given length.