com.jamonapi
Class MonitorComposite

java.lang.Object
  |
  +--com.jamonapi.MonitorComposite
All Implemented Interfaces:
CompositeNode, MinimalMonitor, MonitorReportInterface

public class MonitorComposite
extends java.lang.Object
implements MinimalMonitor, CompositeNode, MonitorReportInterface

MonitorComposite can contain other MonitorComposite and TimingMonitors (at the leaf level)


Constructor Summary
MonitorComposite()
           
 
Method Summary
 void addCompositeNode(java.lang.String childNodeName, CompositeNode addNode)
          Add a CompositeNode to the data structure if it doesn't exist.
 void addLeafNode(java.lang.String childNodeName, LeafNode addNode)
          Add a LeafNode to the data structure if it doesn't exist.
 boolean compositeNodeExists(java.lang.String childNodeName)
          Does the passed in CompositeNode exist.
 long getAccrued()
          Returns the accrued value of all Monitors underneath this MonitorComposite.
 java.lang.String getAccruedString()
          Return the accrued value in String format
 CompositeNode getCompositeNode(java.lang.String childNodeName)
          This is CompositeNode interface method that returns the child MonitorComposite identified by the given label or it creates a new CompositeMonitor.
 java.lang.String getCompositeNodeKey(java.lang.String nodeName)
          getCompositeNodeKey(...) and getLeafNodeKey(...) are used to ensure that composite nodes are not replaced by leaf nodes and vice versa.
 java.lang.String[][] getData()
          Return the contents of this MonitorComposite as a 2 dimensional array of Strings.
 void getData(java.util.ArrayList rowData)
          Add this elements value to the ArrayList.
 java.lang.String[][] getData(java.lang.String label)
          Return the contents of this MonitorComposite as a 2 dimensional array of Strings.
 CompositeNode getExistingCompositeNode(java.lang.String childNodeName)
          Returns the CompositeNode if it exists.
 LeafNode getExistingLeafNode(java.lang.String childNodeName)
          Returns the LeafNode if it exists.
 void getHeader(java.util.ArrayList header)
          Add this elements header value to an ArrayList.
 LeafNode getLeafNode(java.lang.String childNodeName, java.lang.String childNodeType)
          This is CompositeNode interface method that returns a leaf node identified by the given label or it creates a new leaf node by calling the Leaf.
 java.lang.String getLeafNodeKey(java.lang.String nodeName)
          getCompositeNodeKey(...) and getLeafNodeKey(...) are used to ensure that composite nodes are not replaced by leaf nodes and vice versa.
 java.lang.String getReport()
          Return the contents of this MonitorComposite as an HTML table.
 java.lang.String getReport(int sortCol, java.lang.String sortOrder)
          Return the contents of this MonitorComposite as an HTML table sorted by the specified column number in ascending or descending order.
 CompositeNode getRootNode()
          Return this MonitorComposite as a CompositeNode
 void increase(long increaseValue)
          Call increase(long) on all Monitors that this MonitorComposite instance contains
 boolean leafNodeExists(java.lang.String childNodeName)
          Does the passed in leaf node exist.
 void reset()
          Call reset() on all Monitors that this MonitorComposite instance contains
static void setDisplayDelimiter(java.lang.String localDisplayDelimiter)
          Delimiter to be used when displaying the monitor label returned by the getReport() and getData() methods.
 java.lang.String toString()
          Display the accrued value as a string
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MonitorComposite

public MonitorComposite()
Method Detail

getAccrued

public long getAccrued()
Returns the accrued value of all Monitors underneath this MonitorComposite. Note this method will recursively call getAccrued() for any nested MonitorComposites. Note this method uses the Gang of 4's Command pattern.

Specified by:
getAccrued in interface MinimalMonitor

toString

public java.lang.String toString()
Display the accrued value as a string

Overrides:
toString in class java.lang.Object

reset

public void reset()
Call reset() on all Monitors that this MonitorComposite instance contains

Specified by:
reset in interface MinimalMonitor

increase

public void increase(long increaseValue)
Call increase(long) on all Monitors that this MonitorComposite instance contains

Specified by:
increase in interface MinimalMonitor

getData

public void getData(java.util.ArrayList rowData)
Description copied from interface: MinimalMonitor
Add this elements value to the ArrayList. This is used to display the Monitor in a tabular format.

Specified by:
getData in interface MinimalMonitor

getHeader

public void getHeader(java.util.ArrayList header)
Description copied from interface: MinimalMonitor
Add this elements header value to an ArrayList. This is used to display the Monitor in a tabular format.

Specified by:
getHeader in interface MinimalMonitor

getReport

public java.lang.String getReport()
                           throws java.lang.Exception
Return the contents of this MonitorComposite as an HTML table. This method is called to display the data in a MonitorComposite in a servlet or JSP. See www.jamonapi.com for a sample of what the report shoud look like. Sample Call: String html=monitorComposite.getReport();

Specified by:
getReport in interface MonitorReportInterface
java.lang.Exception

