simple.util
Class Utils

java.lang.Object
  extended by simple.util.Utils

public final class Utils
extends java.lang.Object

(No dependents)
Created: Jan 27, 2009

Author:
Kenneth Pierce

Nested Class Summary
static class Utils.Timer
          This class is used to measure time differences.
static class Utils.TimerGroup
          Simple class to maintain several timers at once.
 
Field Summary
private static java.util.Date time
           
 
Constructor Summary
protected Utils()
           
 
Method Summary
static int compare(java.lang.Object object1, java.lang.Object object2)
          Determines order between two objects by using their toString() method.
static java.lang.String getStackTrace(java.lang.Throwable ex)
          Takes an error and returns a String representation of the stack trace.
static java.lang.String getTime(long milliseconds)
           
static java.lang.String getTimeDate()
           
static java.lang.String getTimeLong(long milliseconds)
           
static java.lang.String getTimeLongPrecise(long milliseconds)
           
static java.lang.String getTimePrecise(long milliseconds)
           
static Utils.Timer getTimer()
           
static boolean isSet(int options, int option)
          Tests to see if the on bits in option are also on in options.
static boolean isSet(long options, long option)
          Tests to see if the on bits in option are also on in options.
static
<E> java.util.Vector<E>
sort(java.util.Vector<E> list)
          Sorts a list alphabetically using each element's toString() function.
static byte[] toByteArray(long value)
          Takes a long value and returns a byte array with its value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

time

private static final java.util.Date time
Constructor Detail

Utils

protected Utils()
Method Detail

getTimeDate

public static java.lang.String getTimeDate()

getTimer

public static Utils.Timer getTimer()
Returns:
A new Timer.

toByteArray

public static byte[] toByteArray(long value)
Takes a long value and returns a byte array with its value.

Parameters:
value -
Returns:
The resulting array.

getStackTrace

public static java.lang.String getStackTrace(java.lang.Throwable ex)
Takes an error and returns a String representation of the stack trace.

Parameters:
ex - Error/Exception to get the stack trace from.
Returns:
String containing the stack trace.

sort

public static <E> java.util.Vector<E> sort(java.util.Vector<E> list)
Sorts a list alphabetically using each element's toString() function.

Type Parameters:
E -
Parameters:
list -
Returns:
The sorted vector.

compare

public static int compare(java.lang.Object object1,
                          java.lang.Object object2)
Determines order between two objects by using their toString() method.

Parameters:
object1 -
object2 -
Returns:
-1 if object2 comes before object1
1 if object1 comes before object2
0 if object1 and object2 are the same.

getTime

public static java.lang.String getTime(long milliseconds)

getTimeLong

public static java.lang.String getTimeLong(long milliseconds)

getTimePrecise

public static java.lang.String getTimePrecise(long milliseconds)

getTimeLongPrecise

public static java.lang.String getTimeLongPrecise(long milliseconds)

isSet

public static boolean isSet(int options,
                            int option)
Tests to see if the on bits in option are also on in options.

Parameters:
options - Options the user set.
option - Option to be tested.
Returns:
The result of (options&option)==option

isSet

public static boolean isSet(long options,
                            long option)
Tests to see if the on bits in option are also on in options.

Parameters:
options - Options the user set.
option - Option to be tested.
Returns:
The result of (options&option)==option