ecologylab.generic
Class Generic

java.lang.Object
  extended by ecologylab.generic.Generic
Direct Known Subclasses:
EnvironmentGeneric

public class Generic
extends java.lang.Object

A set of generic convenience methods for doing things like getting typed parameters from the envionment, getting other stuff from the environment, building HashMaps from arrays, manipulating threads, ... While some of these functionalities constitute a nice set of static covers for facilities provided by Environment, this class can be viewed as a kitchen sink of useful static methods.

Author:
andruid

Field Summary
static java.lang.String SEP
           
 
Constructor Summary
Generic()
           
 
Method Summary
static void beep()
           
static boolean booleanFromString(java.lang.String value)
          Convert a String to a boolean.
static java.lang.Object findEqual(java.util.List list, java.lang.Object object)
          Find the first object equal to the one passed in as the second argument, within the List that is the first argument.
static java.lang.ThreadGroup findThreadGroup(int priority)
           
static java.lang.ThreadGroup findThreadGroup(java.lang.ThreadGroup threadGroup, int priority)
           
static java.lang.ThreadGroup findThreadGroup(java.lang.Thread thread, int priority)
           
static int getMaxMemory()
          Returns the environment's current max memory settings (based on command-line parameters in the java control panel)
static void main(java.lang.String[] s)
           
static java.lang.String narrowFloat(float f)
           
static float parseFloat(java.lang.String floatString)
          Turn a string into a float.
static int parseInt(java.lang.String input, int defaultVal)
           
static void raiseMaxPriority(int priority)
           
static void raiseMaxPriority(java.lang.ThreadGroup threadGroup, int priority)
           
static void raiseMaxPriority(java.lang.Thread thread, int priority)
           
static void raisePriority(int priority)
          Raise the priority of the current thread to the priority level, if the current priority level is less than it.
static java.lang.String round(float f, int powerOfTen)
           
static void setPriority(int priority)
          Set the priority of the current thread.
static void setPriority(java.lang.Thread t, int priority)
          Set the priority of the current thread.
static void showDialog(java.lang.String msg)
           
static void sleep(int time)
          Sleep easily.
static void sleep(int time, boolean reportExceptions)
          Sleep easily.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEP

public static final java.lang.String SEP
See Also:
Constant Field Values
Constructor Detail

Generic

public Generic()
Method Detail

booleanFromString

public static boolean booleanFromString(java.lang.String value)
Convert a String to a boolean.

Parameters:
value -
Returns:
true if the String is "true", "yes", or "1". false otherwise

parseFloat

public static float parseFloat(java.lang.String floatString)
Turn a string into a float.

Returns:
the float, if the String is cool; else Float.NaN

sleep

public static final void sleep(int time)
Sleep easily. Report InterruptedExceptions when they happen, if the param is true.


sleep

public static final void sleep(int time,
                               boolean reportExceptions)
Sleep easily. Report InterruptedExceptions when they happen, if the param is true.


setPriority

public static final void setPriority(int priority)
Set the priority of the current thread.


setPriority

public static final void setPriority(java.lang.Thread t,
                                     int priority)
Set the priority of the current thread.


round

public static java.lang.String round(float f,
                                     int powerOfTen)

raisePriority

public static void raisePriority(int priority)
Raise the priority of the current thread to the priority level, if the current priority level is less than it. Otherwise, do nothing.

Parameters:
priority -

raiseMaxPriority

public static void raiseMaxPriority(int priority)

raiseMaxPriority

public static void raiseMaxPriority(java.lang.Thread thread,
                                    int priority)

raiseMaxPriority

public static void raiseMaxPriority(java.lang.ThreadGroup threadGroup,
                                    int priority)

findThreadGroup

public static java.lang.ThreadGroup findThreadGroup(int priority)

findThreadGroup

public static java.lang.ThreadGroup findThreadGroup(java.lang.Thread thread,
                                                    int priority)

findThreadGroup

public static java.lang.ThreadGroup findThreadGroup(java.lang.ThreadGroup threadGroup,
                                                    int priority)

parseInt

public static final int parseInt(java.lang.String input,
                                 int defaultVal)
Returns:
the int represented by input. Silently defaults to defaultVal, input is not in good form.

main

public static void main(java.lang.String[] s)

beep

public static void beep()

findEqual

public static java.lang.Object findEqual(java.util.List list,
                                         java.lang.Object object)
Find the first object equal to the one passed in as the second argument, within the List that is the first argument.

Parameters:
list - The list to search.
object - The object to look for. Must not be null.
Returns:
The equal object from the list, if there is one, or null.

getMaxMemory

public static int getMaxMemory()
Returns the environment's current max memory settings (based on command-line parameters in the java control panel)

Returns:
The maximum amount of memory that can be allocated to the JVM in megabytes.

showDialog

public static void showDialog(java.lang.String msg)

narrowFloat

public static java.lang.String narrowFloat(float f)