com.jamonapi
Class CompositeListener

java.lang.Object
  extended by com.jamonapi.CompositeListener
All Implemented Interfaces:
JAMonListener, DetailData, java.util.EventListener

public class CompositeListener
extends java.lang.Object
implements JAMonListener, DetailData

A class that can contain other listeners that can listen to jamon events of interest. These classes will all implement the JAMonListener interface too. This is an example of the Gang of 4 Composite design pattern.

Author:
steve souza

Constructor Summary
CompositeListener()
          Uses the CompositeListener name
CompositeListener(java.lang.String name)
          Pass in a Listener name that allows you to differentiate this listener from others
 
Method Summary
 CompositeListener addListener(JAMonListener listener)
          Add a listener to the composite and return this object
 java.lang.Object[][] getData()
          Return all the monitors in the composite
static java.lang.Object[][] getData(JAMonListener listener)
           
 java.lang.String[] getHeader()
           
static java.lang.String[] getHeader(JAMonListener listener)
           
 JAMonListener getListener(int index)
          Return the listener associated with the index
 JAMonListener getListener(java.lang.String listenerName)
          Return the listener associated with the passed in name
 java.lang.String getName()
          Return the name of this instance
 int getNumListeners()
          Return the number of listeners
 int getRowCount()
          Also returns the number of listeners
 boolean hasData()
           
 boolean hasListener(java.lang.String listenerName)
          return true if the named listener exists
 boolean isEmpty()
           
 java.util.Iterator iterator()
          Get an iterator that will contain the Composite's JAMonListener objects.
 void processEvent(Monitor mon)
          Notify all listeners that are part of this composite of a jamon event and pass them the monitor that triggered the event.
 CompositeListener removeListener(java.lang.String listenerName)
          Remove the named listener from this CompositeListener
 void setName(java.lang.String name)
          sets the name of this monitor instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeListener

public CompositeListener()
Uses the CompositeListener name


CompositeListener

public CompositeListener(java.lang.String name)
Pass in a Listener name that allows you to differentiate this listener from others

Method Detail

addListener

public CompositeListener addListener(JAMonListener listener)
Add a listener to the composite and return this object


getListener

public JAMonListener getListener(java.lang.String listenerName)
Return the listener associated with the passed in name


getListener

public JAMonListener getListener(int index)
Return the listener associated with the index


removeListener

public CompositeListener removeListener(java.lang.String listenerName)
Remove the named listener from this CompositeListener


hasListener

public boolean hasListener(java.lang.String listenerName)
return true if the named listener exists


getNumListeners

public int getNumListeners()
Return the number of listeners


getRowCount

public int getRowCount()
Also returns the number of listeners


getName

public java.lang.String getName()
Return the name of this instance

Specified by:
getName in interface JAMonListener

setName

public void setName(java.lang.String name)
sets the name of this monitor instance

Specified by:
setName in interface JAMonListener

processEvent

public void processEvent(Monitor mon)
Notify all listeners that are part of this composite of a jamon event and pass them the monitor that triggered the event.

Specified by:
processEvent in interface JAMonListener

iterator

public java.util.Iterator iterator()
Get an iterator that will contain the Composite's JAMonListener objects. The objects will be safe cast to JAMonListener


isEmpty

public boolean isEmpty()

hasData

public boolean hasData()

getData

public java.lang.Object[][] getData()
Return all the monitors in the composite

Specified by:
getData in interface DetailData

getHeader

public java.lang.String[] getHeader()
Specified by:
getHeader in interface DetailData

getData

public static java.lang.Object[][] getData(JAMonListener listener)

getHeader

public static java.lang.String[] getHeader(JAMonListener listener)