www.sdmetrics.com

com.sdmetrics.metrics
Class FilterAttributeProcessor

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

public class FilterAttributeProcessor
extends java.lang.Object

Processes the standard filter attributes for individual model elements or entire sets. The filter attributes are the attributes "target", "targetcondition", "element", "eltype", "condition", and "scope".


Constructor Summary
FilterAttributeProcessor(MetricsEngine engine, ProcedureAttributes attributes)
           
 
Method Summary
 ModelElement applyFilters(ModelElement principal, ModelElement candidate, Variables vars)
          Applies the filter attributes to a candidate element.
 java.lang.Iterable<ModelElement> fullIteration(java.util.Collection<ModelElement> set, Variables vars)
          Applies element filters and filter attributes to an element set and returns an iteration over the resulting elements.
 boolean isValid()
          Tests if the resulting model element from the most recent application of filter attributes fulfills all filter conditions.
 java.lang.Iterable<ModelElement> validIteration(java.util.Collection<ModelElement> set, Variables vars)
          Applies element filters and filter attributes to an element set and returns an iteration over the valid elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterAttributeProcessor

public FilterAttributeProcessor(MetricsEngine engine,
                                ProcedureAttributes attributes)
                         throws SDMetricsException
Parameters:
engine - Metric engine to evaluate the filter expressions
attributes - metric or set calculation procedure definition with the filter attributes to apply.
Throws:
SDMetricsException - The "scope" attribute is set but does not contain a string.
Method Detail

applyFilters

public ModelElement applyFilters(ModelElement principal,
                                 ModelElement candidate,
                                 Variables vars)
                          throws SDMetricsException
Applies the filter attributes to a candidate element.

Returns the element produced by the "element" filter attribute, or null if the "element" filter attribute yields no model element. If the "element" filter attribute is not set, the candidate element itself is returned.

In either case, after the call to this method, method isValid() indicates if the returned element satisfies the conditions of the other filter attributes.

Parameters:
principal - The model element for which the metric or set is calculated.
candidate - The candidate model element.
vars - Variables for the evaluation of the condition expressions
Returns:
The result from applying the "element" filter attribute, if specified, otherwise the candidate model element.
Throws:
SDMetricsException - An error occurred evaluating one of the filter attributes.

isValid

public boolean isValid()
Tests if the resulting model element from the most recent application of filter attributes fulfills all filter conditions.

Filters are applied by calling method applyFilters(com.sdmetrics.model.ModelElement, com.sdmetrics.model.ModelElement, com.sdmetrics.metrics.Variables) or methods hasNext() and next() on the iterators produced by methods fullIteration(java.util.Collection, com.sdmetrics.metrics.Variables) or validIteration(Collection, Variables).

Returns:
true if the model element returned by the most recent filter application fulfills all filter attribute conditions.

fullIteration

public java.lang.Iterable<ModelElement> fullIteration(java.util.Collection<ModelElement> set,
                                                      Variables vars)
                                               throws SDMetricsException
Applies element filters and filter attributes to an element set and returns an iteration over the resulting elements.

Parameters:
set - Element set, typically the result of a "relation" or "relset" attribute in a projection-like metric.
vars - Variables for the evaluation of expressions
Returns:
Iteration over the resulting elements
Throws:
SDMetricsException - Error evaluating the filter attributes

validIteration

public java.lang.Iterable<ModelElement> validIteration(java.util.Collection<ModelElement> set,
                                                       Variables vars)
                                                throws SDMetricsException
Applies element filters and filter attributes to an element set and returns an iteration over the valid elements.

Parameters:
set - Element set, typically the result of a "relation" or "relset" attribute in a projection-like metric.
vars - Variables for the evaluation of expressions
Returns:
Iteration over the resulting elements
Throws:
SDMetricsException - Error evaluating the filter attributes

www.sdmetrics.com