ca.odell.glazedlists.event
Class ListEvent<E>

java.lang.Object
  extended by java.util.EventObject
      extended by ca.odell.glazedlists.event.ListEvent<E>
All Implemented Interfaces:
Serializable

public final class ListEvent<E>
extends EventObject

A ListEvent models a change to a list.

The lists may change over time, causing this sequence of changes to grow indefinitely. The event is accessed like an iterator, with the user calling next() repeatedly to view the changes in sequence.

It is also possible to view changes in blocks, which may provide some performance benefit. To use this, use the nextBlock() method instead of the next() method.

Author:
Jesse Wilson
See Also:
Serialized Form

Field Summary
static int DELETE
          different types of changes
static int INSERT
           
static int UPDATE
           
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
ListEvent(ListEvent<E> original)
          Creates a clone of this ListEvent, in order to iterate through the changes multiple times.
 
Method Summary
 int getBlockEndIndex()
          Gets the last row of the current block of changes.
 int getBlocksRemaining()
          Gets the number of blocks currently remaining in this atomic change.
 int getBlockStartIndex()
          Gets the first row of the current block of changes.
 int getIndex()
          Gets the current row index.
 int[] getReorderMap()
          Gets the reorder map of this list.
 EventList<E> getSourceList()
          Gets the List where this event originally occured.
 int getType()
          Gets the type of the current change, which should be one of ListEvent.INSERT, UPDATE, or DELETE.
 boolean hasNext()
          Without incrementing the implicit iterator, this tests if there is another change to view.
 boolean isReordering()
          Tests if this change is a complete reordering of the list.
 boolean next()
          Increments the change sequence to view the next change.
 boolean nextBlock()
          Increments the change sequence to view the next change block.
 void reset()
          Resets this event's position to the previously-marked position.
 String toString()
          Gets this event as a String.
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DELETE

public static final int DELETE
different types of changes

See Also:
Constant Field Values

UPDATE

public static final int UPDATE
See Also:
Constant Field Values

INSERT

public static final int INSERT
See Also:
Constant Field Values
Constructor Detail

ListEvent

public ListEvent(ListEvent<E> original)
Creates a clone of this ListEvent, in order to iterate through the changes multiple times. You should always be sure to iterate through all values in the original instance in order to reach the freshest changes.

Because the master change sequence does not know about clones, it is possible that the change information stored in the master list will be cleaned up without notifying the clone. In order to prevent this, you should always use the clone list before using the original list - this way the existance of values in the original list guarantees that such values will be visible to the clone.

Method Detail

reset

public void reset()
Resets this event's position to the previously-marked position. This should be used for TransformedLists that require multiple-passes of the ListEvent in order to process it.


next

public boolean next()
Increments the change sequence to view the next change. This will return true if such a change exists and false when there is no change to view.


hasNext

public boolean hasNext()
Without incrementing the implicit iterator, this tests if there is another change to view. The user will still need to call next() to view such a change.


nextBlock

public boolean nextBlock()
Increments the change sequence to view the next change block.


isReordering

public boolean isReordering()
Tests if this change is a complete reordering of the list.


getReorderMap

public int[] getReorderMap()
Gets the reorder map of this list. This will also increment the change sequence to the next change.

Returns:
an array of integers where the the previous index of a value is stored at the current index of that value.

getIndex

public int getIndex()
Gets the current row index. If the block type is delete, this will always return the startIndex of the current list change.


getBlockStartIndex

public int getBlockStartIndex()
Gets the first row of the current block of changes. Inclusive.


getBlockEndIndex

public int getBlockEndIndex()
Gets the last row of the current block of changes. Inclusive.


getType

public int getType()
Gets the type of the current change, which should be one of ListEvent.INSERT, UPDATE, or DELETE.


getBlocksRemaining

public int getBlocksRemaining()
Gets the number of blocks currently remaining in this atomic change.


getSourceList

public EventList<E> getSourceList()
Gets the List where this event originally occured.


toString

public String toString()
Gets this event as a String. This simply iterates through all blocks and concatenates them.

Overrides:
toString in class EventObject


Glazed Lists 1.5.0, Copyright © 2003-2005 publicobject.com, O'Dell Engineering.
Documentation build by James Lemieux at 2005-12-21 23:25