org.opensaml.xml.util
Class IndexedXMLObjectChildrenList<ElementType extends XMLObject>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<ElementType>
          extended by org.opensaml.xml.util.XMLObjectChildrenList<ElementType>
              extended by org.opensaml.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
private  Map<QName,List<ElementType>> objectIndex
          Index of objects by type and name.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
IndexedXMLObjectChildrenList(XMLObject parent)
          Constructor.
IndexedXMLObjectChildrenList(XMLObject parent, Collection<ElementType> col)
          Constructor.
 
Method Summary
 void add(int index, ElementType element)
          Inserts the specified element at the specified position in 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.
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.
 boolean remove(ElementType element)
          Removes a given element from the list and index.
 ElementType remove(int index)
          Removes the element at the specified position in this list.
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 element at the specified position in this list with the specified 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.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.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

objectIndex

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

Constructor Detail

IndexedXMLObjectChildrenList

public IndexedXMLObjectChildrenList(XMLObject parent)
Constructor.

Parameters:
parent - the parent of the XMLObjects added to the list

IndexedXMLObjectChildrenList

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

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

add

public void add(int index,
                ElementType element)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
add in interface List<ElementType extends XMLObject>
Overrides:
add in class XMLObjectChildrenList<ElementType extends XMLObject>
Parameters:
index - index of element to add
element - element to be stored at the specified position

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

public List<ElementType> get(QName typeOrName)
Retrieves all the SAMLObjects that have given schema type or element name.

Parameters:
typeOrName - the schema type or element name
Returns:
list of SAMLObjects that have given schema type or element name, which may be empty. Will not be null.

checkAndCreateIndex

protected void checkAndCreateIndex(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(ElementType element)
Indexes the given SAMLObject by type and element name.

Parameters:
element - the SAMLObject to index

indexElement

protected void indexElement(QName index,
                            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(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

public ElementType remove(int index)
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list

Specified by:
remove in interface List<ElementType extends XMLObject>
Overrides:
remove in class XMLObjectChildrenList<ElementType extends XMLObject>
Parameters:
index - the index of the element to remove
Returns:
the element removed from the list

removeElementFromIndex

protected void removeElementFromIndex(ElementType element)
Removes the given element from the schema type and element qname index.

Parameters:
element - the element to remove from the index

removeElementFromIndex

protected void removeElementFromIndex(QName index,
                                      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

public ElementType set(int index,
                       ElementType element)
Replaces the element at the specified position in this list with the specified element.

Specified by:
set in interface List<ElementType extends XMLObject>
Overrides:
set in class XMLObjectChildrenList<ElementType extends XMLObject>
Parameters:
index - index of element to replace
element - element to be stored at the specified position
Returns:
the element previously at the specified position

subList

public List<? extends ElementType> subList(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 so 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


Copyright © 1999-2013. All Rights Reserved.