public class Utility
extends java.lang.Object
Constructor and Description |
---|
Utility() |
Modifier and Type | Method and Description |
---|---|
static int |
bytesToInt(byte a)
Convert a single byte to a 32-bit int, with sign extension.
|
static int |
bytesToInt(byte a,
byte b,
boolean swapBytes)
Concatenate two bytes to a 32-bit int value.
|
static int |
bytesToInt(byte a,
byte b,
byte c,
boolean swapBytes)
Concatenate three bytes to a 32-bit int value.
|
static int |
bytesToInt(byte a,
byte b,
byte c,
byte d,
boolean swapBytes)
Concatenate four bytes to a 32-bit int value.
|
static long |
bytesToLong(byte a,
byte b,
byte c,
byte d,
byte e,
byte f,
byte g,
byte h,
boolean swapBytes)
Concatenate eight bytes to a 64-bit int value.
|
static short |
bytesToShort(byte a,
byte b,
boolean swapBytes)
Concatenate two bytes to a short integer value.
|
static byte[] |
format(byte[] source,
int start,
int end)
Return a byte array which is a subset of bytes from source
beginning with index start and stopping just before index
end.
|
static byte[] |
intToShortBytes(int a)
Convert an int value to a 2-byte array.
|
static byte[] |
longToIntBytes(long a)
Convert a long value to a 4-byte array.
|
static void |
main(java.lang.String[] args)
Test method.
|
static byte[] |
pad(byte[] source,
int requiredBytes,
byte paddingByte)
Return a byte array of length requiredBytes that contains the
contents of source and is padded on the end with paddingByte.
|
static int |
uBytesToInt(byte a)
Treat byte value as an unsigned value and convert to a 32-bit int value.
|
static int |
uBytesToInt(byte a,
byte b,
boolean swapBytes)
Conatenate two unsigned byte values into a 32-bit integer.
|
static long |
uBytesToLong(byte a,
byte b,
byte c,
byte d,
boolean swapBytes)
Conacatenate four unsigned byte values into a long integer.
|
public static short bytesToShort(byte a, byte b, boolean swapBytes)
a
- high order byteb
- low order byteswapBytes
- reverse the roles of the first two parameterspublic static int bytesToInt(byte a)
a
- signed byte valuepublic static int bytesToInt(byte a, byte b, boolean swapBytes)
a
- high order byteb
- low order byteswapBytes
- byte order swap flagpublic static int bytesToInt(byte a, byte b, byte c, boolean swapBytes)
a
- highest order byteb
- second-highest order bytec
- lowest order byteswapBytes
- byte order swap flagpublic static int bytesToInt(byte a, byte b, byte c, byte d, boolean swapBytes)
a
- highest order byteb
- second-highest order bytec
- second-lowest order byted
- lowest order byteswapBytes
- byte order swap flagedu.iris.Fissures.seed.util.Utility#uBytesToLong(byte,byte,byte,byte,boolean)
public static long bytesToLong(byte a, byte b, byte c, byte d, byte e, byte f, byte g, byte h, boolean swapBytes)
a
- highest order byteb
- second-highest order bytec
- next order byted
- next order bytee
- next order bytef
- next order byteg
- next order byteh
- lowest order byteswapBytes
- byte order swap flagedu.iris.Fissures.seed.util.Utility#uBytesToLong(byte,byte,byte,byte,boolean)
public static int uBytesToInt(byte a)
a
- unsigned byte valuepublic static int uBytesToInt(byte a, byte b, boolean swapBytes)
a
- high order unsigned byteb
- low order unsigned byteswapBytes
- if true, b becomes the high order bytepublic static long uBytesToLong(byte a, byte b, byte c, byte d, boolean swapBytes)
a
- highest-order byteb
- second-highest order bytec
- second-lowest order byted
- lowest order byteswapBytes
- if true, byte order is d,c,b,a, else order is
a,b,c,dpublic static byte[] longToIntBytes(long a)
a
- long integerpublic static byte[] intToShortBytes(int a)
a
- int valuepublic static byte[] pad(byte[] source, int requiredBytes, byte paddingByte)
source
- byte array to have paddingByte(s) appended torequiredBytes
- the length in bytes of the returned byte arraypaddingByte
- the byte value that will be appended to the array to
fill out the required byte size of the return arraypublic static byte[] format(byte[] source, int start, int end)
source
- source byte arraystart
- starting index, inclusiveend
- ending index, exclusivepublic static void main(java.lang.String[] args)
args
- not used.