www.sdmetrics.com

com.sdmetrics.metrics
Class ScalarOperation

java.lang.Object
  extended by com.sdmetrics.metrics.AbstractProcedure
      extended by com.sdmetrics.metrics.ScalarOperation

public abstract class ScalarOperation
extends AbstractProcedure

Base class for scalar operations in expressions. Scalar operations return strings, numbers (Float or Integer), or model elements.

Since:
2.3

Constructor Summary
ScalarOperation()
           
 
Method Summary
abstract  java.lang.Object calculateValue(ModelElement element, ExpressionNode node, Variables vars)
          Calculates the value for the scalar operation.
protected  float getFloatValue(ModelElement element, ExpressionNode node, Variables vars)
          Evaluates an expression that yields a float value.
protected  float getFloatValue(java.lang.Object value, ModelElement element)
          Converts a number value to float.
 
Methods inherited from class com.sdmetrics.metrics.AbstractProcedure
evalBooleanExpression, evalElementSetExpression, evalExpression, evalSetExpression, getFilterAttributeProcessor, getMetaModel, getMetricsEngine, getModel, getRelationOrSet, isCompatible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScalarOperation

public ScalarOperation()
Method Detail

calculateValue

public abstract java.lang.Object calculateValue(ModelElement element,
                                                ExpressionNode node,
                                                Variables vars)
                                         throws SDMetricsException
Calculates the value for the scalar operation.

Parameters:
element - Model element for which to calculate the operation
node - The expression node with the operands for the scalar operation.
vars - The variables for the calculation.
Returns:
Result of the operation.
Throws:
SDMetricsException - Problems while calculating the operation value.

getFloatValue

protected float getFloatValue(ModelElement element,
                              ExpressionNode node,
                              Variables vars)
                       throws SDMetricsException
Evaluates an expression that yields a float value.

Parameters:
element - The model element to evaluate the expression for.
node - Root node of the expression to evaluate
vars - Variables for the expression evaluation
Returns:
The value of the expression
Throws:
SDMetricsException - Problems while evaluating the expression.

getFloatValue

protected float getFloatValue(java.lang.Object value,
                              ModelElement element)
                       throws SDMetricsException
Converts a number value to float.

Parameters:
value - Value to convert (must be an instance of java.lang.Number).
element - Model element for which to calculate the operation
Returns:
floatValue of the Number
Throws:
SDMetricsException - Value is not a number

www.sdmetrics.com