public class FilterAttributeProcessor
extends java.lang.Object
Constructor and Description |
---|
FilterAttributeProcessor(MetricsEngine engine,
ProcedureAttributes attributes)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public FilterAttributeProcessor(MetricsEngine engine, ProcedureAttributes attributes) throws SDMetricsException
engine
- Metric engine to evaluate the filter expressionsattributes
- metric or set calculation procedure definition with the
filter attributes to apply.SDMetricsException
- The "scope" attribute is set but does not
contain a string.public ModelElement applyFilters(ModelElement principal, ModelElement candidate, Variables vars) throws SDMetricsException
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.
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 expressionsSDMetricsException
- An error occurred evaluating one of the filter
attributes.public boolean isValid()
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.model.ModelElement>, com.sdmetrics.metrics.Variables)
or validIteration(Collection, Variables)
.
true
if the model element returned by the most
recent filter application fulfills all filter attribute
conditions.public java.lang.Iterable<ModelElement> fullIteration(java.util.Collection<ModelElement> set, Variables vars) throws SDMetricsException
applyFilters(com.sdmetrics.model.ModelElement, com.sdmetrics.model.ModelElement, com.sdmetrics.metrics.Variables)
.
isValid()
indicates if the most recently returned
element of the iteration fulfills the filter attribute conditions.
set
- Element set, typically the result of a "relation" or "relset"
attribute in a projection-like metric.vars
- Variables for the evaluation of expressionsSDMetricsException
- Error evaluating the filter attributespublic java.lang.Iterable<ModelElement> validIteration(java.util.Collection<ModelElement> set, Variables vars) throws SDMetricsException
applyFilters(com.sdmetrics.model.ModelElement, com.sdmetrics.model.ModelElement, com.sdmetrics.metrics.Variables)
.
set
- Element set, typically the result of a "relation" or "relset"
attribute in a projection-like metric.vars
- Variables for the evaluation of expressionsSDMetricsException
- Error evaluating the filter attributes