org.specrunner.parameters.core
Class ParameterDecoratorImpl

java.lang.Object
  extended by org.specrunner.parameters.core.ParameterDecoratorImpl
All Implemented Interfaces:
IParameterDecorator

public class ParameterDecoratorImpl
extends Object
implements IParameterDecorator

Generic implementation of a parameter sensible object.

Author:
Thiago Santos

Field Summary
protected  Map<String,Object> allParameters
          Set of all parameters, valid or not.
protected  Map<String,IAccess> checked
          Hold information of already checked attributes.
protected  Map<String,Object> parameters
          Set of valid parameters.
 
Fields inherited from interface org.specrunner.parameters.IParameterDecorator
INVERT_FLAG, LATE_FLAG, SILENT_FLAG
 
Constructor Summary
ParameterDecoratorImpl()
           
 
Method Summary
 String clear(String name)
          Get name cleared.
 Map<String,Object> getAllParameters()
          Map of parameters set.
 Object getDecorated()
          Gets the decorated object.
 Object getParameter(String name)
          Gets a parameter.
 Map<String,Object> getParameters()
          Map of parameters set.
protected  boolean hasAnnotation(IAccess s, Class<? extends Annotation> an)
          Check if @DontEval annotation is present in feature.
 boolean hasParameter(String name)
          Check if a parameter name is valid.
protected  boolean is(String name, String flag, Class<? extends Annotation> annotation)
          Combine flag and annotation information.
 boolean isEval(String name)
          Check if a given name has to be evaluated.
 boolean isLate(String name)
          Check if a given name has to be evaluated at the end or not.
 boolean isSilent(String name)
          Check if a given name has to be evaluated silently or not.
 void setAllParameters(Map<String,Object> allParameters)
          Set of all parameters map.
 void setDecorated(Object decorated)
          Sets the decorated object.
 Object setParameter(String name, Object value, IContext context)
          Set a parameter.
 void setParameters(Map<String,Object> parameters)
          Set parameters map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

checked

protected Map<String,IAccess> checked
Hold information of already checked attributes.


parameters

protected Map<String,Object> parameters
Set of valid parameters.


allParameters

protected Map<String,Object> allParameters
Set of all parameters, valid or not.

Constructor Detail

ParameterDecoratorImpl

public ParameterDecoratorImpl()
Method Detail

getDecorated

public Object getDecorated()
Description copied from interface: IParameterDecorator
Gets the decorated object.

Specified by:
getDecorated in interface IParameterDecorator
Returns:
The object.

setDecorated

public void setDecorated(Object decorated)
Description copied from interface: IParameterDecorator
Sets the decorated object. Reset all parameters information.

Specified by:
setDecorated in interface IParameterDecorator
Parameters:
decorated - The new decorated object.

isEval

public boolean isEval(String name)
Description copied from interface: IParameterDecorator
Check if a given name has to be evaluated.

Specified by:
isEval in interface IParameterDecorator
Parameters:
name - The feature name.
Returns:
true, to evaluate, false, otherwise. Default is true.

isSilent

public boolean isSilent(String name)
Description copied from interface: IParameterDecorator
Check if a given name has to be evaluated silently or not.

Specified by:
isSilent in interface IParameterDecorator
Parameters:
name - The feature name.
Returns:
true, to silent evaluation, false, otherwise. Default is true.

isLate

public boolean isLate(String name)
Description copied from interface: IParameterDecorator
Check if a given name has to be evaluated at the end or not.

Specified by:
isLate in interface IParameterDecorator
Parameters:
name - The feature name.
Returns:
true, to late evaluation, false, otherwise. Default is false.

is

protected boolean is(String name,
                     String flag,
                     Class<? extends Annotation> annotation)
Combine flag and annotation information.

Parameters:
name - The feature name.
flag - The flag name.
annotation - The annotation.
Returns:
true, if conditions as satisfied, false, otherwise.

clear

public String clear(String name)
Description copied from interface: IParameterDecorator
Get name cleared.

Specified by:
clear in interface IParameterDecorator
Parameters:
name - The name.
Returns:
Cleared string.

getParameter

public Object getParameter(String name)
Description copied from interface: IParameterDecorator
Gets a parameter.

Specified by:
getParameter in interface IParameterDecorator
Parameters:
name - The parameter name.
Returns:
The parameter value.

setParameter

public Object setParameter(String name,
                           Object value,
                           IContext context)
                    throws Exception
Description copied from interface: IParameterDecorator
Set a parameter.

Specified by:
setParameter in interface IParameterDecorator
Parameters:
name - The parameter name.
value - The parameter value.
context - The context where value is insert.
Returns:
The resulting value of setting 'name' with the value in a given context. i.e. If context has a variable 'x' bind to 1(integer) and we ask to set 'name' to 'x', the operation output will be '1', but if feature 'name' in the decorated object has a annotation @DontEval the result will be 'x'.
Throws:
Exception - On evaluation error.

hasAnnotation

protected boolean hasAnnotation(IAccess s,
                                Class<? extends Annotation> an)
Check if @DontEval annotation is present in feature.

Parameters:
s - The feature access.
an - Annotation type.
Returns:
true, if annotation present, false, otherwise.

hasParameter

public boolean hasParameter(String name)
Description copied from interface: IParameterDecorator
Check if a parameter name is valid.

Specified by:
hasParameter in interface IParameterDecorator
Parameters:
name - The parameter.
Returns:
The parameter name.

getParameters

public Map<String,Object> getParameters()
Description copied from interface: IParameterDecorator
Map of parameters set. Only parameters properly set to object are available.

Specified by:
getParameters in interface IParameterDecorator
Returns:
The parameter mapping containing only parameters properly set.

setParameters

public void setParameters(Map<String,Object> parameters)
Description copied from interface: IParameterDecorator
Set parameters map.

Specified by:
setParameters in interface IParameterDecorator
Parameters:
parameters - The map.

getAllParameters

public Map<String,Object> getAllParameters()
Description copied from interface: IParameterDecorator
Map of parameters set. All parameters tried to be set in the object, even those whose corresponding property is not present in object.

Specified by:
getAllParameters in interface IParameterDecorator
Returns:
The parameter mapping containing all parameters set.

setAllParameters

public void setAllParameters(Map<String,Object> allParameters)
Description copied from interface: IParameterDecorator
Set of all parameters map.

Specified by:
setAllParameters in interface IParameterDecorator
Parameters:
allParameters - The map.


Copyright © 2014. All rights reserved.