org.opensaml.xml.util
Class XMLObjectChildrenList<ElementType extends XMLObject>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<ElementType>
          extended by org.opensaml.xml.util.XMLObjectChildrenList<ElementType>
Type Parameters:
ElementType - type of elements added to the list
All Implemented Interfaces:
Iterable<ElementType>, Collection<ElementType>, List<ElementType>
Direct Known Subclasses:
IndexedXMLObjectChildrenList

public class XMLObjectChildrenList<ElementType extends XMLObject>
extends AbstractList<ElementType>

Resizable list for the children of XMLObjects. This list implements all optional List operations and does not all for null elements. XMLObjects added to, or removed from, this list will have their parent object appropriately set and, the underlying DOM will be released during mutation opertions.


Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
XMLObjectChildrenList(XMLObject newParent)
          Constructs an empty list with all added XMLObjects being assigned the given parent XMLObject.
XMLObjectChildrenList(XMLObject newParent, Collection<ElementType> newElements)
          Constructs a list containing the elements in the specified collection, in the order they are returned by the collection's iterator, with each added XMLObject assigned the given parent XMLObject.
 
Method Summary
 void add(int index, ElementType element)
          Adds the given XMLObject to this list.
 boolean contains(ElementType element)
          Checks to see if the given element is contained in this list.
 ElementType get(int index)
          
 boolean remove(ElementType element)
          Removes the element from the list.
 ElementType remove(int index)
          
 ElementType set(int index, ElementType element)
          Replaces the XMLObject at the specified index with the given element.
protected  void setParent(ElementType element)
          Assigned the parent, given at list construction, to the given element if the element does not have a parent or its parent matches the one given at list construction time.
 int size()
          
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

XMLObjectChildrenList

public XMLObjectChildrenList(XMLObject newParent)
                      throws NullPointerException
Constructs an empty list with all added XMLObjects being assigned the given parent XMLObject.

Parameters:
newParent - the parent for all the added XMLObjects
Throws:
NullPointerException - thrown if the parent is null

XMLObjectChildrenList

public XMLObjectChildrenList(XMLObject newParent,
                             Collection<ElementType> newElements)
                      throws NullPointerException
Constructs a list containing the elements in the specified collection, in the order they are returned by the collection's iterator, with each added XMLObject assigned the given parent XMLObject.

Parameters:
newParent - the parent for all the added XMLObjects
newElements - the elements to be added
Throws:
NullPointerException - thrown if the parent is null
IllegalArgumentException - thrown if any of the XMLObjects in the given collection already have a parent that is different from the given parent
Method Detail

size

public int size()

Specified by:
size in interface Collection<ElementType extends XMLObject>
Specified by:
size in interface List<ElementType extends XMLObject>
Specified by:
size in class AbstractCollection<ElementType extends XMLObject>

contains

public boolean contains(ElementType element)
Checks to see if the given element is contained in this list.

Parameters:
element - the element to check for
Returns:
true if the element is in this list, false if not

get

public ElementType get(int index)

Specified by:
get in interface List<ElementType extends XMLObject>
Specified by:
get in class AbstractList<ElementType extends XMLObject>

set

public ElementType set(int index,
                       ElementType element)
                                  throws IllegalArgumentException
Replaces the XMLObject at the specified index with the given element.

Specified by:
set in interface List<ElementType extends XMLObject>
Overrides:
set in class AbstractList<ElementType extends XMLObject>
Parameters:
index - index of the XMLObject to be replaced
element - element to be stored at the given index
Returns:
the replaced XMLObject
Throws:
IllegalArgumentException - thrown if the given XMLObject already has a parent that is different from the XMLObject given at list construction time

add

public void add(int index,
                ElementType element)
         throws IllegalArgumentException
Adds the given XMLObject to this list.

Specified by:
add in interface List<ElementType extends XMLObject>
Overrides:
add in class AbstractList<ElementType extends XMLObject>
Parameters:
index - index at which to add the given XMLObject
element - element to be stored at the given index
Throws:
IllegalArgumentException - thrown if the given XMLObject already has a parent that is different from the XMLObject given at list construction time

remove

public ElementType remove(int index)

Specified by:
remove in interface List<ElementType extends XMLObject>
Overrides:
remove in class AbstractList<ElementType extends XMLObject>

remove

public boolean remove(ElementType element)
Removes the element from the list.

Parameters:
element - the element to be removed
Returns:
true if the element was in the list and removed, false if not

setParent

protected void setParent(ElementType element)
                  throws IllegalArgumentException
Assigned the parent, given at list construction, to the given element if the element does not have a parent or its parent matches the one given at list construction time.

Parameters:
element - the element to set the parent on
Throws:
IllegalArgumentException - thrown if the given element already has a parent and it is different than the parent given at list construction time


Copyright © 2006-2011 Internet2. All Rights Reserved.