Package com.reportmill.base
Class RMDataReader
- java.lang.Object
-
- com.reportmill.base.RMDataReader
-
public class RMDataReader extends java.lang.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
All Methods Static Methods Instance Methods Concrete Methods 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[]
bytes()
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.static RMDataReader
getReader(java.lang.Object aSource)
Returns a data reader from the given source File, String path, InputStream, byte[], etc.static RMDataReader
getReader(java.lang.Object aSource, int offset, int length)
Returns a data reader from the given source File, String path, InputStream, byte[], etc.int
length()
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
littleUShortAtIndex(int index)
Returns the little endian unsigned short at the given byte index.int
offset()
Returns the offset of the bytes for the reader.byte[]
toByteArray()
Returns a byte array for the reader.byte[]
toByteArray(int start, int end)
Returns a byte array for the reader.java.lang.String
toString()
Returns the reader's bytes as a string.java.lang.String
toString(int start, int end, java.lang.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.
-
-
-
Method Detail
-
getReader
public static RMDataReader getReader(java.lang.Object aSource)
Returns a data reader from the given source File, String path, InputStream, byte[], etc.
-
getReader
public static RMDataReader getReader(java.lang.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 java.lang.String toString()
Returns the reader's bytes as a string.- Overrides:
toString
in classjava.lang.Object
-
toString
public java.lang.String toString(int start, int end, java.lang.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.
-
-