vec_math
Class ExpressionCalculator

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by vec_math.ExpressionCalculator
All Implemented Interfaces:
Cloneable, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
ExposureTime

public class ExpressionCalculator
extends PropertyBundles
implements Initializable

Combines an ExpressionNode and an ExpressionParser to actually fill paramtere values into an expression and evaluate this.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  ExpressionNode expression
          The parsable double expression.
static String KEY_INITEXPRESSION
          The evaluator uses this expression for parsing.
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
ExpressionCalculator(Map<String,String> init)
          Constructs a new expression evaluator.
 
Method Summary
 Number evaluate(Map<String,Object> set)
          Returns the actual value of the expression.
 ExpressionNode getExpression()
          Returns the initial expression.
 void init()
          If the calculator has a property named KEY_INITEXPRESSION, we use this expression to initialize the calculator.
 void initCalculator(String node)
          Initializes the expression.
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

KEY_INITEXPRESSION

public static final String KEY_INITEXPRESSION
The evaluator uses this expression for parsing.

See Also:
Constant Field Values

expression

private ExpressionNode expression
The parsable double expression.

Constructor Detail

ExpressionCalculator

public ExpressionCalculator(Map<String,String> init)
Constructs a new expression evaluator. The properties can be used for additional variables that should be available to the evaluator.

Method Detail

init

public void init()
If the calculator has a property named KEY_INITEXPRESSION, we use this expression to initialize the calculator.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyResources

initCalculator

public void initCalculator(String node)
Initializes the expression. Variable substitution is done in the evaluate(java.util.Map) method. Proper parsing is only possible if the argument follows the generic ExpressionNode specification.

Parameters:
node - A String expression.

evaluate

public Number evaluate(Map<String,Object> set)
Returns the actual value of the expression. Variables that are TargetDependingParameters are evaluted using the target definition. Variable names must either be substitutable from the parameter cluster handed over or specified as constants in the DTDConstants.CONSTANT section of the merit. The sequence of parameter substitution first looks up the merit's constant. Only if the variable is not a defined constant, it is evaluated using the parameter set.

Returns:
Either a Double or a Boolean

getExpression

public ExpressionNode getExpression()
Returns the initial expression.