fr.gael.drb
Class DrbDefaultNodeList
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<DrbItem>
fr.gael.drb.DrbDefaultSequence
fr.gael.drb.DrbDefaultNodeList
- All Implemented Interfaces:
- DrbNodeList, DrbSequence, Serializable, Cloneable, Iterable<DrbItem>, Collection<DrbItem>, List<DrbItem>, RandomAccess
public class DrbDefaultNodeList
- extends DrbDefaultSequence
- implements DrbNodeList
Generic implementation of DrbNodeList. This default implementation of
DrbNodeList extends a ArrayList provided by Java API. It is a generic mean to
create a list of nodes. If no specific operations are required to implement
the DrbNodeList (e.g. filters, caching, hashing, etc.) this class is a simple
mean to represent a collection of nodes. Note : the add() or equivalent
operations of the ArrayList class have not been overrided to insure they
insert DrbNode intances. Some inconsistency may appear if no care is taken
while calling add() or equivalent operations.
- See Also:
- Serialized Form
| Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
DrbDefaultNodeList
public DrbDefaultNodeList()
item
public DrbNode item(int index)
- Returns a specific item of the list. This operation wraps the
ArrayList.get() operation. The exception that ArrayList.get() can raise is
however traped and not propagated. In such case a message is written to
the error output and the operation returns null without throwing any
exception.
- Specified by:
item in interface DrbNodeList
- Parameters:
index - The position of the item starting from 0 and not greater or
equal to the item count in the list.
- Returns:
- A reference to specified item or null if no such node.
getNamedItem
public DrbNode getNamedItem(String name,
int occurence)
- Returns an occurence of item matching a specific name. The occurence
number starts from 1. The name is a local name without any prefix.A null
reference is returned if the provided occurrence is outside the list
bounds.
- Specified by:
getNamedItem in interface DrbNodeList
- Parameters:
name - The name to match.occurence - The occurence number of the desired child.
- Returns:
- A reference to specified item or null if no such node.
addItem
public DrbSequence addItem(int index,
DrbItem item)
throws NullPointerException,
UnsupportedOperationException,
IndexOutOfBoundsException
- Inserts a item at a given position. The passed item is inserted in the
list of children at the given position The position is the expected index
of the item after insertion. All the previous item from the aimed position
to the end of the list are shift to the end of the new sequence (i.e.
their indices are shifted up of 1). If the given index is out of the
sequence bounds and therefore less than zero and greater or equal to the
current number of items,the operation raises an exception. An index equal
to the current number of item is allowed and the operation is therefore
equivalent to an append.
- Specified by:
addItem in interface DrbSequence- Overrides:
addItem in class DrbDefaultSequence
- Parameters:
index - The expected index of the item after the insertion.item - A reference to the item to be inserted.
- Returns:
- A reference to the a sequence containing the inserted node.
- Throws:
NullPointerException - This exception is raised when the passed item
a null reference. This exception may be overriden by an
UnsupportedOperationException.
IndexOutOfBoundsException - This exception is raised when the passe
index is less than zero or if it is greater or equal to the
number of item in the sequence prior the call
UnsupportedOperationException - This exception is raised when the
implementation does not support the requested insertion for any
reason (e.g. impossible in this current specific case or in
general).
toString
public String toString()
- Prints the node list contents. The items of the list are printed on a line
by line basis.
- Overrides:
toString in class DrbDefaultSequence
- Returns:
- The list as a String or an emtpy string if the list contains no
item.
Copyright© 2001-2009 GAEL Consultant. All rights reserved. Use is subject to license terms .