anon.util
Class Util

java.lang.Object
  extended by anon.util.Util

public final class Util
extends java.lang.Object


Field Summary
static java.lang.String VERSION_FORMAT
          Defines the format of version numbers in the AN.ON project.
 
Constructor Summary
private Util()
          This class works without being initialised and is completely static.
 
Method Summary
static boolean arraysEqual(byte[] arrayOne, byte[] arrayTwo)
          Tests if two byte arrays are equal.
static boolean arraysEqual(byte[] a_arrayA, int a_Aoff, byte[] a_arrayB, int a_Boff, int a_length)
          Tests if a_length positions of two arrays are equal.
static boolean arraysEqual(char[] arrayOne, char[] arrayTwo)
          Tests if two charactet arrays are equal.
private static void bubbleSortStrings(java.util.Vector a_vector, java.lang.String[] buffer, int[] bufferIndices)
          Uses the Bubble Sort method to sort a vector of objects by comparing the output of the toString() method.
static long convertVersionStringToNumber(java.lang.String a_version)
          Converts a version string of the form xx.xx.xxx to a number
private static int divide(java.lang.String[] a_IDs, java.lang.String[] a_values, int a_left, int a_right)
           
static java.lang.String getStackTrace(java.lang.Throwable a_t)
          Gets the stack trace of a Throwable as String.
static java.lang.String getStaticFieldValue(java.lang.Class a_class, java.lang.String a_fieldName)
          Uses the reflection API to get the value of a static field in the given class, if the field is present.
private static boolean isUmlaut(char a_character, java.lang.String[] a_transformedUmlauts, int a_position)
          Tests if a character is an umlaut and, if yes, writes the umlaut in an ASCII form to the array of transformed umlauts at the specified position.
static java.lang.String normaliseString(java.lang.String a_string, int a_normLength)
          Normalises a String to the given length by filling it up with spaces, if it does not already have this length or is even longer.
static float parseFloat(java.lang.String a_string)
          Implementation of parseFloat not implemented in JDK 1.1.8
private static void quicksort(java.lang.String[] a_IDs, java.lang.String[] a_values, int a_left, int a_right)
           
static java.lang.String replaceAll(java.lang.String a_source, java.lang.String a_toReplace, java.lang.String a_replaceWith)
          Since JDK 1.1.8 does not provide String.replaceAll(), this is an equivalent method.
static void sort(java.lang.String[] a_ids, java.lang.String[] a_values)
           
static java.util.Vector sortStrings(java.util.Vector a_vector)
          Sorts a Vector alphabetically using the toString() method of each object.
private static void swap(java.lang.String[] a_IDs, java.lang.String[] a_values, int a, int b)
           
static java.lang.Object[] toArray(java.lang.Object a_object)
          Creates an Object array from a single Object.
static java.util.Vector toVector(java.lang.Object a_object)
          Creates a Vector from a single Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_FORMAT

public static final java.lang.String VERSION_FORMAT
Defines the format of version numbers in the AN.ON project.

See Also:
Constant Field Values
Constructor Detail

Util

private Util()
This class works without being initialised and is completely static. Therefore, the constructor is not needed and private.

Method Detail

normaliseString

public static java.lang.String normaliseString(java.lang.String a_string,
                                               int a_normLength)
Normalises a String to the given length by filling it up with spaces, if it does not already have this length or is even longer.

Parameters:
a_string - a String
a_normLength - a length to normalise the String
Returns:
the normalised String

getStackTrace

public static java.lang.String getStackTrace(java.lang.Throwable a_t)
Gets the stack trace of a Throwable as String.

Parameters:
a_t - a Throwable
Returns:
the stack trace of a throwable as String

arraysEqual

public static boolean arraysEqual(byte[] arrayOne,
                                  byte[] arrayTwo)
Tests if two byte arrays are equal.

Parameters:
arrayOne - a byte array
arrayTwo - another byte array
Returns:
true if the two byte arrays are equal or both arrays are null; false otherwise

arraysEqual

public static boolean arraysEqual(char[] arrayOne,
                                  char[] arrayTwo)
Tests if two charactet arrays are equal.

Parameters:
arrayOne - a charactet array
arrayTwo - another charactet array
Returns:
true if the two charactet arrays are equal or both arrays are null; false otherwise

arraysEqual

public static final boolean arraysEqual(byte[] a_arrayA,
                                        int a_Aoff,
                                        byte[] a_arrayB,
                                        int a_Boff,
                                        int a_length)
Tests if a_length positions of two arrays are equal.

Parameters:
a_arrayA - byte[]
a_Aoff - int
a_arrayB - byte[]
a_Boff - int
a_length - int
Returns:
boolean

toVector

public static java.util.Vector toVector(java.lang.Object a_object)
Creates a Vector from a single Object.

Parameters:
a_object - an Object
Returns:
a Vector containing the given Object or an empty Vector if the Object was null

toArray

public static java.lang.Object[] toArray(java.lang.Object a_object)
Creates an Object array from a single Object.

Parameters:
a_object - an Object
Returns:
an Object array containing the given Object or an empty array if the Object was null

swap

private static void swap(java.lang.String[] a_IDs,
                         java.lang.String[] a_values,
                         int a,
                         int b)

sortStrings

public static java.util.Vector sortStrings(java.util.Vector a_vector)
Sorts a Vector alphabetically using the toString() method of each object.

Parameters:
a_vector - a Vector
Returns:
an alphabetically sorted Vector

parseFloat

public static float parseFloat(java.lang.String a_string)
                        throws java.lang.NumberFormatException
Implementation of parseFloat not implemented in JDK 1.1.8

Parameters:
a_string - String
Returns:
float
Throws:
java.lang.NumberFormatException

sort

public static void sort(java.lang.String[] a_ids,
                        java.lang.String[] a_values)

divide

private static int divide(java.lang.String[] a_IDs,
                          java.lang.String[] a_values,
                          int a_left,
                          int a_right)

quicksort

private static void quicksort(java.lang.String[] a_IDs,
                              java.lang.String[] a_values,
                              int a_left,
                              int a_right)

bubbleSortStrings

private static void bubbleSortStrings(java.util.Vector a_vector,
                                      java.lang.String[] buffer,
                                      int[] bufferIndices)
Uses the Bubble Sort method to sort a vector of objects by comparing the output of the toString() method.

Parameters:
a_vector - a Vector
buffer - a buffer
bufferIndices - indices for the buffer

isUmlaut

private static boolean isUmlaut(char a_character,
                                java.lang.String[] a_transformedUmlauts,
                                int a_position)
Tests if a character is an umlaut and, if yes, writes the umlaut in an ASCII form to the array of transformed umlauts at the specified position.

Parameters:
a_character - a character; must be lower case !
a_transformedUmlauts - an array of transformed umlauts
a_position - the position to write into the array of umlauts; if the character is not an umlaut, 'null' is written at this position, otherwise the character transformed into an ASCII form
Returns:
if the given character is an umlaut; false otherwise

convertVersionStringToNumber

public static long convertVersionStringToNumber(java.lang.String a_version)
                                         throws java.lang.NumberFormatException
Converts a version string of the form xx.xx.xxx to a number

Parameters:
a_version - a version string of the form xx.xx.xxx
Returns:
the given version string as number
Throws:
java.lang.NumberFormatException - if the version has an illegal format

replaceAll

public static java.lang.String replaceAll(java.lang.String a_source,
                                          java.lang.String a_toReplace,
                                          java.lang.String a_replaceWith)
Since JDK 1.1.8 does not provide String.replaceAll(), this is an equivalent method.


getStaticFieldValue

public static java.lang.String getStaticFieldValue(java.lang.Class a_class,
                                                   java.lang.String a_fieldName)
Uses the reflection API to get the value of a static field in the given class, if the field is present.

Parameters:
a_class - a Class
a_fieldName - the field to read the value from
Returns:
the value of a static field in the given class or null if the value or field is not present