Overview  Package   Class  Tree  Index 

be.lassi.util
Class Util

java.lang.Object
  extended by be.lassi.util.Util

public class Util
extends java.lang.Object


Method Summary
static int characterCount(java.lang.String string, char character)
          Gets the number of occurances of given character in given string.
static int characterIndex(java.lang.String string, char character, int occurance)
          Gets the index of the occurance'th position of given character in given string.
static void debug(java.lang.String message)
          Prints a debug message on stdout.
static void deleteFile(java.io.File file)
           
static void doNothing()
           
static java.lang.String eat(java.lang.String string, java.lang.String pattern)
           
static boolean isNumeric(java.lang.String string)
           
static boolean isThreadAlive(java.lang.String name)
           
static java.lang.String nameOf(java.lang.Class<?> clazz)
           
static
<E> java.util.ArrayList<E>
newArrayList()
          Constructs a new ArrayList in a generic way (from the book Effective Java 2nd Edition by Joshua Bloch).
static
<K,V> java.util.HashMap<K,V>
newHashMap()
          Constructs a new HashMap in a generic way (from the book Effective Java 2nd Edition by Joshua Bloch).
static
<E> java.util.concurrent.LinkedBlockingQueue<E>
newLinkedBlockingQueue()
           
static
<E> LList<E>
newList()
           
static long now()
          Provides current system time in milliseconds.
static java.lang.String readFile(java.lang.String filename)
          Gets the entire contents of the file in one string.
static void sleep(long millis)
          Sleeps given number of milli-seconds.
static byte toByte(int intValue)
           
static int toInt(byte byteValue)
           
static int toInt(byte high, byte low)
           
static int toInt(Holder<java.lang.String> holder)
           
static int toInt(java.lang.String string)
           
static java.lang.String toString(byte[] bytes)
           
static java.lang.String toString(byte[] bytes, int length)
           
static java.lang.String toString(java.io.Reader reader)
          Returns a string with contents read from given reader.
static void validate(java.lang.String name, int value, int min, int max)
           
static void writeFile(java.lang.String filename, java.lang.String string)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

characterCount

public static int characterCount(java.lang.String string,
                                 char character)
Gets the number of occurances of given character in given string.

Parameters:
string - the string to be search for character occurances
character - the character to search for

characterIndex

public static int characterIndex(java.lang.String string,
                                 char character,
                                 int occurance)
Gets the index of the occurance'th position of given character in given string.

Parameters:
string - the string to be searched
character - the character to search for
occurance - the occurance of the character we are looking for
Returns:
the position index, or -1 if this occurance is not found

debug

public static void debug(java.lang.String message)
Prints a debug message on stdout. Use this method when you want to print messages from the code for debugging purposes. The debug messages can be easily removed later by removing all references in this method. This prevents debug messages from being left behind in the code.

Parameters:
message - the message to be printed

deleteFile

public static void deleteFile(java.io.File file)

doNothing

public static void doNothing()

eat

public static java.lang.String eat(java.lang.String string,
                                   java.lang.String pattern)

isNumeric

public static boolean isNumeric(java.lang.String string)

isThreadAlive

public static boolean isThreadAlive(java.lang.String name)

nameOf

public static java.lang.String nameOf(java.lang.Class<?> clazz)

newArrayList

public static <E> java.util.ArrayList<E> newArrayList()
Constructs a new ArrayList in a generic way (from the book Effective Java 2nd Edition by Joshua Bloch).

Type Parameters:
E - the type of the elements in the collection
Returns:
the new ArrayList

newHashMap

public static <K,V> java.util.HashMap<K,V> newHashMap()
Constructs a new HashMap in a generic way (from the book Effective Java 2nd Edition by Joshua Bloch).

Type Parameters:
K - the type of the map key
V - the type of the map values
Returns:
the new HashMap

newLinkedBlockingQueue

public static <E> java.util.concurrent.LinkedBlockingQueue<E> newLinkedBlockingQueue()

newList

public static <E> LList<E> newList()

now

public static long now()
Provides current system time in milliseconds.

Before Java 1.5, the idea of this method was to provide the time information in an operating system independent way. Simply using System.currentTimeMillis() everywhere was not good enough. On Linux the granularity of the time information provided was always ok, but on Windows the granularity was not fine enough (and very different, depending on the operating system version). We used to use ibmts. With the introduction of System.nanoTime() in Java 1.5, this is not required anymore.


readFile

public static java.lang.String readFile(java.lang.String filename)
                                 throws java.io.IOException
Gets the entire contents of the file in one string.

Returns:
String file contents
Throws:
java.io.IOException

sleep

public static void sleep(long millis)
Sleeps given number of milli-seconds.

Parameters:
millis - number of milli-seconds to sleep

toByte

public static byte toByte(int intValue)

toInt

public static int toInt(byte byteValue)

toInt

public static int toInt(byte high,
                        byte low)

toInt

public static int toInt(Holder<java.lang.String> holder)

toInt

public static int toInt(java.lang.String string)

toString

public static java.lang.String toString(byte[] bytes)

toString

public static java.lang.String toString(byte[] bytes,
                                        int length)

toString

public static java.lang.String toString(java.io.Reader reader)
Returns a string with contents read from given reader.

Parameters:
reader - the reader from which to read the contents
Returns:
the contents

validate

public static void validate(java.lang.String name,
                            int value,
                            int min,
                            int max)

writeFile

public static void writeFile(java.lang.String filename,
                             java.lang.String string)
                      throws java.io.IOException
Throws:
java.io.IOException

Overview  Package   Class  Tree  Index 
Lighting Assistant 1.2