www.sdmetrics.com

com.sdmetrics.metrics
Class RuleEngine

java.lang.Object
  extended by com.sdmetrics.metrics.RuleEngine

public class RuleEngine
extends java.lang.Object

Checks the design rules for a model and reports violations.


Constructor Summary
RuleEngine(MetricsEngine me)
          Creates a new rule engine.
 
Method Summary
 java.util.List<RuleViolation> checkRule(ModelElement element, Rule rule)
          Checks a design rule for a model element.
 void clearValuesCache()
          Clears the value cache for rule procedures.
 java.util.Collection<java.lang.String> collectExemptedRules(ModelElement element)
          Gets the names of the rules that a model element is allowed to violate.
 MetricsEngine getMetricsEngine()
          Returns the metrics engine that this rule engine uses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuleEngine

public RuleEngine(MetricsEngine me)
Creates a new rule engine.

Parameters:
me - Metrics engine to use for rule checking.
Method Detail

getMetricsEngine

public MetricsEngine getMetricsEngine()
Returns the metrics engine that this rule engine uses.

Returns:
Metrics Engine of this rule engine.

collectExemptedRules

public java.util.Collection<java.lang.String> collectExemptedRules(ModelElement element)
                                                            throws SDMetricsException
Gets the names of the rules that a model element is allowed to violate. Searches through the tagged values or comments of the model element, looking for occurrences of the exemption prefix "_violates". Extracts the identifiers following each such occurrence. These define the names of the rules the element is allowed to violate. Returns the set of these names.

Parameters:
element - Element to retrieve rule exemptions for.
Returns:
The set of the names of the rules the model element is allowed to violate.
Throws:
SDMetricsException - The tagged values or comments could not be accessed.

checkRule

public java.util.List<RuleViolation> checkRule(ModelElement element,
                                               Rule rule)
                                        throws SDMetricsException
Checks a design rule for a model element.

Parameters:
element - The model element to check.
rule - The rule to check.
Returns:
The list of detected rule violations.
Throws:
SDMetricsException - An error occurred checking the design rule.

clearValuesCache

public void clearValuesCache()
Clears the value cache for rule procedures.

The cache can be cleared any time. When you perform a comprehensive rule check (checking all rules for all model elements), a good strategy is to check all elements of one type, and clear the cache before proceeding with the next type.


www.sdmetrics.com