Data Request Broker
2-3-release

fr.gael.drb
Class DrbDefaultNodeList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<DrbItem>
              extended by fr.gael.drb.DrbDefaultSequence
                  extended by 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

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
DrbDefaultNodeList()
           
 
Method Summary
 DrbSequence addItem(int index, DrbItem item)
          Inserts a item at a given position.
 DrbNode getNamedItem(String name, int occurence)
          Returns an occurence of item matching a specific name.
 DrbNode item(int index)
          Returns a specific item of the list.
 String toString()
          Prints the node list contents.
 
Methods inherited from class fr.gael.drb.DrbDefaultSequence
addItem, atomize, getItem, getLength, main, removeItem
 
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
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface fr.gael.drb.DrbNodeList
getLength
 
Methods inherited from interface fr.gael.drb.DrbSequence
atomize, getItem, removeItem
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

DrbDefaultNodeList

public DrbDefaultNodeList()
Method Detail

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.

Data Request Broker - DRB API®
2-3-release

Copyright© 2001-2009 GAEL Consultant. All rights reserved. Use is subject to license terms .