de.jstacs.io
Class ParameterSetParser

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

public class ParameterSetParser
extends Object

This class extracts values from Parameters and 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 Exception 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
<T extends InstantiableFromParameterSet>
T
getInstanceFromParameterSet(InstanceParameterSet<T> pars)
          Returns an instance of a subclass of InstantiableFromParameterSet that can be instantiated by the InstanceParameterSet pars.
static
<T extends InstantiableFromParameterSet>
T
getInstanceFromParameterSet(ParameterSet pars, Class<T> 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 of the Parameter
Throws:
ParameterSetParser.WrongParameterTypeException - if par is not a Parameter of type int, i.e. its DataType is not DataType.INT
See Also:
DataType, DataType.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 of the Parameter
Throws:
ParameterSetParser.WrongParameterTypeException - if par is not a Parameter of type float, i.e. its DataType is not DataType.FLOAT
See Also:
DataType, DataType.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 of the Parameter
Throws:
ParameterSetParser.WrongParameterTypeException - if par is not a Parameter of type double, i.e. its DataType is not DataType.DOUBLE
See Also:
DataType, DataType.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 of the Parameter
Throws:
ParameterSetParser.WrongParameterTypeException - if par is not a Parameter of type short, i.e. its DataType is not DataType.SHORT
See Also:
DataType, DataType.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 of the Parameter
Throws:
ParameterSetParser.WrongParameterTypeException - if par is not a Parameter of type long, i.e. its DataType is not DataType.LONG
See Also:
DataType, DataType.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 of the Parameter
Throws:
ParameterSetParser.WrongParameterTypeException - if par is not a Parameter of type byte, i.e. its DataType is not DataType.BYTE
See Also:
DataType, DataType.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 of the Parameter
Throws:
ParameterSetParser.WrongParameterTypeException - if par is not a Parameter of type boolean, i.e. its DataType is not DataType.BOOLEAN
See Also:
DataType, DataType.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 of the Parameter
Throws:
ParameterSetParser.WrongParameterTypeException - if par is not a Parameter of type String, i.e. its DataType is not DataType.STRING
See Also:
DataType, DataType.STRING

getInstanceFromParameterSet

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

Type Parameters:
T - the type of the InstanceParameterSet
Parameters:
pars - the InstanceParameterSet
Returns:
the instance
Throws:
ParameterSetParser.NotInstantiableException - if InstanceParameterSet.getInstanceClass() of pars is null, could not be found or cannot be instantiated from pars
See Also:
InstanceParameterSet.getInstanceClass(), getInstanceFromParameterSet(ParameterSet, Class)

getInstanceFromParameterSet

public static <T extends InstantiableFromParameterSet> T getInstanceFromParameterSet(ParameterSet pars,
                                                                                     Class<T> 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.

Type Parameters:
T - the type of the InstanceParameterSet
Parameters:
pars - the ParameterSet
instanceClass - the class that shall be instantiated
Returns:
the instance
Throws:
ParameterSetParser.NotInstantiableException - if instanceClass is null, could not be found or cannot be instantiated from pars