www.sdmetrics.com

com.sdmetrics.metrics
Class RuleProcedure

java.lang.Object
  extended by com.sdmetrics.metrics.AbstractProcedure
      extended by com.sdmetrics.metrics.RuleProcedure
Direct Known Subclasses:
RuleProcedureCycle, RuleProcedureSet, RuleProcedureViolation

public abstract class RuleProcedure
extends AbstractProcedure

Base class for all rule procedures.


Constructor Summary
RuleProcedure()
           
 
Method Summary
abstract  void checkRule(ModelElement element, Rule rule)
          Checks the rule for a model element.
protected  int getMinExpressionValue(ModelElement element, ProcedureAttributes attributes, java.lang.String attrName, Variables vars)
          Evaluates the "minnodes" or "mincnt" expression of a rule.
protected  RuleEngine getRuleEngine()
          Gets the rule engine for this rule procedure.
protected  java.lang.Object getRuleValue(ModelElement element, ProcedureAttributes attributes, Variables vars)
          Evaluates the "value" expression of a rule.
protected  java.util.Map<java.lang.Object,java.lang.Object> getValuesCache()
          Gets the cache to store data for reuse for subsequent checks of other model elements.
protected  void reportViolation(ModelElement element, Rule rule, java.lang.Object value)
          Reports a rule violation.
 
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

RuleProcedure

public RuleProcedure()
Method Detail

checkRule

public abstract void checkRule(ModelElement element,
                               Rule rule)
                        throws SDMetricsException
Checks the rule for a model element.

Parameters:
element - The element to check.
rule - The rule to check.
Throws:
SDMetricsException - Problem while checking the rule

getRuleEngine

protected RuleEngine getRuleEngine()
Gets the rule engine for this rule procedure.

Returns:
The rule engine of the procedure.

reportViolation

protected void reportViolation(ModelElement element,
                               Rule rule,
                               java.lang.Object value)
Reports a rule violation.

Parameters:
element - The violating element.
rule - The violated rule.
value - The value of the rule violation.

getValuesCache

protected java.util.Map<java.lang.Object,java.lang.Object> getValuesCache()
Gets the cache to store data for reuse for subsequent checks of other model elements.

Returns:
value cache for rule procedures

getRuleValue

protected java.lang.Object getRuleValue(ModelElement element,
                                        ProcedureAttributes attributes,
                                        Variables vars)
                                 throws SDMetricsException
Evaluates the "value" expression of a rule.

Parameters:
element - Model element for which the rule is evaluated
attributes - Attributes of the calculation procedure definition of the rule.
vars - Variables for the evaluation of the expression
Returns:
Result of the "value" expression of the rule, or null if none was specified.
Throws:
SDMetricsException - An error occurred evaluating the "value" expression.

getMinExpressionValue

protected int getMinExpressionValue(ModelElement element,
                                    ProcedureAttributes attributes,
                                    java.lang.String attrName,
                                    Variables vars)
                             throws SDMetricsException
Evaluates the "minnodes" or "mincnt" expression of a rule.

Parameters:
element - Model element for which the rule is evaluated
attributes - Attributes of the calculation procedure definition of the rule.
attrName - Name of the attribute ("minnodes" or "mincnt").
vars - Variables for the evaluation of the expression
Returns:
Value of the "min" expression, or 1 if none was specified.
Throws:
SDMetricsException - An error occurred evaluating the expression.

www.sdmetrics.com