ca.odell.glazedlists.calculation
Class AbstractCalculation<N>

java.lang.Object
  extended by ca.odell.glazedlists.calculation.AbstractCalculation<N>
All Implemented Interfaces:
Calculation<N>
Direct Known Subclasses:
AbstractCompositeCalculation, AbstractEventListCalculation

public abstract class AbstractCalculation<N>
extends Object
implements Calculation<N>

Eases the burdens of implementing any type of Calculation. It stores the last numeric result which represents the Calculation. It provides support for managing the PropertyChangeListeners and firing value changes to them.

Author:
James Lemieux

Constructor Summary
AbstractCalculation(N initialValue)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener pcl)
           
protected  void fireValueChange(N oldValue, N newValue)
          A convenience method for firing a PropertyChangeEvent describing a change in the value of this calculation.
 String getName()
           
 N getValue()
           
 void removePropertyChangeListener(PropertyChangeListener pcl)
           
 void setName(String name)
          Adjusts the Calculation to have the new name;
protected  void setValue(N value)
          Subclasses should call this method in order to update the value that is reported from this calculation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ca.odell.glazedlists.calculation.Calculation
dispose
 

Constructor Detail

AbstractCalculation

public AbstractCalculation(N initialValue)
Parameters:
initialValue - the value that should immediately be reported as the value of this Calculation
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener pcl)
Specified by:
addPropertyChangeListener in interface Calculation<N>
Parameters:
pcl - a PropertyChangeListener to notify any time the value changes

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener pcl)
Specified by:
removePropertyChangeListener in interface Calculation<N>
Parameters:
pcl - a PropertyChangeListener which should no longer be notified of value changes

getName

public String getName()
Specified by:
getName in interface Calculation<N>
Returns:
a human readable name for this Calculation

setName

public void setName(String name)
Description copied from interface: Calculation
Adjusts the Calculation to have the new name;

Specified by:
setName in interface Calculation<N>
Parameters:
name - the new human-readable name of this Calculation

getValue

public N getValue()
Specified by:
getValue in interface Calculation<N>
Returns:
the latest calculated value

setValue

protected void setValue(N value)
Subclasses should call this method in order to update the value that is reported from this calculation. Note: this method does NOT fire a PropertyChangeEvent. Subclasses must do that at appropriate times using fireValueChange(Object, Object).

Parameters:
value - the new value of this calculation

fireValueChange

protected void fireValueChange(N oldValue,
                               N newValue)
A convenience method for firing a PropertyChangeEvent describing a change in the value of this calculation.

Parameters:
oldValue - the old value reported from this calculation
newValue - the new value reported from this calculation


Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by hbrands at 2015-02-16 14:02