Package org.opensaml.core.xml.util
Class IndexedXMLObjectChildrenList<ElementType extends XMLObject>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<ElementType>
org.opensaml.core.xml.util.XMLObjectChildrenList<ElementType>
org.opensaml.core.xml.util.IndexedXMLObjectChildrenList<ElementType>
- Type Parameters:
ElementType- the type of element added to the list
- All Implemented Interfaces:
Iterable<ElementType>,Collection<ElementType>,List<ElementType>
@NotThreadSafe
public class IndexedXMLObjectChildrenList<ElementType extends XMLObject>
extends XMLObjectChildrenList<ElementType>
A list which indexes XMLObjects by their schema type and element QName for quick retrival based on those items.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<QName,List<ElementType>> Index of objects by type and name.Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.IndexedXMLObjectChildrenList(XMLObject parent, Collection<ElementType> col) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int index, ElementType element) Adds the given XMLObject to this list.protected voidcheckAndCreateIndex(QName index) Check for the existence of an index for the specified QName and create it if it doesn't exist.voidclear()Retrieves all the SAMLObjects that have given schema type or element name, or a null if no such objects exist.protected voidindexElement(ElementType element) Indexes the given SAMLObject by type and element name.protected voidindexElement(QName index, ElementType element) Indexes the given SAMLobject by the given index.remove(int index) booleanremove(ElementType element) Removes a given element from the list and index.protected voidremoveElementFromIndex(ElementType element) Removes the given element from the schema type and element QName index.protected voidremoveElementFromIndex(QName index, ElementType element) Removes an object from the given index id.set(int index, ElementType element) Replaces the XMLObject at the specified index with the given element.List<? extends ElementType>Returns a view of the list that only contains elements stored under the given index.Methods inherited from class org.opensaml.core.xml.util.XMLObjectChildrenList
contains, get, setParent, sizeMethods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Field Details
-
objectIndex
Index of objects by type and name.
-
-
Constructor Details
-
IndexedXMLObjectChildrenList
Constructor.- Parameters:
parent- the parent of theXMLObjects added to the list
-
IndexedXMLObjectChildrenList
public IndexedXMLObjectChildrenList(@Nonnull XMLObject parent, @Nonnull Collection<ElementType> col) Constructor.- Parameters:
parent- the parent of all elementscol- collection to add to this list
-
-
Method Details
-
add
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 classXMLObjectChildrenList<ElementType extends XMLObject>- Parameters:
index- index at which to add the given XMLObjectelement- element to be stored at the given index
-
clear
public void clear()- Specified by:
clearin interfaceCollection<ElementType extends XMLObject>- Specified by:
clearin interfaceList<ElementType extends XMLObject>- Overrides:
clearin classAbstractList<ElementType extends XMLObject>
-
get
Retrieves all the SAMLObjects that have given schema type or element name, or a null if no such objects exist.- Parameters:
typeOrName- the schema type or element name- Returns:
- list of SAMLObjects that have given schema type or element name or null
-
checkAndCreateIndex
Check for the existence of an index for the specified QName and create it if it doesn't exist.- Parameters:
index- the index to check
-
indexElement
Indexes the given SAMLObject by type and element name. A null input is ignored.- Parameters:
element- the SAMLObject to index
-
indexElement
Indexes the given SAMLobject by the given index.- Parameters:
index- the index for the elementelement- the element to be indexed
-
remove
Removes a given element from the list and index.- Overrides:
removein classXMLObjectChildrenList<ElementType extends XMLObject>- Parameters:
element- the element to be removed- Returns:
- true if the element was in the list and removed, false if not
-
remove
- Specified by:
removein interfaceList<ElementType extends XMLObject>- Overrides:
removein classXMLObjectChildrenList<ElementType extends XMLObject>
-
removeElementFromIndex
Removes the given element from the schema type and element QName index. A null input is ignored.- Parameters:
element- the element to remove from the index
-
removeElementFromIndex
Removes an object from the given index id.- Parameters:
index- the id of the indexelement- the element to be removed from that index
-
set
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 classXMLObjectChildrenList<ElementType extends XMLObject>- Parameters:
index- index of the XMLObject to be replacedelement- element to be stored at the given index- Returns:
- the replaced XMLObject
-
subList
Returns a view of the list that only contains elements stored under the given index. The returned list is backed by this list and supports all optional operations, so changes made to the returned list are reflected in this list.- Parameters:
index- index of the elements returned in the list view- Returns:
- a view of this list that contains only the elements stored under the given index
-