public final class ByteArrayUnmarshaller
extends java.lang.Object
With sign extensions enabled, the marshalled data is interpreted as signed
and the data will be appropriately converted into the return type container.
With sign extensions disabled, unfilled bits in the container will be set to
zero. For example, -1
as one signed byte is 0xFF
.
Using readShort
with signExtend
true, the resultant
short will contain 0xFFFF
, which is -1
in Java's
signed format. With signExtend
false, the resultant short will
contain 0x00FF
, which is 255
.
Modifier and Type | Method and Description |
---|---|
static double |
readDouble(byte[] byteArray,
int offset,
boolean bigEndian)
Returns a double value copied from eight consecutive bytes of the byte
array starting at the offset.
|
static float |
readFloat(byte[] byteArray,
int offset,
boolean bigEndian)
Returns a float value copied from four consecutive bytes of the byte
array starting at the offset.
|
static int |
readInt(byte[] byteArray,
int offset,
boolean bigEndian)
Returns an int value copied from four consecutive bytes starting at the
offset.
|
static int |
readInt(byte[] byteArray,
int offset,
boolean bigEndian,
int numBytes,
boolean signExtend)
Returns an int value copied from zero to four consecutive bytes of the
byte array starting at the offset.
|
static long |
readLong(byte[] byteArray,
int offset,
boolean bigEndian)
Returns a long value copied from eight consecutive bytes of the byte
array starting at the offset.
|
static long |
readLong(byte[] byteArray,
int offset,
boolean bigEndian,
int numBytes,
boolean signExtend)
Returns a long value copied from zero to eight consecutive bytes of the
byte array starting at the offset.
|
static short |
readShort(byte[] byteArray,
int offset,
boolean bigEndian)
Returns a short value copied from two consecutive bytes of the byte array
starting at the offset.
|
static short |
readShort(byte[] byteArray,
int offset,
boolean bigEndian,
int numBytes,
boolean signExtend)
Returns a short value copied from zero to two consecutive bytes of the
byte array starting at the offset.
|
public static short readShort(byte[] byteArray, int offset, boolean bigEndian)
byteArray
- sourceoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian)
orderjava.lang.NullPointerException
- if byteArray
is nulljava.lang.ArrayIndexOutOfBoundsException
- if an invalid array access occurspublic static short readShort(byte[] byteArray, int offset, boolean bigEndian, int numBytes, boolean signExtend)
byteArray
- sourceoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian)
ordernumBytes
- the number of bytes to unmarshall, must be 0-2 inclusivesignExtend
- if true and numBytes < 2
then the topmost
bytes of the returned short will be sign extendedjava.lang.NullPointerException
- if byteArray
is nulljava.lang.IllegalArgumentException
- if numBytes < 0
or
numBytes > 2
java.lang.ArrayIndexOutOfBoundsException
- if an invalid array access occurspublic static int readInt(byte[] byteArray, int offset, boolean bigEndian)
byteArray
- sourceoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian)
orderjava.lang.NullPointerException
- if byteArray is nulljava.lang.ArrayIndexOutOfBoundsException
- if an invalid array access occurspublic static int readInt(byte[] byteArray, int offset, boolean bigEndian, int numBytes, boolean signExtend)
byteArray
- sourceoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian)
ordernumBytes
- the number of bytes to unmarshall, must be 0-4 inclusivesignExtend
- if true and numBytes < 4
then the topmost
bytes of the returned int will be sign extendedjava.lang.NullPointerException
- if byteArray
is nulljava.lang.IllegalArgumentException
- if numBytes < 0
or
numBytes > 4
java.lang.ArrayIndexOutOfBoundsException
- if an invalid array access occurspublic static long readLong(byte[] byteArray, int offset, boolean bigEndian)
byteArray
- sourceoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian)
orderjava.lang.NullPointerException
- if byteArray
is nulljava.lang.ArrayIndexOutOfBoundsException
- if an invalid array access occurspublic static long readLong(byte[] byteArray, int offset, boolean bigEndian, int numBytes, boolean signExtend)
byteArray
- sourceoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian)
ordernumBytes
- the number of bytes to unmarshall, must be 0-8 inclusivesignExtend
- if true and numBytes < 8
then the topmost
bytes of the returned long will be sign extendedjava.lang.NullPointerException
- if byteArray
is nulljava.lang.IllegalArgumentException
- if numBytes < 0
or
numBytes > 8
java.lang.ArrayIndexOutOfBoundsException
- if an invalid array access occurspublic static float readFloat(byte[] byteArray, int offset, boolean bigEndian)
byteArray
- sourceoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian)
orderjava.lang.NullPointerException
- if byteArray
is nulljava.lang.ArrayIndexOutOfBoundsException
- if an invalid array access occurspublic static double readDouble(byte[] byteArray, int offset, boolean bigEndian)
byteArray
- sourceoffset
- offset in the byte arraybigEndian
- if false the bytes will be copied in reverse (little endian)
orderjava.lang.NullPointerException
- if byteArray
is nulljava.lang.ArrayIndexOutOfBoundsException
- if an invalid array access occursEclipse OpenJ9 website.
To raise a bug report or suggest an improvement create an Eclipse OpenJ9 issue.
Copyright © 2013, 2025 IBM Corp. and others.