planet.util
Class Utilities

java.lang.Object
  extended byplanet.util.Utilities

public class Utilities
extends java.lang.Object

Offers different utilities.

Author:
Jordi Pujol, Pedro Garcia

Field Summary
static int BYTE_SIZE
          Size in bits of the byte
static int INT_AS_BYTES
          Number of bytes for any int value.
static int INT_SIZE
          Size in bits of the int
static int LONG_SIZE
          Size in bits of the long
 
Constructor Summary
Utilities()
           
 
Method Summary
static byte[] generateByteHash(java.lang.String data)
          Generate a hash code from specified data.
static int[] generateIntHash(java.lang.String data)
          Generate a hash code from specified data.
static boolean parseBoolean(java.lang.String txt)
          Parses the string argument as a boolean.
static int[] toIntArray(byte[] data)
          Change a byte array to int array
static void toIntArray(int[] dst, byte[] src)
          Copy all bytes as int values.
static int[] toIntArray(java.lang.String data)
          Change a byte array to int array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INT_SIZE

public static final int INT_SIZE
Size in bits of the int

See Also:
Constant Field Values

LONG_SIZE

public static final int LONG_SIZE
Size in bits of the long

See Also:
Constant Field Values

BYTE_SIZE

public static final int BYTE_SIZE
Size in bits of the byte

See Also:
Constant Field Values

INT_AS_BYTES

public static final int INT_AS_BYTES
Number of bytes for any int value.

See Also:
Constant Field Values
Constructor Detail

Utilities

public Utilities()
Method Detail

toIntArray

public static void toIntArray(int[] dst,
                              byte[] src)
Copy all bytes as int values.

Parameters:
dst - int[] where to copy all bytes.
src - source byte[]

toIntArray

public static int[] toIntArray(byte[] data)
Change a byte array to int array

Parameters:
data - byte array to change to int array
Returns:
int array from data

toIntArray

public static int[] toIntArray(java.lang.String data)
Change a byte array to int array

Parameters:
data - byte array to change to int array
Returns:
int array from data

generateIntHash

public static int[] generateIntHash(java.lang.String data)
Generate a hash code from specified data. Hash function is SHA-1.

Parameters:
data - String to obtain its hash code.
Returns:
null if no SHA could be obtained, or result of hash function in int array format.

generateByteHash

public static byte[] generateByteHash(java.lang.String data)
Generate a hash code from specified data. Hash function is SHA-1.

Parameters:
data - String to obtain its hash code.
Returns:
null if no SHA could be obtained, or result of hash function in byte array format.

parseBoolean

public static boolean parseBoolean(java.lang.String txt)
Parses the string argument as a boolean. The boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string "true". Implemented in JDK1.4 as a replacement of jdk1.5 Boolean.parseBoolean.

Parameters:
txt - The String containing the boolean representation to be parsed
Returns:
the boolean represented by the string argument