Package org.opensaml.core.xml.util
Class XMLObjectChildrenList<ElementType extends XMLObject>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<ElementType>
-
- org.opensaml.core.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 nothing 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 Modifier and Type Field Description private List<ElementType>elementsList of elements.private XMLObjectparentParent to the elements in this list.-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, ElementType element)Adds the given XMLObject to this list.booleancontains(ElementType element)Checks to see if the given element is contained in this list.ElementTypeget(int index)ElementTyperemove(int index)booleanremove(ElementType element)Removes the element from the list.ElementTypeset(int index, ElementType element)Replaces the XMLObject at the specified index with the given element.protected voidsetParent(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.intsize()-
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.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Field Detail
-
parent
private final XMLObject parent
Parent to the elements in this list.
-
elements
private final List<ElementType extends XMLObject> elements
List of elements.
-
-
Constructor Detail
-
XMLObjectChildrenList
public XMLObjectChildrenList(@Nonnull XMLObject newParent)Constructs an empty list with all added XMLObjects being assigned the given parent XMLObject.- Parameters:
newParent- the parent for all the added XMLObjects
-
XMLObjectChildrenList
public XMLObjectChildrenList(@Nonnull XMLObject newParent, @Nonnull 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.An IllegalArgumentException is thrown if any of the XMLObjects in the given collection already have a parent other than the given parent
- Parameters:
newParent- the parent for all the added XMLObjectsnewElements- the elements to be added
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceCollection<ElementType extends XMLObject>- Specified by:
sizein interfaceList<ElementType extends XMLObject>- Specified by:
sizein classAbstractCollection<ElementType extends XMLObject>
-
contains
public boolean contains(@Nonnull ElementType element)Checks to see if the given element is contained in this list.- Parameters:
element- the element to check for- Returns:
- true iff the element is in this list
-
get
@Nonnull public ElementType get(int index)
- Specified by:
getin interfaceList<ElementType extends XMLObject>- Specified by:
getin classAbstractList<ElementType extends XMLObject>
-
set
@Nullable public ElementType set(int index, @Nullable ElementType element)
Replaces the XMLObject at the specified index with the given element. A null input is ignored and returned.An IllegalArgumentException is thrown if the given XMLObject already has a parent other than the parent given at list construction time.
- Specified by:
setin interfaceList<ElementType extends XMLObject>- Overrides:
setin classAbstractList<ElementType extends XMLObject>- Parameters:
index- index of the XMLObject to be replacedelement- element to be stored at the given index- Returns:
- the replaced XMLObject
-
add
public void add(int index, @Nullable ElementType element)Adds the given XMLObject to this list. A null element is ignored, as is an element already in the list.An IllegalArgumentException is thrown if the given XMLObject already has a parent other than the parent given at list construction time.
- Specified by:
addin interfaceList<ElementType extends XMLObject>- Overrides:
addin classAbstractList<ElementType extends XMLObject>- Parameters:
index- index at which to add the given XMLObjectelement- element to be stored at the given index
-
remove
@Nonnull public ElementType remove(int index)
- Specified by:
removein interfaceList<ElementType extends XMLObject>- Overrides:
removein classAbstractList<ElementType extends XMLObject>
-
remove
public boolean remove(@Nullable ElementType element)Removes the element from the list.- Parameters:
element- the element to be removed- Returns:
- true iff the element was in the list and removed
-
setParent
protected void setParent(@Nonnull 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.An IllegalArgumentException is thrown if the given XMLObject already has a parent other than the parent given at list construction time.
- Parameters:
element- the element to set the parent on
-
-