laser.util.argument
Class Utility

java.lang.Object
  extended by laser.util.argument.Utility

public class Utility
extends java.lang.Object

Utility class for the argument package. This is mostly to get around issues arising from single inheritence.

Author:
Jamieson M. Cobleigh (laser-software@cs.umass.edu)

Constructor Summary
Utility()
           
 
Method Summary
static java.lang.Object getClassInstance(java.lang.Class type)
          Gets a new instance of the given Class.
static java.lang.Boolean parseBoolean(java.lang.String value)
          Parses a String as a Boolean value
static java.lang.Class parseClass(java.lang.String value)
          Converts from a String to a Class.
static java.lang.Float parseFloat(java.lang.String value)
          Parses a String as a Float value
static java.lang.Integer parseInteger(java.lang.String value)
          Parses a String as an Integer value
static java.lang.Long parseLong(java.lang.String value)
          Parses a String as a Long value
static java.lang.String toStringValue(java.lang.Class value)
          Converts from a Class to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utility

public Utility()
Method Detail

parseBoolean

public static java.lang.Boolean parseBoolean(java.lang.String value)
Parses a String as a Boolean value

NOTE: In Java when parsing a string to a boolean value, true ( case insensitive ) is true and ANYTHING else is false.

Parameters:
value - the String
Returns:
the Boolean value

parseClass

public static java.lang.Class parseClass(java.lang.String value)
                                  throws ArgumentFormatException
Converts from a String to a Class.

Parameters:
value - the String
Returns:
the Class value
Throws:
ArgumentFormatException - if the String is not parseable as a Class

toStringValue

public static java.lang.String toStringValue(java.lang.Class value)
Converts from a Class to a String.

Parameters:
value - The Class value
Returns:
The String value

getClassInstance

public static java.lang.Object getClassInstance(java.lang.Class type)
                                         throws ArgumentFormatException
Gets a new instance of the given Class.

Parameters:
type - The Class to be instantiated
Returns:
A new instance
Throws:
ArgumentFormatException

parseFloat

public static java.lang.Float parseFloat(java.lang.String value)
                                  throws ArgumentFormatException
Parses a String as a Float value

Parameters:
value - the String
Returns:
the Float value
Throws:
ArgumentFormatException - if the String is not parseable as a Float

parseInteger

public static java.lang.Integer parseInteger(java.lang.String value)
                                      throws ArgumentFormatException
Parses a String as an Integer value

Parameters:
value - the String
Returns:
the Long value
Throws:
ArgumentFormatException - if the String is not parseable as a Long

parseLong

public static java.lang.Long parseLong(java.lang.String value)
                                throws ArgumentFormatException
Parses a String as a Long value

Parameters:
value - the String
Returns:
the Long value
Throws:
ArgumentFormatException - if the String is not parseable as a Long