getReport

public java.lang.String getReport(int sortCol,
                                  java.lang.String sortOrder)
                           throws java.lang.Exception
Return the contents of this MonitorComposite as an HTML table sorted by the specified column number in ascending or descending order. This method is called to display the data in a MonitorComposite in a servlet or JSP. See www.jamonapi.com for a sample of what the report shoud look like. Sample Call: String html=monitorComposite.getReport(2, "asc"); // return the html report sorted by column 2 in ascending order

java.lang.Exception

getData

public java.lang.String[][] getData()
Return the contents of this MonitorComposite as a 2 dimensional array of Strings. This is the data minus the formatting of what is returned by the getReport() method.

Specified by:
getData in interface MonitorReportInterface

getData

public java.lang.String[][] getData(java.lang.String label)
Return the contents of this MonitorComposite as a 2 dimensional array of Strings. The passed "label" will be prepended to the first column in the array. Sample Call: String[][] arr=monitorComposite.getData("myLabel");

Specified by:
getData in interface MonitorReportInterface

setDisplayDelimiter

public static void setDisplayDelimiter(java.lang.String localDisplayDelimiter)
Delimiter to be used when displaying the monitor label returned by the getReport() and getData() methods. The default is a period. A better approach would have been to simply display the delimeter that was used on the MonitorComposites creation


getCompositeNode

public CompositeNode getCompositeNode(java.lang.String childNodeName)
This is CompositeNode interface method that returns the child MonitorComposite identified by the given label or it creates a new CompositeMonitor. This method is used by the factory classes to create MonitorComposites. Sample Call: monitorComposite.getCompositeNode("myApp.jsp")

Specified by:
getCompositeNode in interface CompositeNode

getLeafNode

public LeafNode getLeafNode(java.lang.String childNodeName,
                            java.lang.String childNodeType)
This is CompositeNode interface method that returns a leaf node identified by the given label or it creates a new leaf node by calling the Leaf. This method is used by the factory classes to create TimingMonitors. Sample Call: monitorComposite.getCompositeNode("myApp.jsp");

Specified by:
getLeafNode in interface CompositeNode

addCompositeNode

public void addCompositeNode(java.lang.String childNodeName,
                             CompositeNode addNode)
Add a CompositeNode to the data structure if it doesn't exist.

Specified by:
addCompositeNode in interface CompositeNode

leafNodeExists

public boolean leafNodeExists(java.lang.String childNodeName)
Does the passed in leaf node exist. Returns true if there has been a LeafNode created with this label. Sample Call: monitorComposite.leafNodeExists("myApp.jsp.homePage");

Specified by:
leafNodeExists in interface CompositeNode

compositeNodeExists

public boolean compositeNodeExists(java.lang.String childNodeName)
Does the passed in CompositeNode exist. Returns true if there has been a CompositeNode created with this label. Sample Call: monitorComposite.compositeNodeExists("myApp.jsp");

Specified by:
compositeNodeExists in interface CompositeNode

getExistingCompositeNode

public CompositeNode getExistingCompositeNode(java.lang.String childNodeName)
Returns the CompositeNode if it exists. Sample Call: monitorComposite.compositeNodeExists("myApp.jsp");


getExistingLeafNode

public LeafNode getExistingLeafNode(java.lang.String childNodeName)
Returns the LeafNode if it exists. Sample Call: monitorComposite.compositeNodeExists("myApp.jsp");


addLeafNode

public void addLeafNode(java.lang.String childNodeName,
                        LeafNode addNode)
Add a LeafNode to the data structure if it doesn't exist.

Specified by:
addLeafNode in interface CompositeNode

getRootNode

public CompositeNode getRootNode()
Return this MonitorComposite as a CompositeNode

Specified by:
getRootNode in interface CompositeNode

getCompositeNodeKey

public java.lang.String getCompositeNodeKey(java.lang.String nodeName)
getCompositeNodeKey(...) and getLeafNodeKey(...) are used to ensure that composite nodes are not replaced by leaf nodes and vice versa. For example the following 2 entries could both be simultaneously valid even though their labels are identical. Leaf Node: pages.homePage Composite Node: pages.homePage This is because leafs and composites have different keys behind the scenes. Using the example above the keys may look something like: Leaf Node Key: pagesC.homePageL Composite Node: pagesC.homePageC

Specified by:
getCompositeNodeKey in interface CompositeNode

getLeafNodeKey

public java.lang.String getLeafNodeKey(java.lang.String nodeName)
getCompositeNodeKey(...) and getLeafNodeKey(...) are used to ensure that composite nodes are not replaced by leaf nodes and vice versa. For example the following 2 entries could both be simultaneously valid even though their labels are identical. Leaf Node: pages.homePage Composite Node: pages.homePage This is because leafs and composites have different keys behind the scenes. Using the example above the keys may look something like: Leaf Node Key: pagesC.homePageL Composite Node: pagesC.homePageC

Specified by:
getLeafNodeKey in interface CompositeNode

getAccruedString

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