edu.uoc.pfc.j2ee.jalonsod.mtp.request
Class ParameterInstance

java.lang.Object
  extended by edu.uoc.pfc.j2ee.jalonsod.mtp.request.ParameterInstance
Direct Known Subclasses:
BooleanParameterInstance, DateParameterInstance, DoubleParameterInstance, IntegerParameterInstance, StringParameterInstance

public abstract class ParameterInstance
extends java.lang.Object

File: ParameterInstance.java Created: 2012-05-01 Holds one parameter value from the request. The parameterInstance is related to one parameter metadata from configuration.

Author:
José Alonso de Motta
See Also:
FormInstance, Parameter

Field Summary
protected  Parameter parameter
          The configuration metadata parameter wich belongs to this parameterInstance.
static java.lang.Integer VALIDATION_DATATYPE_CONVERSION_ERROR
          The parameter does not pass datatype conversion validation for the value.
static java.lang.Integer VALIDATION_FUNCTION_ERROR
          The parameter value does not pass function validation.
static java.lang.Integer VALIDATION_NOT_VALIDATED
          The parameter is not yet validated.
static java.lang.Integer VALIDATION_OK
          The parameter is fully validated.
static java.lang.Integer VALIDATION_REQUIRED_VALUE_IS_NULL
          The parameter value is null but it's required.
protected  java.lang.Integer validationStatus
          The validation status of the parameterInstance.
 
Constructor Summary
protected ParameterInstance(Parameter parameter)
           
 
Method Summary
static ParameterInstance createParameterInstance(Parameter parameter)
          Factory method to create new ParameterInstance subtypes.
abstract  java.lang.Object getDefaultValue()
          Returns the default value of the parameterInstance with appropriate datatype.
 Parameter getParameter()
           
 java.lang.Integer getValidationStatus()
           
abstract  java.lang.Object getValue()
          Returns the value of the parameterInstance.
 void setParameter(Parameter parameter)
           
abstract  void setStringValue(java.lang.String value)
          Sets the value of the parameterInstance received in a string and converted to appropriate datatype.
 void setValidationStatus(java.lang.Integer validationStatus)
           
abstract  void setValue(java.lang.Object value)
          Sets the value of the parameterInstance.
 void setValueAsDefault()
          Sets the value of this parameterInstance with the default value defined in the parameter metadata from configuration.
abstract  java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VALIDATION_NOT_VALIDATED

public static final java.lang.Integer VALIDATION_NOT_VALIDATED
The parameter is not yet validated.


VALIDATION_DATATYPE_CONVERSION_ERROR

public static final java.lang.Integer VALIDATION_DATATYPE_CONVERSION_ERROR
The parameter does not pass datatype conversion validation for the value.


VALIDATION_REQUIRED_VALUE_IS_NULL

public static final java.lang.Integer VALIDATION_REQUIRED_VALUE_IS_NULL
The parameter value is null but it's required.


VALIDATION_FUNCTION_ERROR

public static final java.lang.Integer VALIDATION_FUNCTION_ERROR
The parameter value does not pass function validation.


VALIDATION_OK

public static final java.lang.Integer VALIDATION_OK
The parameter is fully validated.


parameter

protected Parameter parameter
The configuration metadata parameter wich belongs to this parameterInstance.


validationStatus

protected java.lang.Integer validationStatus
The validation status of the parameterInstance. It's one of the VALIDATION_* constants.

Constructor Detail

ParameterInstance

protected ParameterInstance(Parameter parameter)
Method Detail

createParameterInstance

public static ParameterInstance createParameterInstance(Parameter parameter)
Factory method to create new ParameterInstance subtypes.

Parameters:
parameter - the configuration metadata parameter associated with this object.
Returns:
a new parameterInstance object of appropriate subtype.

setValueAsDefault

public void setValueAsDefault()
Sets the value of this parameterInstance with the default value defined in the parameter metadata from configuration.


getParameter

public Parameter getParameter()

setParameter

public void setParameter(Parameter parameter)

getValidationStatus

public java.lang.Integer getValidationStatus()

setValidationStatus

public void setValidationStatus(java.lang.Integer validationStatus)

getValue

public abstract java.lang.Object getValue()
Returns the value of the parameterInstance.

Returns:
the value of the parameterInstance. The datatype varies according to parameter subtype from configuration.

setValue

public abstract void setValue(java.lang.Object value)
Sets the value of the parameterInstance.

Parameters:
value - the value of the parameterInstance. The datatype must be appropiate according datatype of parameter metadata from configuration.

setStringValue

public abstract void setStringValue(java.lang.String value)
                             throws MTPException
Sets the value of the parameterInstance received in a string and converted to appropriate datatype.

Parameters:
value - the string with the value to convert.
Throws:
MTPException - throws when the value cannot be converted to appropriate datatype.

getDefaultValue

public abstract java.lang.Object getDefaultValue()
Returns the default value of the parameterInstance with appropriate datatype.

Returns:
the default value of the parameterInstance.

toString

public abstract java.lang.String toString()
Overrides:
toString in class java.lang.Object