Last update: 2011-06-23

org.proteios.core
Class ParameterType<T>

java.lang.Object
  extended by org.proteios.core.ParameterType<T>
Direct Known Subclasses:
BooleanParameterType, DateParameterType, DoubleParameterType, FileParameterType, FloatParameterType, IntegerParameterType, ItemParameterType, LongParameterType, StringParameterType

public abstract class ParameterType<T>
extends Object

This is the base class for all parameter types. A ParameterType is used by objects that take some kind of parameter input from an user.

Version:
2.0
Author:
Samuel, Nicklas, Enell
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Method Summary
 T getDefaultValue()
          Get the default value.
 int getHeight()
          Get the height of the input field for the parameter in the GUI.
 List<T> getItems()
          Get the list of item data objects to choose from.
 int getMultiplicity()
          Get how many values that can be tied to this parameter. 0 is unlimited values and 1 is default.
 boolean getNotNull()
          Check if the parameter can be null.
 Class<T> getParameterClass()
          Get the class a value must have to match this parameter type.
 int getWidth()
          Get the width of the input field in the GUI.
 boolean isEnumeration()
          Check if the parameter type enumerates the allowed values or not.
 void validate(String name, List<?> values)
          Check if a list of values contain invalid values.
 void validate(String name, Object value)
          Check if a value is valid according to the settings of this parameter type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getParameterClass

public Class<T> getParameterClass()
Get the class a value must have to match this parameter type.


getHeight

public int getHeight()
Get the height of the input field for the parameter in the GUI. Only used as a hint for the client.

Returns:
The height of the input field.

getWidth

public int getWidth()
Get the width of the input field in the GUI. Only used as a hint for the client.

Returns:
The width of the input field.

getNotNull

public boolean getNotNull()
Check if the parameter can be null. Will return true if it can't be null.

Returns:
True if not null, otherwise false.

getMultiplicity

public int getMultiplicity()
Get how many values that can be tied to this parameter. 0 is unlimited values and 1 is default.

Returns:
The multiplicity.

getDefaultValue

public T getDefaultValue()
Get the default value.

Returns:
The default value or null if none i set.

validate

public void validate(String name,
                     Object value)
              throws InvalidDataException
Check if a value is valid according to the settings of this parameter type.

Parameters:
name - The name of the parameter, used for better exception messages
value - The value to test
Throws:
InvalidDataException - If the value is invalid

validate

public void validate(String name,
                     List<?> values)
              throws InvalidDataException
Check if a list of values contain invalid values.

Parameters:
values - A list of objects to check
Throws:
InvalidDataException - If the list contains too many values as specified by the getMultiplicity() setting or has invalid values as checked by validate(String, Object)

isEnumeration

public boolean isEnumeration()
Check if the parameter type enumerates the allowed values or not. If the parameter is an enumeration the values can be retreived by getItems()

Returns:
TRUE if the parameter type is an enumeration, FALSE otherwise

getItems

public List<T> getItems()
Get the list of item data objects to choose from.

Returns:
List of item data objects.

Last update: 2011-06-23