com.jamonapi
Class AccumulateMonitor

java.lang.Object
  |
  +--com.jamonapi.AccumulateMonitor
All Implemented Interfaces:
AccumulateMonitorInterface, MinimalMonitor
Direct Known Subclasses:
ActiveStatsMonitor, LastAccessMonitor, TimeStatsDistMonitor, TimeStatsMonitor

public class AccumulateMonitor
extends java.lang.Object
implements AccumulateMonitorInterface

AccumulateMonitors represent Monitors that increase in value. AccumulateMonitors use the Gang of 4's decorator pattern to pass method invocations to the next Monitor in the chain. Note many of the public methods such as start(), stop() and reset() call the same method of next Monitor in the decorator chain. Any classes that inherit from AccumulateMonitor implement the protected methods startThis(), stopThis(), and resetThis() and leave the public methods as is. In general the various ...This() (startThis(), stopThis(), resetThis()) methods perform the action on that instance and the methods without ...This() (start(), stop(), reset()) take care of passing the command down the decorator chain.


Constructor Summary
AccumulateMonitor()
          Default constructor.
AccumulateMonitor(AccumulateMonitorInterface childMonitor)
          Monitors use the Gang of 4 decorator pattern where each monitor points to and calls the next monitor in the chain.
 
Method Summary
 long getAccrued()
          Get the value of the monitor.
 java.lang.String getAccruedString()
          Return the accrued value in String format
 void getData(java.util.ArrayList rowData)
          Populate the ArrayList with data from this Monitor as well as all other Monitors in the decorator chain
 void getHeader(java.util.ArrayList header)
          Add the display header that is associated with this Monitor to the header (as an ArrayList entry).
 java.lang.String getType()
          Display this Monitors type
 java.lang.String getUnits()
          Dispay the units appropriate for this monitor
 void increase()
          Increase the monitors accrued value by 1 unit.
 void increase(long increaseValue)
          Increase the monitors accrued value by the ammount specified in the parameter, and call increase on all monitors in the decorator chain.
 boolean isPrimary()
          Indicates whether or not this Monitor is primary.
static void main(java.lang.String[] args)
          Method that calls test code for this class.
 void reset()
          Erase/wipe out any accrued statistics for this monitor, and call reset on all monitors in the decorator chain Sample Call: monitor.reset();
 void setPrimary(boolean primary)
          Specify whether or not this Monitor is primary.
 void start()
          Start gathering statistics for this Monitor.
 void stop()
          Stop gathering statistics for the Monitor.
 java.lang.String toString()
          Display this Monitor as well as all Monitor's in the decorator chain as Strings
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AccumulateMonitor

public AccumulateMonitor()
Default constructor. Note Monitors use the Gang of 4 decorator pattern where each monitor points to and calls the next monitor in the chain. With the default constructor there is no need for a next Monitors in the chain, but to keep the logic identical to when there is a next Monitor in the chain a NullMonitor (that does nothing) is used as the next Monitor to call in the decorator pattern. Martin Fowler's Refactoring book discusses NullMonitor's.


AccumulateMonitor

public AccumulateMonitor(AccumulateMonitorInterface childMonitor)
Monitors use the Gang of 4 decorator pattern where each monitor points to and calls the next monitor in the chain. This constructor as its argument takes the next AccumulateMonitor in the chain. Sample Call: AccumulateMonitor mon=new AccumulateMonitor(new AccumulateMonitor(new AccumulateMonitor()));

Method Detail

getAccrued

public long getAccrued()
Get the value of the monitor. What this value means depends on what the monitor does. In the case of a Timing monitor it would be the elapsed time since the monitor was started. Sample call: long accrued=monitor.getAccrued();

Specified by:
getAccrued in interface MinimalMonitor

increase

public void increase(long increaseValue)
Increase the monitors accrued value by the ammount specified in the parameter, and call increase on all monitors in the decorator chain. Sample Call: monitor.increase(100);

Specified by:
increase in interface MinimalMonitor

increase

public void increase()
Increase the monitors accrued value by 1 unit. Sample Call: monitor.increase();

Specified by:
increase in interface AccumulateMonitorInterface

reset

public void reset()
Erase/wipe out any accrued statistics for this monitor, and call reset on all monitors in the decorator chain Sample Call: monitor.reset();

Specified by:
reset in interface MinimalMonitor

toString

public java.lang.String toString()
Display this Monitor as well as all Monitor's in the decorator chain as Strings

Overrides:
toString in class java.lang.Object

getUnits

public java.lang.String getUnits()
Dispay the units appropriate for this monitor


getType

public java.lang.String getType()
Display this Monitors type


getData

public void getData(java.util.ArrayList rowData)
Populate the ArrayList with data from this Monitor as well as all other Monitors in the decorator chain

Specified by:
getData in interface MinimalMonitor

start

public void start()
Start gathering statistics for this Monitor. The Monitor will run until the stop() method is called. start() will also call the start() method for all other Monitors in the decorator chain.

Specified by:
start in interface AccumulateMonitorInterface

stop

public void stop()
Stop gathering statistics for the Monitor. stop() is called after a Monitor has been started with the start() method. stop() will also call the stop() method for all Monitors in the decorator chain.

Specified by:
stop in interface AccumulateMonitorInterface

getAccruedString

public java.lang.String getAccruedString()
Return the accrued value in String format


getHeader

public void getHeader(java.util.ArrayList header)
Add the display header that is associated with this Monitor to the header (as an ArrayList entry). Also give all Monitors in the decorator chain the opportunity to add their header entries.

Specified by:
getHeader in interface MinimalMonitor

isPrimary

public boolean isPrimary()
Indicates whether or not this Monitor is primary. See www.jamonapi.com for an explanation of primary Monitors.

Specified by:
isPrimary in interface AccumulateMonitorInterface

setPrimary

public void setPrimary(boolean primary)
Specify whether or not this Monitor is primary. See www.jamonapi.com for an explanation of primary Monitors. Call setPrimary() for all Monitors in the decorator chain

Specified by:
setPrimary in interface AccumulateMonitorInterface

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Method that calls test code for this class.

java.lang.Exception