net.java.dev.moskito.core.stats.impl
Class IntervalImpl

java.lang.Object
  extended by net.java.dev.moskito.core.stats.impl.IntervalImpl
All Implemented Interfaces:
Interval, IUpdateable

 class IntervalImpl
extends Object
implements IUpdateable, Interval

This class implements an Inveral with a name and an unique id that is furthermore a registry for primary and secondary update listeners. On calling the update() method it will notify the primary listener first and afterwards the secondary listeners.

Author:
dvayanu

Field Summary
private  int id
          This is the unique interval id.
private  int length
          This is the length of the interval in seconds.
private  String name
          This is the human readable name of this Interval.
private  List<IIntervalListener> primaryIntervalListeners
          This List holds all primary listeners.
private  List<IIntervalListener> secondaryIntervalListeners
          This List holds all secondary listeners.
 
Constructor Summary
IntervalImpl(int anId, String aName, int aLength)
          This is the constructor.
 
Method Summary
 void addPrimaryIntervalListener(IIntervalListener aListener)
          This method adds a listener as primary listener.
 void addSecondaryIntervalListener(IIntervalListener aListener)
          This method adds a listener as primary listener.
 int getId()
          This method returns the interval id.
 int getLength()
          This method returns the interval length in seconds.
 String getName()
          This method returns the interval name.
private  void notifyListeners(List<IIntervalListener> aListeners)
          This method notifies all listeners in the given List.
 void removePrimaryIntervalListener(IIntervalListener aListener)
          This method removes the given listener from the primary listeners.
 void removeSecondaryIntervalListener(IIntervalListener aListener)
          This method removes the given listener from the primary listeners.
 String toString()
           
 void update()
          This method will be called if an update occures.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private String name
This is the human readable name of this Interval.


id

private int id
This is the unique interval id.


length

private int length
This is the length of the interval in seconds.


primaryIntervalListeners

private List<IIntervalListener> primaryIntervalListeners
This List holds all primary listeners.


secondaryIntervalListeners

private List<IIntervalListener> secondaryIntervalListeners
This List holds all secondary listeners.

Constructor Detail

IntervalImpl

public IntervalImpl(int anId,
                    String aName,
                    int aLength)
This is the constructor.

Parameters:
anId - the id
aName - the name
aLength - the interval length in seconds
Method Detail

addPrimaryIntervalListener

public void addPrimaryIntervalListener(IIntervalListener aListener)
Description copied from interface: Interval
This method adds a listener as primary listener.

Specified by:
addPrimaryIntervalListener in interface Interval
Parameters:
aListener - the new listener
See Also:
Interval.addPrimaryIntervalListener(net.java.dev.moskito.core.stats.IIntervalListener)

removePrimaryIntervalListener

public void removePrimaryIntervalListener(IIntervalListener aListener)
Description copied from interface: Interval
This method removes the given listener from the primary listeners.

Specified by:
removePrimaryIntervalListener in interface Interval
Parameters:
aListener - the listener to remove.
See Also:
Interval.removePrimaryIntervalListener(net.java.dev.moskito.core.stats.IIntervalListener)

addSecondaryIntervalListener

public void addSecondaryIntervalListener(IIntervalListener aListener)
Description copied from interface: Interval
This method adds a listener as primary listener.

Specified by:
addSecondaryIntervalListener in interface Interval
Parameters:
aListener - the new listener
See Also:
Interval.addSecondaryIntervalListener(net.java.dev.moskito.core.stats.IIntervalListener)

removeSecondaryIntervalListener

public void removeSecondaryIntervalListener(IIntervalListener aListener)
Description copied from interface: Interval
This method removes the given listener from the primary listeners.

Specified by:
removeSecondaryIntervalListener in interface Interval
Parameters:
aListener - the listener to remove.
See Also:
Interval.removeSecondaryIntervalListener(net.java.dev.moskito.core.stats.IIntervalListener)

getId

public int getId()
Description copied from interface: Interval
This method returns the interval id.

Specified by:
getId in interface Interval
Returns:
the interval id
See Also:
Interval.getId()

getName

public String getName()
Description copied from interface: Interval
This method returns the interval name.

Specified by:
getName in interface Interval
Returns:
the interval name
See Also:
Interval.getName()

getLength

public int getLength()
Description copied from interface: Interval
This method returns the interval length in seconds.

Specified by:
getLength in interface Interval
Returns:
the interval length in seconds
See Also:
Interval.getLength()

update

public void update()
Description copied from interface: IUpdateable
This method will be called if an update occures.

Specified by:
update in interface IUpdateable
See Also:
IUpdateable.update()

notifyListeners

private void notifyListeners(List<IIntervalListener> aListeners)
This method notifies all listeners in the given List.

Parameters:
aListeners - the List of listeners

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2006 MoSKito Project Team. All Rights Reserved.
MoSKito, the open source java monitoring framework