www.sdmetrics.com

com.sdmetrics.metrics
Class AbstractProcedure

java.lang.Object
  extended by com.sdmetrics.metrics.AbstractProcedure
Direct Known Subclasses:
BooleanOperation, MetricProcedure, RuleProcedure, ScalarOperation, SetOperation, SetProcedure

public class AbstractProcedure
extends java.lang.Object

Base class for metric, set, and rule procedures as well as scalar, boolean, and set operations.


Constructor Summary
AbstractProcedure()
           
 
Method Summary
protected  boolean evalBooleanExpression(ModelElement element, ExpressionNode node, Variables vars)
          Calculates the value of a boolean expression for a model element.
protected  java.util.Collection<ModelElement> evalElementSetExpression(ModelElement element, ExpressionNode node, Variables vars)
          Calculates a set expression that returns a set of model elements.
protected  java.lang.Object evalExpression(ModelElement element, ExpressionNode node, Variables vars)
          Calculates the value of a metric expression for a model element.
protected  java.util.Collection<?> evalSetExpression(ModelElement element, ExpressionNode node, Variables vars)
          Calculates a set expression for a model element.
protected  FilterAttributeProcessor getFilterAttributeProcessor(ProcedureAttributes attributes)
          Creates a new filter attribute processing object.
protected  MetaModel getMetaModel()
          Gets the metamodel for which this calculation takes place.
protected  MetricsEngine getMetricsEngine()
          Gets the metrics engine to use for calculations.
protected  Model getModel()
          Gets the model for which this calculation takes place.
protected  java.util.Collection<ModelElement> getRelationOrSet(ModelElement element, ProcedureAttributes attributes, Variables vars)
          Gets the element set specified by a "relation" or "relset" attribute.
protected  boolean isCompatible(ModelElement element, MetricEntry metric, ModelElement candidate)
          Checks if a metric or set can be applied to a related element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractProcedure

public AbstractProcedure()
Method Detail

getMetricsEngine

protected MetricsEngine getMetricsEngine()
Gets the metrics engine to use for calculations.

Returns:
Metrics engine for this procedure

getRelationOrSet

protected java.util.Collection<ModelElement> getRelationOrSet(ModelElement element,
                                                              ProcedureAttributes attributes,
                                                              Variables vars)
                                                       throws SDMetricsException
Gets the element set specified by a "relation" or "relset" attribute.

Parameters:
element - Element for which to retrieve the set.
attributes - Attributes of the procedure definition.
vars - Variables for the evaluation of expressions
Returns:
The set specified by the "relation" or "relset" attribute.
Throws:
SDMetricsException - Neither "relation" nor "relset" attribute was specified.

getFilterAttributeProcessor

protected FilterAttributeProcessor getFilterAttributeProcessor(ProcedureAttributes attributes)
                                                        throws SDMetricsException
Creates a new filter attribute processing object.

Parameters:
attributes - Attributes of the procedure definition
Returns:
Filter attribute processor for this procedure
Throws:
SDMetricsException - One of the filter attributes contains illegal values

getModel

protected Model getModel()
Gets the model for which this calculation takes place.

Returns:
The model for this calculation.

getMetaModel

protected MetaModel getMetaModel()
Gets the metamodel for which this calculation takes place.

Returns:
The metamodel for this calculation

evalExpression

protected java.lang.Object evalExpression(ModelElement element,
                                          ExpressionNode node,
                                          Variables vars)
                                   throws SDMetricsException
Calculates the value of a metric expression for a model element.

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 resulting metric value of the expression
Throws:
SDMetricsException - a problem occurred during the evaluation

evalBooleanExpression

protected boolean evalBooleanExpression(ModelElement element,
                                        ExpressionNode node,
                                        Variables vars)
                                 throws SDMetricsException
Calculates the value of a boolean expression for a model element.

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 resulting boolean value of the expression
Throws:
SDMetricsException - a problem occurred during the evaluation

evalSetExpression

protected java.util.Collection<?> evalSetExpression(ModelElement element,
                                                    ExpressionNode node,
                                                    Variables vars)
                                             throws SDMetricsException
Calculates a set expression for a model element.

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 result set of the evaluation
Throws:
SDMetricsException - a problem occurred during the evaluation

evalElementSetExpression

protected java.util.Collection<ModelElement> evalElementSetExpression(ModelElement element,
                                                                      ExpressionNode node,
                                                                      Variables vars)
                                                               throws SDMetricsException
Calculates a set expression that returns a set of model elements.

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 resulting element set
Throws:
SDMetricsException - a problem occurred during the evaluation

isCompatible

protected boolean isCompatible(ModelElement element,
                               MetricEntry metric,
                               ModelElement candidate)
Checks if a metric or set can be applied to a related element. Used for recursive or nesting metrics/sets. If the metric or set is not inheritable, the related element must be of the same type as the element for which the metric is being calculated. If the metric or set is inheritable, the related element must be an ancestor or descendant for which the metric is also available.

Parameters:
element - The element for which the metric/set/rule is calculated.
metric - The metric, set, or rule to be checked.
candidate - The related element to check.
Returns:
true if the metric/set/rule can be applied to the candidate element, else false
Since:
2.3

www.sdmetrics.com