planet.util
Class Utilities

java.lang.Object
  extended by planet.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_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 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 int INT_SIZE
Size in bits of the int


LONG_SIZE

public static int LONG_SIZE
Size in bits of the long


BYTE_SIZE

public static int BYTE_SIZE
Size in bits of the byte

Constructor Detail

Utilities

public Utilities()
Method Detail

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