See: Description
Interface | Description |
---|---|
StronglyConnectedComponents.Graph<T> |
Provides the strongly connected components algorithm with the information
it requires about the directed graph.
|
Class | Description |
---|---|
AbstractProcedure |
Base class for metric, set, and rule procedures as well as scalar, boolean,
and set operations.
|
BooleanOperation |
Base class for Boolean operations in expressions.
|
ChangeDirectionsAdapter<T> |
Constructs a new graph from an existing one, reversing or removing the
directions of the edges.
|
ElementGraph |
A graph consisting of model elements.
|
FilterAttributeProcessor |
Processes the standard filter attributes for individual model elements or
entire sets.
|
Glossary |
Represents a glossary term entry in the metric definition file.
|
Matrix |
Represents the definition of a relation matrix in the metric definition file.
|
MatrixData |
Data structure to store the data for one matrix.
|
MatrixEngine |
Calculates relation matrices.
|
Metric |
Represents the definition of metric in the metric definition file.
|
MetricEntry |
Base class for entries in the metric definition file (metrics, sets, rules,
or matrices).
|
MetricProcedure |
Base class for all metric procedures.
|
MetricProcedureAttributeValue |
Calculates an "attributevalue" metric procedure.
|
MetricProcedureCompare |
Calculates the deprecated "compare" metric procedure.
|
MetricProcedureCompound |
Calculates a "compound" metric procedure.
|
MetricProcedureConnectedComponents |
Calculates a "connectedcomponents" metric procedure.
|
MetricProcedureCount |
Calculates the deprecated "count" metric procedure.
|
MetricProcedureFilterValue |
Calculates a "filtervalue" metric procedure.
|
MetricProcedureNesting |
Calculates a "nesting" metric procedure.
|
MetricProcedureProjection |
Calculates a "projection" metric procedure.
|
MetricProcedureSetOperation |
Calculates the deprecated "setoperation" metric procedure.
|
MetricProcedureSignature |
Calculates a "signature" metric procedure.
|
MetricProcedureSubelements |
Calculates a "subelements" metric procedure.
|
MetricProcedureSubString |
Calculates the "substring" procedure to extract substrings from a string.
|
MetricProcedureValuesetOperation |
Calculates the deprecated "valueset" metric procedure.
|
MetricsEngine |
Calculates metrics and sets.
|
MetricStore |
Reads a metric definition file and provides access to metrics, sets, and
rules defined therein.
|
MetricTools |
Collection of static helper methods that are useful for the implementation of
calculation procedures.
|
ProcedureAttributes |
Stores the attributes of the calculation procedure definition of a metric,
set, matrix, or rule in the metric definition file.
|
Reference |
Represents a literature reference in the metric definition file.
|
Rule |
Represents a design rule.
|
RuleEngine |
Checks the design rules for a model and reports violations.
|
RuleFilter |
Represents and evaluates a design rule filter expression.
|
RuleProcedure |
Base class for all rule procedures.
|
RuleProcedureCycle |
Checks a "cycle" rule.
|
RuleProcedureSet |
Checks rules based on set procedures.
|
RuleProcedureViolation |
Checks a "violation" rule with a simple rule condition.
|
RuleViolation |
Stores details about the violation of one specific rule by one specific model
element.
|
ScalarOperation |
Base class for scalar operations in expressions.
|
Set |
Represents the definition of a set in the metric definition file.
|
SetOperation |
Base class for set operations in expressions.
|
SetProcedure |
Base class for all set procedures.
|
SetProcedureCompare |
Calculates the deprecated "compare" set procedure.
|
SetProcedureCompound |
Calculates the deprecated "compoundset" procedure for sets.
|
SetProcedureProjection |
Calculates the "projection" set procedure.
|
SetProcedureSubelements |
Calculates the "subelements" set procedure.
|
SetSummationHelper |
Helps set calculation procedures to build up their cumulative result sets.
|
StronglyConnectedComponents<T> |
Calculates the strongly connected components of a directed graph.
|
SummationHelper |
Processes the "sum" and "stat" attributes of metric calculation procedures.
|
Variables |
Contains the names and values of variables to use when evaluating metric,
set, or condition expressions.
|
Enum | Description |
---|---|
DescriptionLocator |
Enumerates the locators for metrics, rules, and so forth in descriptions in
the metric definition files.
|
Exception | Description |
---|---|
SDMetricsException |
Exception to deal with problems that can occur during metrics calculation.
|
Tutorial - how to calculate metrics and check design rules for a UML model.
The following code snippets take you through the steps to calculate the
design metrics and check the design rules for a UML model, and write the
results to the console. We assume we have already loaded the UML model, as
described in the tutorial for package com.sdmetrics.model
.
import java.util.Collection; import sdmetrics.metrics.Metric; import sdmetrics.metrics.MetricStore; import sdmetrics.metrics.MetricsEngine; import sdmetrics.metrics.Rule; import sdmetrics.metrics.RuleEngine; import sdmetrics.metrics.RuleFilter; import sdmetrics.metrics.RuleViolation; import sdmetrics.model.MetaModel; import sdmetrics.model.Model; import sdmetrics.model.ModelElement; import sdmetrics.util.XMLParser;
com.sdmetrics.model
),
as well as the metric definition file with the metrics and rules you wish
to calculate and check, respectively.
MetaModel metaModel = ...; // metamodel to use Model model = ...; // model to uses String metricsURL = ...; // metric definition file to use
XMLParser parser = new XMLParser();
MetricStore
metricStore = new MetricStore(metaModel);
parser.parse(metricsURL, metricStore.getSAXParserHandler());
As is the case for parsing the metamodel and XMI files, you do not have to use
the SAX parser provided by class XMLParser
. Instances of org.xml.sax.XMLReader
that you created yourself will also do.
MetricsEngine
metricsEngine = new MetricsEngine(metricStore, model);
If you only want to check design rules, you can skip the next step and proceed directly
with rule checking.
In the following nested loop, we only calculate metrics that are not defined as "internal" helper metrics.
for (ModelElement element : model) { System.out.println("Calculating metrics for element " + element.getFullName()); // calculate and print all metric values for the element Collection<Metric> metrics = metricStore.getMetrics
(element.getType()); for (Metric
metric : metrics) { if (!metric.isInternal()) { System.out.println(" Metric " + metric.getName() + ": " + metricsEngine.getMetricValue
(element, metric)); } } }
In this example we use a rule filter to only check design rules for the "analysis" phase. We also skip rules that have been disabled in the metric definition file, and we skip checking rules from which the model element has explicitly been exempted.
RuleEngine
ruleEngine = new RuleEngine(metricsEngine);RuleFilter
ruleFilter = new RuleFilter("analysis"); for (ModelElement element : model) { System.out.println("Checking rules for element " + element.getFullName()); // get rules set of exempted rules for this element Collection<String> exemptRuleNames = ruleEngine.collectExemptedRules
(element); Collection<Rule> rules = metricStore.getRules
(element.getType()); for (Rule
rule : rules) { if (rule.isEnabled() && ruleFilter.match(rule) && !exemptRuleNames.contains(rule.getName())) { List<RuleViolation
> issues = ruleEngine.checkRule
(element,rule); for (RuleViolation issue : issues) { System.out.println(" Violates rule " + issue.getRule().getName() + ": " + issue.getValue()); } } } }
com.sdmetrics.app
to calculate all data and
organize it in a tabular layout.