public class CASAFileUtilities extends Object
Copyright: Copyright 2003-2014, Knowledge Science Group, University of Calgary. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The Knowledge Science Group makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Modifier and Type | Field and Description |
---|---|
protected static int |
INT_BYTE_MASK
A mask for the lower 8 bits of a Java int.
|
protected static long |
LONG_BYTE_MASK
A mask for the lower 8 bits of a Java long.
|
static int |
MAX_UNSIGNED_INT
The maximum unsigned 16 bit value.
|
static long |
MAX_UNSIGNED_LONG
The maximum unsigned 32 bit value.
|
static short |
MAX_UNSIGNED_SHORT
The maximum unsigned 8 bit value.
|
Constructor and Description |
---|
CASAFileUtilities() |
Modifier and Type | Method and Description |
---|---|
static byte |
toByte(short aValue)
Convert a short (16 bit value in Java) to an unsigned 8 bit representation in 1 byte.
|
static byte[] |
toByteArray(int[] data)
Convert an int array to a byte array.
|
static byte[] |
toByteArray(int[] data,
int start,
int length)
Convert an int array to a byte array.
|
static byte[] |
toBytes(int aValue)
Convert an int (32 bit value in Java) to an unsigned 16 bit representation in 2 bytes.
|
static byte[] |
toBytes(long aValue)
Convert a long (64 bit value in Java) to an unsigned 32 bit representation in 4 bytes.
|
static byte[] |
toBytes(short aValue)
Convert a short (16 bit value in Java) to an unsigned 8 bit representation in 1 byte.
|
static int |
toInt(byte[] bytes)
Convert 2 bytes to an int (interpret 2 bytes as an UNSIGNED integer value).
|
static int |
toInt(byte[] bytes,
int start)
Convert 2 bytes to an int (interpret 2 bytes as an UNSIGNED integer value).
|
static int[] |
toIntArray(byte[] data)
Convert a byte array to an int array.
|
static int[] |
toIntArray(byte[] data,
int start,
int length)
Convert a byte array to an int array.
|
static long |
toLong(byte[] bytes)
Convert 4 bytes to an int (interpret 4 bytes as an UNSIGNED long value).
|
static long |
toLong(byte[] bytes,
int start)
Convert 4 bytes to an int (interpret 4 bytes as an UNSIGNED long value).
|
static short |
toShort(byte aByte)
Convert 1 byte to a short (interpret 1 byte as an UNSIGNED short value).
|
static short |
toShort(byte[] bytes)
Convert 1 byte to a short (interpret 1 byte as an UNSIGNED short value).
|
static short |
toShort(byte[] bytes,
int start)
Convert 1 byte to a short (interpret 1 byte as an UNSIGNED short value).
|
static void |
toStream(PrintStream out,
byte[] bytes)
Dump out bytes in a nicely formatted hex value format to the supplied stream.
|
static void |
toStream(PrintStream out,
byte[] bytes,
int startIndex,
int endIndex)
Dump out bytes in a nicely formatted hex value format to the supplied stream.
|
public static final long MAX_UNSIGNED_LONG
public static final int MAX_UNSIGNED_INT
public static final short MAX_UNSIGNED_SHORT
protected static final long LONG_BYTE_MASK
protected static final int INT_BYTE_MASK
public static byte[] toBytes(long aValue)
public static byte[] toBytes(int aValue)
public static byte[] toBytes(short aValue)
public static byte toByte(short aValue)
public static long toLong(byte[] bytes)
ArrayIndexOutOfBoundsException
- if not 4 bytes in arraypublic static long toLong(byte[] bytes, int start)
ArrayIndexOutOfBoundsException
- if not 4 bytes in arraypublic static int toInt(byte[] bytes)
ArrayIndexOutOfBoundsException
- if not 2 bytes in arraypublic static int toInt(byte[] bytes, int start)
ArrayIndexOutOfBoundsException
- if not 2 bytes in arraypublic static short toShort(byte[] bytes)
ArrayIndexOutOfBoundsException
- if empty arraypublic static short toShort(byte[] bytes, int start)
ArrayIndexOutOfBoundsException
- if empty arraypublic static short toShort(byte aByte)
public static void toStream(PrintStream out, byte[] bytes)
public static void toStream(PrintStream out, byte[] bytes, int startIndex, int endIndex)
public static byte[] toByteArray(int[] data)
public static byte[] toByteArray(int[] data, int start, int length)
public static int[] toIntArray(byte[] data)
public static int[] toIntArray(byte[] data, int start, int length)