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
Fields Modifier and Type Field Description private Map<QName,List<ElementType>>objectIndexIndex of objects by type and name.-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description IndexedXMLObjectChildrenList(XMLObject parent)Constructor.IndexedXMLObjectChildrenList(XMLObject parent, Collection<ElementType> col)Constructor.
-
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.protected voidcheckAndCreateIndex(QName index)Check for the existence of an index for the specified QName and create it if it doesn't exist.voidclear()List<ElementType>get(QName typeOrName)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.ElementTyperemove(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.ElementTypeset(int index, ElementType element)Replaces the XMLObject at the specified index with the given element.List<? extends ElementType>subList(QName index)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, size
-
Methods inherited from class java.util.AbstractList
add, addAll, 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
-
objectIndex
private final Map<QName,List<ElementType extends XMLObject>> objectIndex
Index of objects by type and name.
-
-
Constructor Detail
-
IndexedXMLObjectChildrenList
public IndexedXMLObjectChildrenList(@Nonnull XMLObject parent)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 Detail
-
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 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
@Nonnull public List<ElementType> get(@Nonnull QName typeOrName)
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
protected void checkAndCreateIndex(@Nonnull QName index)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
protected void indexElement(@Nullable ElementType element)Indexes the given SAMLObject by type and element name. A null input is ignored.- Parameters:
element- the SAMLObject to index
-
indexElement
protected void indexElement(@Nonnull QName index, @Nullable ElementType element)Indexes the given SAMLobject by the given index.- Parameters:
index- the index for the elementelement- the element to be indexed
-
remove
public boolean remove(@Nullable ElementType element)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
@Nonnull public ElementType remove(int index)
- Specified by:
removein interfaceList<ElementType extends XMLObject>- Overrides:
removein classXMLObjectChildrenList<ElementType extends XMLObject>
-
removeElementFromIndex
protected void removeElementFromIndex(@Nullable ElementType element)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
protected void removeElementFromIndex(@Nonnull QName index, @Nullable ElementType element)Removes an object from the given index id.- Parameters:
index- the id of the indexelement- the element to be removed from that index
-
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 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
@Nonnull public List<? extends ElementType> subList(@Nonnull QName index)
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
-
-