pt.digitalis.dif.dem.objects.parameters
Interface IParameter<T>

Type Parameters:
T - generic type of the parameter
All Superinterfaces:
Cloneable
All Known Implementing Classes:
AbstractParameter, BigDecimalParameter, BooleanParameter, DateParameter, DocumentParameter, DoubleParameter, LongParameter, StringParameter

public interface IParameter<T>
extends Cloneable

This class will define a Parameter.

It will hold information relative to the Parameter value, ID key and validation constraints.

Author:
Pedro Viegas pviegas@digitalis.pt
Created on:
Nov 23, 2007

Method Summary
 IParameter<T> clone()
          Creates a new instance of the current object
 void forceInitialize(boolean allowAnonymous, Map<String,IParameterConstraint> constraints, T defaultValue, String formLinked, String id, ParameterScope parameterScope, String parentID, Entity parentType, boolean persistToRepository, boolean readonly, boolean referencedInARuleFromAnotherParameter, boolean required, boolean formConfigurable, List<IParameterRule<T>> rules, Map<String,IParameterValidator> validators, T value)
          Parameter Initializer.
 Map<String,IParameterConstraint> getConstraints()
           
 String getFormLinked()
           
 String getId()
           
 ParameterScope getParameterScope()
           
 String getParentID()
           
 Entity getParentType()
           
 List<IParameterRule<T>> getRules()
          Inspector for the 'rules' attribute.
 List<String> getSupportedClasses()
           
 Map<String,IParameterValidator> getValidators()
           
 T getValue(IDIFContext context)
          Returns the parameter value.
 BigDecimal getValueAsBigDecimal(IDIFContext context)
           
 boolean getValueAsBoolean(IDIFContext context)
           
 Date getValueAsDate(IDIFContext context)
           
 DocumentRepositoryEntry getValueAsDocument(IDIFContext context)
          Returns the parameter value as a Document Note: Only Document types parameters will correctly respond to this method.
 Double getValueAsDouble(IDIFContext context)
           
 Long getValueAsLong(IDIFContext context)
           
 String getValueAsString(IDIFContext context)
          Returns the parameter value as a String
 void initialize(String id, Entity parentType, String parentID, boolean formConfigurable, boolean persistToRepository, boolean allowAnonymousAccess, ParameterScope parameterScope, String defaultValue, String constraintDefinition, Map<String,IParameterValidator> validators, List<IParameterRule<T>> rules)
          Parameter Initializer.
 boolean isAllowAnonymous()
           
 boolean isFormConfigurable()
          Inspector for the 'formConfigurable' attribute.
 boolean isNumeric()
           
 boolean isPersistToRepository()
           
 boolean isReadonly()
           
 boolean isReferencedInARuleFromAnotherParameter()
          Inspector for the 'referencedInARuleFromAnotherParameter' attribute.
 boolean isRequired()
           
 boolean isStringSetterSupported()
           
 ParameterErrorList refreshParameterValue(IStageInstance stageInstance)
          Updates the value of the parameter from the relevant sources.
 ParameterErrorList setDefaultValue(IStageInstance stageInstance)
          Sets the value of the parameter to its default and runs all constraints and validations
 ParameterErrorList setDefaultValue(IStageInstance stageInstance, boolean initializationInProgress)
          Sets the value of the parameter to its default and runs all constraints and validations
 void setFormConfigurable(boolean formConfigurable)
          Modifier for the 'formConfigurable' attribute.
 void setFormLinked(String formLinked)
           
 void setReferencedInARuleFromAnotherParameter(boolean referencedInARuleFromAnotherParameter)
          Modifier for the 'referencedInARuleFromAnotherParameter' attribute.
 ParameterErrorList setValue(T value, IStageInstance stageInstance)
          Sets the value of the parameter and runs all constraints and validations
 ParameterErrorList setValue(T value, IStageInstance stageInstance, boolean initializationInProgress)
          Sets the value of the parameter and runs all constraints and validations
 ParameterErrorList setValueFromString(String value, IStageInstance stageInstance)
          Sets the value of the parameter converting if from a string representation and runs all constraints and validations
 ParameterErrorList setValueFromString(String value, IStageInstance stageInstance, boolean initializationInProgress)
          Sets the value of the parameter converting if from a string representation and runs all constraints and validations
 

Method Detail

clone

IParameter<T> clone()
                    throws CloneNotSupportedException
Creates a new instance of the current object

Returns:
IParameter clone
Throws:
CloneNotSupportedException

forceInitialize

void forceInitialize(boolean allowAnonymous,
                     Map<String,IParameterConstraint> constraints,
                     T defaultValue,
                     String formLinked,
                     String id,
                     ParameterScope parameterScope,
                     String parentID,
                     Entity parentType,
                     boolean persistToRepository,
                     boolean readonly,
                     boolean referencedInARuleFromAnotherParameter,
                     boolean required,
                     boolean formConfigurable,
                     List<IParameterRule<T>> rules,
                     Map<String,IParameterValidator> validators,
                     T value)
Parameter Initializer. Since IoC provides the construction this should be called after TODO: Refactor this method!! This is a bad coding practice! Methods should have between 3 and 7 arguments. Nine is too much. Use encapsulation.

Parameters:
id - the parameter id
parentType - the parent entity type
parentID - the id of the parent entity
persistToRepository - if the parameter value should be persisted to the repository
allowAnonymous - if a USER scoped parameter should allow anonymous access
parameterScope - the scope of the parameter
defaultValue - the parameter default value
constraints - the string that defines the constraints to apply
formLinked - the form name of null if not set
readonly -
referencedInARuleFromAnotherParameter - the new referencedInARuleFromAnotherParameter value to set
required -
formConfigurable - T if the form is configurable
validators - a validator list to validate the parameter values
rules - the parameter rules
value -

getConstraints

Map<String,IParameterConstraint> getConstraints()
Returns:
the constraints

getFormLinked

String getFormLinked()
Returns:
the form name of null if not set

getId

String getId()
Returns:
the id

getParameterScope

ParameterScope getParameterScope()
Returns:
the persistScope

getParentID

String getParentID()
Returns:
the parentID

getParentType

Entity getParentType()
Returns:
the parentType

getRules

List<IParameterRule<T>> getRules()
Inspector for the 'rules' attribute.

Returns:
the rules value

getSupportedClasses

List<String> getSupportedClasses()
Returns:
the list of supported class types for the parameter value

getValidators

Map<String,IParameterValidator> getValidators()
Returns:
the validators

getValue

T getValue(IDIFContext context)
           throws ParameterException
Returns the parameter value. This method will check a number of possible sources for the value of the parameter depending on it's scope and attributes.

Parameters:
context - the DIF context to read if needed
Returns:
the value
Throws:
ParameterException - if the parameter could not be read

getValueAsBigDecimal

BigDecimal getValueAsBigDecimal(IDIFContext context)
                                throws ParameterException
Parameters:
context - the DIF context to read if needed
Returns:
the value of the parameter as a Double
Throws:
ParameterException - if a conversion error occurs

getValueAsBoolean

boolean getValueAsBoolean(IDIFContext context)
                          throws ParameterException
Parameters:
context - the DIF context to read if needed
Returns:
the value of the parameter as a boolean
Throws:
ParameterException - if the parameter value cannot be read

getValueAsDate

Date getValueAsDate(IDIFContext context)
                    throws ParameterException
Parameters:
context - the DIF context to read if needed
Returns:
the value of the parameter as a Date
Throws:
ParameterException - if a conversion error occurs

getValueAsDocument

DocumentRepositoryEntry getValueAsDocument(IDIFContext context)
                                           throws ParameterException
Returns the parameter value as a Document Note: Only Document types parameters will correctly respond to this method. All others will report an invalid usage ParameterException

Parameters:
context - the DIF context to read if needed
Returns:
the string representation of the parameter value
Throws:
ParameterException - if the parameter value cannot be read

getValueAsDouble

Double getValueAsDouble(IDIFContext context)
                        throws ParameterException
Parameters:
context - the DIF context to read if needed
Returns:
the value of the parameter as a Double
Throws:
ParameterException - if a conversion error occurs

getValueAsLong

Long getValueAsLong(IDIFContext context)
                    throws ParameterException
Parameters:
context - the DIF context to read if needed
Returns:
the value of the parameter as an Long
Throws:
ParameterException - if a conversion error occurs

getValueAsString

String getValueAsString(IDIFContext context)
                        throws ParameterException
Returns the parameter value as a String

Parameters:
context - the DIF context to read if needed
Returns:
the string representation of the parameter value
Throws:
ParameterException - if the parameter value cannot be read

initialize

void initialize(String id,
                Entity parentType,
                String parentID,
                boolean formConfigurable,
                boolean persistToRepository,
                boolean allowAnonymousAccess,
                ParameterScope parameterScope,
                String defaultValue,
                String constraintDefinition,
                Map<String,IParameterValidator> validators,
                List<IParameterRule<T>> rules)
                throws ParameterException
Parameter Initializer. Since IoC provides the construction this should be called after TODO: Refactor this method!! This is a bad coding practice! Methods should have between 3 and 7 arguments. Nine is too much. Use encapsulation.

