org.zkoss.util
Interface ListX

All Known Implementing Classes:
AbstractGroup.ChildArray, CheckableTreeArray, Document.ChildArray, Element.AttrArray, TreeArray

public interface ListX

The extended list interface. It provides methods to access the entry of each node in the list.

Any class implementing this interface guarantees the binding between the entry and the element never changes even after removed.

Author:
tomyeh
See Also:
TreeArray

Nested Class Summary
static interface ListX.Entry
          Represents the entry of each node in the list.
 
Method Summary
 ListX.Entry addEntry(int index, java.lang.Object element)
          Inserts the specified element at the specified position in this list.
 ListX.Entry addEntry(ListX.Entry insertBefore, java.lang.Object element)
          Inserts the sepcified element in front of the specified entry.
 ListX.Entry addEntry(java.lang.Object element)
          Appends the specified element to the end of this list.
 ListX.Entry getEntry(int index)
          Gets the entry of the specified index, rather than the element added by List.add.
 int indexOfEntry(ListX.Entry entry)
          Gets the index of the specified entry.
 ListX.Entry removeEntry(int index)
          Remove the entry at the specified location from the list.
 void removeEntry(ListX.Entry entry)
          Remove the entry from the list.
 

Method Detail

getEntry

ListX.Entry getEntry(int index)
Gets the entry of the specified index, rather than the element added by List.add. An entry is an internal representation of an object that holding the element stored by List.add.

The caller should consider the returned entry as opaque. The caller could store it for later use. It is useful when you want to extend the list's features, such as providing two or more indexing methods.

In other words, even if the underlying structure of a list is changed (e.g., a new element is inserted), the caller holding entries won't be affected.

Parameters:
index - the index from which the entry is retrieved
Returns:
the entry

indexOfEntry

int indexOfEntry(ListX.Entry entry)
Gets the index of the specified entry.

Parameters:
entry - the entry to locate
Returns:
the index; -1 if entry is orphan

addEntry

ListX.Entry addEntry(ListX.Entry insertBefore,
                     java.lang.Object element)
Inserts the sepcified element in front of the specified entry.

Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters:
insertBefore - the entry before which an new entry will be inserted; append is assumed if null
element - the element to insert
Returns:
the new entry containing the inserted element.

addEntry

ListX.Entry addEntry(int index,
                     java.lang.Object element)
Inserts the specified element at the specified position in this list. It is an enhanced version of List.add -- it returns the entry containing the element.

Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Returns:
the new entry that conatining the inserted element.

addEntry

ListX.Entry addEntry(java.lang.Object element)
Appends the specified element to the end of this list. It is an enhanced version of List.add -- it returns the entry containing the element.

Parameters:
element - the element to be inserted.
Returns:
the new entry that conatining the inserted element.

removeEntry

void removeEntry(ListX.Entry entry)
Remove the entry from the list. The entry object does not be deleted, and it is just no longer referenced by the list.

Parameters:
entry - the entry returned by getEntry.

removeEntry

ListX.Entry removeEntry(int index)
Remove the entry at the specified location from the list. Unlike List.remove(int), it returns the entry being removed.

Parameters:
index - the location of the entry to remove
Returns:
the entry being removed


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo