util
Class Util

java.lang.Object
  extended by util.Util

public final class Util
extends java.lang.Object

Offers static methods for converting data types (which are of general use, but not offered by the java API).

Author:
Karl-Peter Fuchs

Constructor Summary
private Util()
          Empty constructor.
 
Method Summary
static int byteArrayToInt(byte[] byteArray)
          Converts the bypassed byte array to an int value.
static long byteArrayToLong(byte[] byteArray)
          Converts the bypassed byte array to a long value.
static int byteArrayToShort(byte[] byteArray)
          Converts the bypassed byte array to a short value.
static byte[] intToByteArray(int source)
          Converts the bypassed int value to a byte array.
static byte[] longToByteArray(long source)
          Converts the bypassed long value to a byte array.
static byte[] mergeArrays(byte[] firstArray, byte[] secondArray)
          Merges the bypassed byte arrays (secondArray is appended to firstArray).
static byte[] shortToByteArray(int source)
          Converts the bypassed short value to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

private Util()
Empty constructor. Never used since all methods are static.

Method Detail

longToByteArray

public static byte[] longToByteArray(long source)
Converts the bypassed long value to a byte array.

Parameters:
source - The long value to be translated.
Returns:
Byte array representation of the bypassed long value.

byteArrayToLong

public static long byteArrayToLong(byte[] byteArray)
Converts the bypassed byte array to a long value.

Parameters:
byteArray - The byte array to be translated.
Returns:
"long" representation of the bypassed byte array.

intToByteArray

public static byte[] intToByteArray(int source)
Converts the bypassed int value to a byte array.

Parameters:
source - The int value to be translated.
Returns:
Byte array representation of the bypassed int value.

byteArrayToInt

public static int byteArrayToInt(byte[] byteArray)
Converts the bypassed byte array to an int value.

Parameters:
byteArray - The byte array to be translated.
Returns:
"int" representation of the bypassed byte array.

shortToByteArray

public static byte[] shortToByteArray(int source)
Converts the bypassed short value to a byte array.

Parameters:
source - The short value to be translated.
Returns:
Byte array representation of the bypassed short value.

byteArrayToShort

public static int byteArrayToShort(byte[] byteArray)
Converts the bypassed byte array to a short value.

Parameters:
byteArray - The byte array to be translated.
Returns:
"short" representation of the bypassed byte array.

mergeArrays

public static byte[] mergeArrays(byte[] firstArray,
                                 byte[] secondArray)
Merges the bypassed byte arrays (secondArray is appended to firstArray).

Parameters:
firstArray - Array to be extended.
secondArray - Array to be appended.
Returns:
Merged array.