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 Details

  • Constructor Details

    • IndexedXMLObjectChildrenList

      public IndexedXMLObjectChildrenList​(@Nonnull XMLObject parent)
      Constructor.
      Parameters:
      parent - the parent of the XMLObjects 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