Package mil.nga.tiff.io
Class ByteReader
- java.lang.Object
-
- mil.nga.tiff.io.ByteReader
-
public class ByteReader extends Object
Read through a byte array- Author:
- osbornb
-
-
Constructor Summary
Constructors Constructor Description ByteReader(byte[] bytes)
ConstructorByteReader(byte[] bytes, ByteOrder byteOrder)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
byteLength()
Get the byte lengthByteOrder
getByteOrder()
Get the byte orderint
getNextByte()
Get the next byte to be readboolean
hasByte()
Check if there is at least one more byte left to readboolean
hasByte(int offset)
Check if there is at least one more byte left to readboolean
hasBytes(int count)
Check if there are the provided number of bytes left to readboolean
hasBytes(int offset, int count)
Check if there are the provided number of bytes left to readbyte
readByte()
Read a bytebyte
readByte(int offset)
Read a bytebyte[]
readBytes(int num)
Read a number of bytesbyte[]
readBytes(int offset, int num)
Read a number of bytesdouble
readDouble()
Read a doubledouble
readDouble(int offset)
Read a doublefloat
readFloat()
Read a floatfloat
readFloat(int offset)
Read a floatint
readInt()
Read an integerint
readInt(int offset)
Read an integershort
readShort()
Read a shortshort
readShort(int offset)
Read a shortString
readString(int num)
Read a String from the provided number of bytesString
readString(int offset, int num)
Read a String from the provided number of bytesshort
readUnsignedByte()
Read an unsigned byteshort
readUnsignedByte(int offset)
Read an unsigned bytelong
readUnsignedInt()
Read an unsigned intlong
readUnsignedInt(int offset)
Read an unsigned intint
readUnsignedShort()
Read an unsigned shortint
readUnsignedShort(int offset)
Read an unsigned shortvoid
setByteOrder(ByteOrder byteOrder)
Set the byte ordervoid
setNextByte(long nextByte)
Set the next byte to be read
-
-
-
Constructor Detail
-
ByteReader
public ByteReader(byte[] bytes)
Constructor- Parameters:
bytes
- bytes
-
ByteReader
public ByteReader(byte[] bytes, ByteOrder byteOrder)
Constructor- Parameters:
bytes
- bytesbyteOrder
- byte order
-
-
Method Detail
-
getNextByte
public int getNextByte()
Get the next byte to be read- Returns:
- next byte to be read
-
setNextByte
public void setNextByte(long nextByte)
Set the next byte to be read- Parameters:
nextByte
- next byte
-
getByteOrder
public ByteOrder getByteOrder()
Get the byte order- Returns:
- byte order
-
setByteOrder
public void setByteOrder(ByteOrder byteOrder)
Set the byte order- Parameters:
byteOrder
- byte order
-
hasByte
public boolean hasByte()
Check if there is at least one more byte left to read- Returns:
- true more bytes left to read
-
hasByte
public boolean hasByte(int offset)
Check if there is at least one more byte left to read- Parameters:
offset
- byte offset- Returns:
- true more bytes left to read
-
hasBytes
public boolean hasBytes(int count)
Check if there are the provided number of bytes left to read- Parameters:
count
- number of bytes- Returns:
- true if has at least the number of bytes left
-
hasBytes
public boolean hasBytes(int offset, int count)
Check if there are the provided number of bytes left to read- Parameters:
offset
- byte offsetcount
- number of bytes- Returns:
- true if has at least the number of bytes left
-
readString
public String readString(int num) throws UnsupportedEncodingException
Read a String from the provided number of bytes- Parameters:
num
- number of bytes- Returns:
- String
- Throws:
UnsupportedEncodingException
- upon string encoding error
-
readString
public String readString(int offset, int num) throws UnsupportedEncodingException
Read a String from the provided number of bytes- Parameters:
offset
- byte offsetnum
- number of bytes- Returns:
- String
- Throws:
UnsupportedEncodingException
- upon string encoding error
-
readByte
public byte readByte()
Read a byte- Returns:
- byte
-
readByte
public byte readByte(int offset)
Read a byte- Parameters:
offset
- byte offset- Returns:
- byte
-
readUnsignedByte
public short readUnsignedByte()
Read an unsigned byte- Returns:
- unsigned byte as short
-
readUnsignedByte
public short readUnsignedByte(int offset)
Read an unsigned byte- Parameters:
offset
- byte offset- Returns:
- unsigned byte as short
-
readBytes
public byte[] readBytes(int num)
Read a number of bytes- Parameters:
num
- number of bytes- Returns:
- bytes
-
readBytes
public byte[] readBytes(int offset, int num)
Read a number of bytes- Parameters:
offset
- byte offsetnum
- number of bytes- Returns:
- bytes
-
readShort
public short readShort()
Read a short- Returns:
- short
-
readShort
public short readShort(int offset)
Read a short- Parameters:
offset
- byte offset- Returns:
- short
-
readUnsignedShort
public int readUnsignedShort()
Read an unsigned short- Returns:
- unsigned short as int
-
readUnsignedShort
public int readUnsignedShort(int offset)
Read an unsigned short- Parameters:
offset
- byte offset- Returns:
- unsigned short as int
-
readInt
public int readInt()
Read an integer- Returns:
- integer
-
readInt
public int readInt(int offset)
Read an integer- Parameters:
offset
- byte offset- Returns:
- integer
-
readUnsignedInt
public long readUnsignedInt()
Read an unsigned int- Returns:
- unsigned int as long
-
readUnsignedInt
public long readUnsignedInt(int offset)
Read an unsigned int- Parameters:
offset
- byte offset- Returns:
- unsigned int as long
-
readFloat
public float readFloat()
Read a float- Returns:
- float
-
readFloat
public float readFloat(int offset)
Read a float- Parameters:
offset
- byte offset- Returns:
- float
-
readDouble
public double readDouble()
Read a double- Returns:
- double
-
readDouble
public double readDouble(int offset)
Read a double- Parameters:
offset
- byte offset- Returns:
- double
-
byteLength
public int byteLength()
Get the byte length- Returns:
- byte length
-
-