Parameters:
id - the parameter id
parentType - the parent entity type
parentID - the id of the parent entity
formConfigurable - if the parameter can be configured for a given form
persistToRepository - if the parameter value should be persisted to the repository
allowAnonymousAccess - if a USER scoped parameter should allow anonymous access
parameterScope - the scope of the parameter
defaultValue - the parameter default value
constraintDefinition - the string that defines the constraints to apply
validators - a validator list to validate the parameter values
rules - the parameter rules
Throws:
ParameterException - if the default value can't be converted to the inner parameter type

isAllowAnonymous

boolean isAllowAnonymous()
Returns:
the allowAnonymous

isFormConfigurable

boolean isFormConfigurable()
Inspector for the 'formConfigurable' attribute.

Returns:
the formConfigurable value

isNumeric

boolean isNumeric()
Returns:
T if the current parameter is of a numeric type

isPersistToRepository

boolean isPersistToRepository()
Returns:
the persistToRepository

isReadonly

boolean isReadonly()
Returns:
the readonly

isReferencedInARuleFromAnotherParameter

boolean isReferencedInARuleFromAnotherParameter()
Inspector for the 'referencedInARuleFromAnotherParameter' attribute.

Returns:
the referencedInARuleFromAnotherParameter value

isRequired

boolean isRequired()
Returns:
the required

isStringSetterSupported

boolean isStringSetterSupported()
Returns:
T if we can set the parameter with a String value representation

refreshParameterValue

ParameterErrorList refreshParameterValue(IStageInstance stageInstance)
Updates the value of the parameter from the relevant sources. This method will check a number of possible sources for the value of the parameter depending on it's scope and attributes.

Parameters:
stageInstance - the DIF stage to read if needed
Returns:
return the error message if the validation fails

setDefaultValue

ParameterErrorList setDefaultValue(IStageInstance stageInstance)
Sets the value of the parameter to its default and runs all constraints and validations

Parameters:
stageInstance - the requested stage
Returns:
return the error messages if the validation fails

setDefaultValue

ParameterErrorList setDefaultValue(IStageInstance stageInstance,
                                   boolean initializationInProgress)
Sets the value of the parameter to its default and runs all constraints and validations

Parameters:
stageInstance - the requested stage
initializationInProgress - T if called within the dif parameter initialization
Returns:
return the error messages if the validation fails

setFormConfigurable

void setFormConfigurable(boolean formConfigurable)
Modifier for the 'formConfigurable' attribute.

Parameters:
formConfigurable - the new formConfigurable value to set

setFormLinked

void setFormLinked(String formLinked)
Parameters:
formLinked -

setReferencedInARuleFromAnotherParameter

void setReferencedInARuleFromAnotherParameter(boolean referencedInARuleFromAnotherParameter)
Modifier for the 'referencedInARuleFromAnotherParameter' attribute.

Parameters:
referencedInARuleFromAnotherParameter - the new referencedInARuleFromAnotherParameter value to set

setValue

ParameterErrorList setValue(T value,
                            IStageInstance stageInstance)
Sets the value of the parameter and runs all constraints and validations

Parameters:
value - the value to set
stageInstance - the DIF stage to read if needed. WARNING: If null is interpreted like an initialization and no scope repositories will be accessed/updated.
Returns:
return the error messages if the validation fails

setValue

ParameterErrorList setValue(T value,
                            IStageInstance stageInstance,
                            boolean initializationInProgress)
Sets the value of the parameter and runs all constraints and validations

Parameters:
value - the value to set
stageInstance - the DIF stage to read if needed. WARNING: If null is interpreted like an initialization and no scope repositories will be accessed/updated.
initializationInProgress - T if called within the dif parameter initialization
Returns:
return the error messages if the validation fails

setValueFromString

ParameterErrorList setValueFromString(String value,
                                      IStageInstance stageInstance)
Sets the value of the parameter converting if from a string representation and runs all constraints and validations

Parameters:
value - the value to set
stageInstance - the DIF stage to read if needed.
Returns:
return the error messages if the validation fails

setValueFromString

ParameterErrorList setValueFromString(String value,
                                      IStageInstance stageInstance,
                                      boolean initializationInProgress)
Sets the value of the parameter converting if from a string representation and runs all constraints and validations

Parameters:
value - the value to set
stageInstance - the DIF stage to read if needed.
initializationInProgress - T if called within the dif parameter initialization
Returns:
return the error messages if the validation fails


Copyright © 2014 Digitalis Informática Lda. All Rights Reserved.