org.jlf.vitals
Class AbstractVitalMeasurement

java.lang.Object
  |
  +--org.jlf.vitals.AbstractVitalMeasurement
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
LongVitalMeasurement

public abstract class AbstractVitalMeasurement
extends java.lang.Object
implements java.lang.Comparable

AbstractVitalMeasurement is a class that holds a measurement of a vital sign, such as number of milliseconds to execute a task or requests per second. This class is abstract to be flexible to accommodate any type of vital sign capture in a subclass.


Field Summary
protected  java.util.Date dateCaptured
          Captures the date of the measurement.
protected  java.lang.String measurementUnit
          Holds the measurement unit to be displayed.
protected  java.lang.String message
          Holds an optional message that can be attached to the measurement.
 
Constructor Summary
AbstractVitalMeasurement()
           
 
Method Summary
abstract  AbstractVitalMeasurement add(AbstractVitalMeasurement measurement)
          Adds one measurement to another, so it can be summed for operations like averaging.
protected  void checkMeasurementType(java.lang.Object measurement)
          Helper method to check the type of measurement and make sure it is not null and alike.
abstract  AbstractVitalMeasurement divideBy(double divisor)
          Divides the measurement by the value input to perform operations like an average.
 java.util.Date getDateCaptured()
          Returns the dateCaptured.
 java.lang.String getMeasurementUnit()
          Returns the measurementUnit.
 java.lang.String getMessage()
          Returns the message held in the vital measurement.
 VitalSign register(java.lang.String vitalKey)
          Registers the current measurement with a vital sign according to the key given as input.
 void setMeasurementUnit(java.lang.String measurementUnit)
          Sets the measurementUnit.
 void setMessage(java.lang.String message)
          Sets a message in the measurement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

dateCaptured

protected java.util.Date dateCaptured
Captures the date of the measurement.


measurementUnit

protected java.lang.String measurementUnit
Holds the measurement unit to be displayed. For example, number of bytes, requests per second, pooled resources.


message

protected java.lang.String message
Holds an optional message that can be attached to the measurement.

Constructor Detail

AbstractVitalMeasurement

public AbstractVitalMeasurement()
Method Detail

checkMeasurementType

protected void checkMeasurementType(java.lang.Object measurement)
Helper method to check the type of measurement and make sure it is not null and alike.


register

public VitalSign register(java.lang.String vitalKey)
Registers the current measurement with a vital sign according to the key given as input.

Returns:
The vital sign the measurement was registered with

add

public abstract AbstractVitalMeasurement add(AbstractVitalMeasurement measurement)
Adds one measurement to another, so it can be summed for operations like averaging.

Returns:
A new measurement that adds the current measurement to the input measurement

divideBy

public abstract AbstractVitalMeasurement divideBy(double divisor)
Divides the measurement by the value input to perform operations like an average.

Returns:
A new measurement that adds the current measurement to the input measurement

getDateCaptured

public java.util.Date getDateCaptured()
Returns the dateCaptured.


getMeasurementUnit

public java.lang.String getMeasurementUnit()
Returns the measurementUnit.

Returns:
String

setMeasurementUnit

public void setMeasurementUnit(java.lang.String measurementUnit)
Sets the measurementUnit.

Parameters:
measurementUnit - The measurementUnit to set

getMessage

public java.lang.String getMessage()
Returns the message held in the vital measurement.

Returns:
String

setMessage

public void setMessage(java.lang.String message)
Sets a message in the measurement.

Parameters:
message - The message to set