|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.iris.dmc.seedcodec.Utility
public class Utility
Generic class providing static methods for converting between integer numbers and byte arrays.
Constructor Summary | |
---|---|
Utility()
|
Method Summary | |
---|---|
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 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utility()
Method Detail |
---|
public static short bytesToShort(byte a, byte b, boolean swapBytes)
a
- high order byteb
- low order byteswapBytes
- reverse the roles of the first two parameters
public static int bytesToInt(byte a)
a
- signed byte value
public static int bytesToInt(byte a, byte b, boolean swapBytes)
a
- high order byteb
- low order byteswapBytes
- byte order swap flag
public 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 flag
public 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 flag
edu.iris.Fissures.seed.util.Utility#uBytesToLong(byte,byte,byte,byte,boolean)
public static int uBytesToInt(byte a)
a
- unsigned byte value
public 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 byte
public 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,d
public static byte[] longToIntBytes(long a)
a
- long integer
public static byte[] intToShortBytes(int a)
a
- int value
public 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 array
public static byte[] format(byte[] source, int start, int end)
source
- source byte arraystart
- starting index, inclusiveend
- ending index, exclusive
public static void main(java.lang.String[] args)
args
- not used.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |