de.jstacs.io
Class ParameterSetParser

java.lang.Object
  extended by de.jstacs.io.ParameterSetParser

public class ParameterSetParser
extends Object

Class that extracts values from Parameters und creates instances of InstantiableFromParameterSets from a ParameterSet.

Author:
Jan Grau

Nested Class Summary
static class ParameterSetParser.NotInstantiableException
          An Exception that is thrown if an instance of some class could not be created.
static class ParameterSetParser.WrongParameterTypeException
          An that is thrown if the datatype of a Parameter is not appropriate for some purpose.
 
Constructor Summary
ParameterSetParser()
           
 
Method Summary
static boolean getBooleanFromParameter(Parameter par)
          Returns the boolean which is the value of the Parameter par.
static byte getByteFromParameter(Parameter par)
          Returns the byte which is the value of the Parameter par.
static double getDoubleFromParameter(Parameter par)
          Returns the double which is the value of the Parameter par.
static float getFloatFromParameter(Parameter par)
          Returns the float which is the value of the Parameter par.
static InstantiableFromParameterSet getInstanceFromParameterSet(ParameterSet pars)
          Returns an instance of a subclass of InstantiableFromParameterSet that can be instantiated by the ParameterSet pars.
static InstantiableFromParameterSet getInstanceFromParameterSet(ParameterSet pars, Class instanceClass)
          Returns an instance of a subclass of InstantiableFromParameterSet that can be instantiated by the ParameterSet pars.
static int getIntFromParameter(Parameter par)
          Returns the int which is the value of the Parameter par.
static long getLongFromParameter(Parameter par)
          Returns the long which is the value of the Parameter par.
static short getShortFromParameter(Parameter par)
          Returns the short which is the value of the Parameter par.
static String getStringFromParameter(Parameter par)
          Returns the String which is the value of the Parameter par.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterSetParser

public ParameterSetParser()
Method Detail

getIntFromParameter

public static int getIntFromParameter(Parameter par)
                               throws ParameterSetParser.WrongParameterTypeException
Returns the int which is the value of the Parameter par.

Parameters:
par - the Parameter
Returns:
the int value
Throws:
ParameterSetParser.WrongParameterTypeException - is thrown if par is not an int-Parameter, i.e. its datatype is not Parameter.INT

getFloatFromParameter

public static float getFloatFromParameter(Parameter par)
                                   throws ParameterSetParser.WrongParameterTypeException
Returns the float which is the value of the Parameter par.

Parameters:
par - the Parameter
Returns:
the float value
Throws:
ParameterSetParser.WrongParameterTypeException - is thrown if par is not an float-Parameter, i.e. its datatype is not Parameter.FLOAT

getDoubleFromParameter

public static double getDoubleFromParameter(Parameter par)
                                     throws ParameterSetParser.WrongParameterTypeException
Returns the double which is the value of the Parameter par.

Parameters:
par - the Parameter
Returns:
the double value
Throws:
ParameterSetParser.WrongParameterTypeException - is thrown if par is not an double-Parameter, i.e. its datatype is not Parameter.DOUBLE

getShortFromParameter

public static short getShortFromParameter(Parameter par)
                                   throws ParameterSetParser.WrongParameterTypeException
Returns the short which is the value of the Parameter par.

Parameters:
par - the Parameter
Returns:
the short value
Throws:
ParameterSetParser.WrongParameterTypeException - is thrown if par is not an short-Parameter, i.e. its datatype is not Parameter.SHORT

getLongFromParameter

public static long getLongFromParameter(Parameter par)
                                 throws ParameterSetParser.WrongParameterTypeException
Returns the long which is the value of the Parameter par.

Parameters:
par - the Parameter
Returns:
the long value
Throws:
ParameterSetParser.WrongParameterTypeException - is thrown if par is not an long-Parameter, i.e. its datatype is not Parameter.LONG

getByteFromParameter

public static byte getByteFromParameter(Parameter par)
                                 throws ParameterSetParser.WrongParameterTypeException
Returns the byte which is the value of the Parameter par.

Parameters:
par - the Parameter
Returns:
the byte value
Throws:
ParameterSetParser.WrongParameterTypeException - is thrown if par is not an byte-Parameter, i.e. its datatype is not Parameter.BYTE

getBooleanFromParameter

public static boolean getBooleanFromParameter(Parameter par)
                                       throws ParameterSetParser.WrongParameterTypeException
Returns the boolean which is the value of the Parameter par.

Parameters:
par - the Parameter
Returns:
the boolean value
Throws:
ParameterSetParser.WrongParameterTypeException - is thrown if par is not an boolean-Parameter, i.e. its datatype is not Parameter.BOOLEAN

getStringFromParameter

public static String getStringFromParameter(Parameter par)
                                     throws ParameterSetParser.WrongParameterTypeException
Returns the String which is the value of the Parameter par.

Parameters:
par - the Parameter
Returns:
the String value
Throws:
ParameterSetParser.WrongParameterTypeException - is thrown if par is not an String-Parameter, i.e. its datatype is not Parameter.STRING

getInstanceFromParameterSet

public static InstantiableFromParameterSet getInstanceFromParameterSet(ParameterSet pars)
                                                                throws ParameterSetParser.NotInstantiableException
Returns an instance of a subclass of InstantiableFromParameterSet that can be instantiated by the ParameterSet pars. The instance-class is taken from pars via the getInstanceClass()-method.

Parameters:
pars - the ParameterSet
Returns:
the instance
Throws:
ParameterSetParser.NotInstantiableException - thrown if getInstanceClass() of pars is null, could not be found or cannot be instantiated from pars

getInstanceFromParameterSet

public static InstantiableFromParameterSet getInstanceFromParameterSet(ParameterSet pars,
                                                                       Class instanceClass)
                                                                throws ParameterSetParser.NotInstantiableException
Returns an instance of a subclass of InstantiableFromParameterSet that can be instantiated by the ParameterSet pars. The instance-class is taken from instanceClass.

Parameters:
pars - the ParameterSet
instanceClass - the class that shall be instantiated
Returns:
the instance
Throws:
ParameterSetParser.NotInstantiableException - thrown if instanceClass could not be found or cannot be instantiated from pars