kaos.metrics
Class Metric

java.lang.Object
  extended by kaos.metrics.Metric

public class Metric
extends java.lang.Object

From: http://techrepublic.com.com/html/tr/sidebars/1045673-3.html Represents an individual metric. Each metric stores a long value or date value (which is a long). The metrics are kept and managed by the Metric Manager.

See Also:
MetricManager

Field Summary
static int AVERAGE_METRIC
          Identifies the generic Average metric.
static int ELAPSED_TIME_METRIC
          Identifies the generic Elapsed Time metric.
static int INDICATOR_METRIC
          Identifies the generic Indicator metric.
static int STATIC_METRIC
          Identifies the generic Static metric.
static int TIME_STAMP_METRIC
          Identifies the generic TimeStamp metric.
 
Constructor Summary
Metric()
          Construct a default Metric object.
Metric(int pMetricType, java.lang.String pMetricId, java.lang.String pMetricName, boolean pCanReset, java.lang.String pMetricDescription)
          Construct a default Metric object using the specified values.
 
Method Summary
 void add(java.util.Date pMetricValue)
          Add method increases or sets a metrics value.
 void add(java.util.GregorianCalendar pMetricValue)
          Add method increases or sets a metrics value.
 void add(int pMetricValue)
          Add method increases or sets a metrics value.
 void add(long pMetricValue)
          Add method increases or sets a metrics value.
 float getAverage()
          Returns the metric's average value.
 boolean getCanReset()
           
 long getDataPointCount()
          Returns the metric's count of data points.
 java.lang.String getDescription()
           
 java.lang.String getId()
           
 java.lang.String getName()
           
 java.util.GregorianCalendar getTimeStamp()
          Returns the metric's TimeStamp value.
 int getType()
           
 long getValue()
          Returns the metric's value.
 void reset()
          Resets all values to zero or null.
 java.lang.String toString()
          The Metric value is returned as a string for logs or screen output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIME_STAMP_METRIC

public static final int TIME_STAMP_METRIC
Identifies the generic TimeStamp metric. The TimeStamp metric is stored as a Gregorian Calendar in UTC time.

See Also:
Constant Field Values

ELAPSED_TIME_METRIC

public static final int ELAPSED_TIME_METRIC
Identifies the generic Elapsed Time metric. The Elapsed Time metric is a TimeStamp metric that returns the number of milliseconds elapsed since the TimeStamp.

See Also:
Constant Field Values

INDICATOR_METRIC

public static final int INDICATOR_METRIC
Identifies the generic Indicator metric. An Indicator metric is just a numeric total.

See Also:
Constant Field Values

STATIC_METRIC

public static final int STATIC_METRIC
Identifies the generic Static metric. A Static metric is a numeric value that replaces existing values with the new values.

See Also:
Constant Field Values

AVERAGE_METRIC

public static final int AVERAGE_METRIC
Identifies the generic Average metric. An Average metric is a numeric value that also keeps a count of the number of datapoints and returns the average as a float.

See Also:
Constant Field Values
Constructor Detail

Metric

public Metric()
Construct a default Metric object. Default type is Indicator.


Metric

public Metric(int pMetricType,
              java.lang.String pMetricId,
              java.lang.String pMetricName,
              boolean pCanReset,
              java.lang.String pMetricDescription)
Construct a default Metric object using the specified values.

Parameters:
pMetricType - Metric type number.
pMetricId - The metric id used to find this metric.
pMetricName - Descriptive name of metric.
pCanReset - True or False to control whether value can be reset.
pMetricDescription - Descriptive text in addition to the name.
Method Detail

getId

public java.lang.String getId()
Returns:
Metric id as a string.

getName

public java.lang.String getName()
Returns:
Name used for this Metric.

getDescription

public java.lang.String getDescription()
Returns:
Description for this Metric.

getType

public int getType()
Returns:
int type for this Metric; should match one of the _METRIC constants.

getCanReset

public boolean getCanReset()
Returns:
true if metric can be reset, false if it cannot be reset.

add

public void add(int pMetricValue)
Add method increases or sets a metrics value.

Parameters:
pMetricValue - value to be added to the current Metric.

add

public void add(long pMetricValue)
Add method increases or sets a metrics value.

Parameters:
pMetricValue - value to be added to the current Metric.

add

public void add(java.util.Date pMetricValue)
Add method increases or sets a metrics value.

Parameters:
pMetricValue - date value to be applied to the current Metric.

add

public void add(java.util.GregorianCalendar pMetricValue)
Add method increases or sets a metrics value.

Parameters:
pMetricValue - calendar value to be applied to the current Metric.

getValue

public long getValue()
Returns the metric's value.

Returns:
Value of the metric, 0 is returned if the metric is not an indicator or static metric type.

getAverage

public float getAverage()
Returns the metric's average value.

Returns:
Value of the metric, 0 is returned if the metric is not an indicator or static metric type.

getTimeStamp

public java.util.GregorianCalendar getTimeStamp()
Returns the metric's TimeStamp value.

Returns:
The Date of the metric or null.

getDataPointCount

public long getDataPointCount()
Returns the metric's count of data points.

Returns:
Count of datapoints added to this metric.

toString

public java.lang.String toString()
The Metric value is returned as a string for logs or screen output.

Overrides:
toString in class java.lang.Object
Returns:
String representation of the metric value.

reset

public void reset()
Resets all values to zero or null.