www.sdmetrics.com

com.sdmetrics.app
Class MetricData

java.lang.Object
  extended by com.sdmetrics.app.MetricData
All Implemented Interfaces:
DataTables

public class MetricData
extends java.lang.Object
implements DataTables

Provides a tabular view of the design measurement data. There is one table for each metamodel element type, rows of the tables are the design elements, columns are the metrics.

The class hides internal metrics, and reduces table output to those element types for which there actually is metric data.

You have the option to pre-calculate all metric values, so that they can be quickly accessed afterwards.


Constructor Summary
MetricData(MetricsEngine engine)
           
 
Method Summary
 java.lang.String getColumnDescription(int index, int col)
          Returns a description for the metric at the specified column.
 java.lang.String getColumnName(int index, int col)
          Returns the name of the metric at the specified column.
 java.lang.Object getMetricValue(int index, int row, int col)
          Returns the metric value for a particular design element and metric in a table, throwing an exception if the calculation failed.
 int getNumberOfColumns(int index)
          Returns the number of metrics for a table.
 int getNumberOfRows(int index)
          Returns the number of design elements for a table.
 int getNumberOfTables()
          Returns the number of available tables.
 java.lang.String getRowName(int index, int row)
          Returns the name of the design element at the specified row.
 java.lang.String getTableName(int index)
          Returns the name of a table.
 java.lang.String getTablesDescription()
          Returns a short description of the tables contents.
 java.lang.String getTypeName(int table)
          Returns the metamodel type name of the elements of a table.
 java.lang.Object getValueAt(int index, int row, int col)
          Returns the metric value for a particular design element and metric in a table.
 boolean precalculateMetrics(MessageHandler msgHandler, int startPercent, int finishPercent)
          Calculates all externally visible metrics, reports any errors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetricData

public MetricData(MetricsEngine engine)
Parameters:
engine - Metrics engine to provide the metric data.
Method Detail

precalculateMetrics

public boolean precalculateMetrics(MessageHandler msgHandler,
                                   int startPercent,
                                   int finishPercent)
Calculates all externally visible metrics, reports any errors.

Parameters:
msgHandler - Handler for progress and error messages
startPercent - Initial value of the progress indicator
finishPercent - Value of the progress indicator at the completion of this calculation run
Returns:
true if all metrics were calculated without errors, else false.

getTypeName

public java.lang.String getTypeName(int table)
Description copied from interface: DataTables
Returns the metamodel type name of the elements of a table.

Specified by:
getTypeName in interface DataTables
Parameters:
table - Index of the table to access.
Returns:
Type name of the model elements of that table.

getMetricValue

public java.lang.Object getMetricValue(int index,
                                       int row,
                                       int col)
                                throws SDMetricsException
Returns the metric value for a particular design element and metric in a table, throwing an exception if the calculation failed. Use this method instead of getValueAt() if you did not pre-calculate the metrics and still need to detect the presence of errors.

Parameters:
index - Index of the table to access.
row - Index of the design element to access.
col - Index of the metric to access.
Returns:
Metric value at the specified coordinates.
Throws:
SDMetricsException - if an error occurred during calculation of the metric.

getNumberOfTables

public int getNumberOfTables()
Description copied from interface: DataTables
Returns the number of available tables.

Specified by:
getNumberOfTables in interface DataTables
Returns:
The number of tables, n. Valid table indices run from 0 to n-1.

getTableName

public java.lang.String getTableName(int index)
Description copied from interface: DataTables
Returns the name of a table.

Specified by:
getTableName in interface DataTables
Parameters:
index - Index of the table to access.
Returns:
The name of that table.

getNumberOfRows

public int getNumberOfRows(int index)
Returns the number of design elements for a table.

Specified by:
getNumberOfRows in interface DataTables
Parameters:
index - Index of the table to access.
Returns:
The number of rows of the table, r. Valid row indices for the table run from 0 to r-1.

getNumberOfColumns

public int getNumberOfColumns(int index)
Returns the number of metrics for a table.

Specified by:
getNumberOfColumns in interface DataTables
Parameters:
index - Index of the table to access.
Returns:
Number of columns of the table, c. Valid column indices for the table run from 0 to c-1.

getValueAt

public java.lang.Object getValueAt(int index,
                                   int row,
                                   int col)
Returns the metric value for a particular design element and metric in a table. Use this method instead of getMetricValue() if metric values have been pre-calculated without errors.

Specified by:
getValueAt in interface DataTables
Parameters:
index - Index of the table to access.
row - Index of the design element to access.
col - Index of the metric to access.
Returns:
Metric value at the specified coordinates, or empty string if metric calculation failed.

getRowName

public java.lang.String getRowName(int index,
                                   int row)
Returns the name of the design element at the specified row.

Specified by:
getRowName in interface DataTables
Parameters:
index - Index of the table to access.
row - Index of the row to access.
Returns:
The name of the row to be used as row header.

getColumnName

public java.lang.String getColumnName(int index,
                                      int col)
Returns the name of the metric at the specified column.

Specified by:
getColumnName in interface DataTables
Parameters:
index - Index of the table to access.
col - Index of the column to access.
Returns:
The name of the column to be used as column header.

getColumnDescription

public java.lang.String getColumnDescription(int index,
                                             int col)
Returns a description for the metric at the specified column.

Specified by:
getColumnDescription in interface DataTables
Parameters:
index - Index of the table to access.
col - Index of the column to access.
Returns:
A brief description text for the column.

getTablesDescription

public java.lang.String getTablesDescription()
Description copied from interface: DataTables
Returns a short description of the tables contents. For example, "metric data", "design rule violations", "descriptive statistics", etc.

Specified by:
getTablesDescription in interface DataTables
Returns:
Description of the table contents.

www.sdmetrics.com