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 final Map<QName,List<ElementType>>`
`objectIndex`
Index 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

Modifier and Type
Method
Description
`void`
`add(int index, ElementType element)`
Adds the given XMLObject to this list.
`protected void`
`checkAndCreateIndex(QName index)`
Check for the existence of an index for the specified QName and create it if it doesn't exist.
`void`
`clear()`
`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 void`
`indexElement(ElementType element)`
Indexes the given SAMLObject by type and element name.
`protected void`
`indexElement(QName index, ElementType element)`
Indexes the given SAMLobject by the given index.
`ElementType`
`remove(int index)`
`boolean`
`remove(ElementType element)`
Removes a given element from the list and index.
`protected void`
`removeElementFromIndex(ElementType element)`
Removes the given element from the schema type and element QName index.
`protected void`
`removeElementFromIndex(QName index, ElementType element)`
Removes an object from the given index id.
`ElementType`
`set(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.lang.Iterable

`forEach`

### Methods inherited from interface java.util.List

`addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray`

## Field Details

### objectIndex

@Nonnull private final Map<QName,List<ElementType extends XMLObject>> objectIndex
Index of objects by type and name.

## Constructor Details

### IndexedXMLObjectChildrenList

public IndexedXMLObjectChildrenList(@Nonnull XMLObject parent)
Constructor.

Parameters:
  `parent` - the parent of the `XMLObject`s added to the list

### IndexedXMLObjectChildrenList

public IndexedXMLObjectChildrenList(@Nonnull XMLObject parent, @Nonnull Collection<ElementType> col)
Constructor.

Parameters:
  `parent` - the parent of all elements
  `col` - collection to add to this list

## Method Details

### 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:
  `add` in interface `List<ElementType extends XMLObject>`
Overrides:
  `add` in class `XMLObjectChildrenList<ElementType extends XMLObject>`
Parameters:
  `index` - index at which to add the given XMLObject
  `element` - element to be stored at the given index

### clear

public void clear()

Specified by:
  `clear` in interface `Collection<ElementType extends XMLObject>`
Specified by:
  `clear` in interface `List<ElementType extends XMLObject>`
Overrides:
  `clear` in class `AbstractList<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 element
  `element` - the element to be indexed

### remove

public boolean remove(@Nullable ElementType element)
Removes a given element from the list and index.

Overrides:
  `remove` in class `XMLObjectChildrenList<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:
  `remove` in interface `List<ElementType extends XMLObject>`
Overrides:
  `remove` in class `XMLObjectChildrenList<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 index
  `element` - 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:
  `set` in interface `List<ElementType extends XMLObject>`
Overrides:
  `set` in class `XMLObjectChildrenList<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

### 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