ca.odell.glazedlists.calculation
Class AbstractEventListCalculation<N,E>

java.lang.Object
  extended by ca.odell.glazedlists.calculation.AbstractCalculation<N>
      extended by ca.odell.glazedlists.calculation.AbstractEventListCalculation<N,E>
All Implemented Interfaces:
Calculation<N>, ListEventListener<E>, EventListener

public abstract class AbstractEventListCalculation<N,E>
extends AbstractCalculation<N>
implements ListEventListener<E>

The transition between an EventList and a single calculated value based on information from each element of the EventList happens in subclasses of this class. To ease the job of maintaining the value of the Calculation when the backing EventList changes, this abstract class provides three abstract methods which must be implemented:

Author:
James Lemieux

Constructor Summary
protected AbstractEventListCalculation(N initialValue, EventList<E> source)
           
 
Method Summary
protected abstract  void deleted(E oldElement)
          Updates the value of this Calculation to exclude the information from the oldElement.
 void dispose()
          Releases the resources consumed by this AbstractEventListCalculation so that it may eventually be garbage collected.
protected abstract  void inserted(E newElement)
          Updates the value of this Calculation to include the information from the newElement.
 void listChanged(ListEvent<E> listChanges)
          Updates the value of this Calculation in response to the listChanges.
protected abstract  void updated(E oldElement, E newElement)
          Updates the value of this Calculation to exclude the information from the oldElement and include the information from the newElement.
 
Methods inherited from class ca.odell.glazedlists.calculation.AbstractCalculation
addPropertyChangeListener, fireValueChange, getName, getValue, removePropertyChangeListener, setName, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEventListCalculation

protected AbstractEventListCalculation(N initialValue,
                                       EventList<E> source)
Parameters:
initialValue - the value that should immediately be reported as the value of this Calculation
source - the List of elements from which this calculation is derived
Method Detail

dispose

public void dispose()
Releases the resources consumed by this AbstractEventListCalculation so that it may eventually be garbage collected.

An AbstractEventListCalculation will be garbage collected without a call to dispose(), but not before its source EventList is garbage collected. By calling dispose(), you allow the AbstractEventListCalculation to be garbage collected before its source EventList. This is necessary for situations where an AbstractEventListCalculation is short-lived but its source EventList is long-lived.

Specified by:
dispose in interface Calculation<N>

inserted

protected abstract void inserted(E newElement)
Updates the value of this Calculation to include the information from the newElement.

Parameters:
newElement - the new element within the EventList

deleted

protected abstract void deleted(E oldElement)
Updates the value of this Calculation to exclude the information from the oldElement.

Parameters:
oldElement - the old element within the EventList

updated

protected abstract void updated(E oldElement,
                                E newElement)
Updates the value of this Calculation to exclude the information from the oldElement and include the information from the newElement.

Parameters:
oldElement - the old element within the EventList
newElement - the new element which replaced the oldElement

listChanged

public void listChanged(ListEvent<E> listChanges)
Updates the value of this Calculation in response to the listChanges.

Specified by:
listChanged in interface ListEventListener<E>
Parameters:
listChanges - describes the changes to the backing EventList


Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by hbrands at 2013-02-12 20:58