Class IndexedElement

All Implemented Interfaces:
Serializable, Cloneable, Branch, Element, Node

public class IndexedElement extends DefaultElement
IndexedElement is an implementation of Elementwhich maintains an index of the attributes and elements it contains to optimise lookups via name.
Version:
$Revision: 1.10 $
See Also:
  • Field Details

    • elementIndex

      private Map<Object,Object> elementIndex
      Lazily constructed index for elements Keys are of type QName and String Values are of type Element and List<Element>
    • attributeIndex

      private Map<Object, Attribute> attributeIndex
      Lazily constructed index for attributes Keys are of type QName and String Values are of type <A>
  • Constructor Details

    • IndexedElement

      public IndexedElement(String name)
    • IndexedElement

      public IndexedElement(QName qname)
    • IndexedElement

      public IndexedElement(QName qname, int attributeCount)
  • Method Details

    • attribute

      public Attribute attribute(String name)
      Description copied from interface: Element
      Returns the attribute with the given name
      Specified by:
      attribute in interface Element
      Overrides:
      attribute in class DefaultElement
      Parameters:
      name - DOCUMENT ME!
      Returns:
      the attribute for the given local name in any namespace. If there are more than one attributes with the given local name in different namespaces then the first one is returned.
    • attribute

      public Attribute attribute(QName qName)
      Description copied from interface: Element
      DOCUMENT ME!
      Specified by:
      attribute in interface Element
      Overrides:
      attribute in class DefaultElement
      Parameters:
      qName - is the fully qualified name
      Returns:
      the attribute for the given fully qualified name or null if it could not be found.
    • element

      public Element element(String name)
      Description copied from interface: Element
      Returns the first element for the given local name and any namespace.
      Specified by:
      element in interface Element
      Overrides:
      element in class DefaultElement
      Parameters:
      name - DOCUMENT ME!
      Returns:
      the first element with the given local name
    • element

      public Element element(QName qName)
      Description copied from interface: Element
      Returns the first element for the given fully qualified name.
      Specified by:
      element in interface Element
      Overrides:
      element in class DefaultElement
      Parameters:
      qName - is the fully qualified name to search for
      Returns:
      the first element with the given fully qualified name
    • elements

      public List<Element> elements(String name)
      Description copied from interface: Element
      Returns the elements contained in this element with the given local name and any namespace. If no elements are found then this method returns an empty list. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
      Specified by:
      elements in interface Element
      Overrides:
      elements in class AbstractElement
      Parameters:
      name - DOCUMENT ME!
      Returns:
      a list of all the elements in this element for the given local name
    • elements

      public List<Element> elements(QName qName)
      Description copied from interface: Element
      Returns the elements contained in this element with the given fully qualified name. If no elements are found then this method returns an empty list. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
      Specified by:
      elements in interface Element
      Overrides:
      elements in class AbstractElement
      Parameters:
      qName - is the fully qualified name to search for
      Returns:
      a list of all the elements in this element for the given fully qualified name.
    • asElement

      protected Element asElement(Object object)
    • asElementList

      protected List<Element> asElementList(Object object)
    • asElementIterator

      protected Iterator<Element> asElementIterator(Object object)
      Deprecated.
      WILL BE REMOVED IN dom4j-1.6 !!
      DOCUMENT ME!
      Parameters:
      object - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • addNode

      protected void addNode(Node node)
      Overrides:
      addNode in class AbstractElement
    • removeNode

      protected boolean removeNode(Node node)
      Overrides:
      removeNode in class DefaultElement
    • attributeIndex

      protected Map<Object, Attribute> attributeIndex()
    • elementIndex

      protected Map<Object,Object> elementIndex()
    • createAttributeIndex

      protected Map<Object, Attribute> createAttributeIndex()
      A Factory Method to create the index for attributes
      Returns:
      DOCUMENT ME!
    • createElementIndex

      protected Map<Object,Object> createElementIndex()
      A Factory Method to create the index for elements
      Returns:
      DOCUMENT ME!
    • addToElementIndex

      protected void addToElementIndex(Element element)
    • addToElementIndex

      protected void addToElementIndex(Object key, Element value)
    • removeFromElementIndex

      protected void removeFromElementIndex(Element element)
    • removeFromElementIndex

      protected void removeFromElementIndex(Object key, Element value)
    • addToAttributeIndex

      protected void addToAttributeIndex(Attribute attribute)
    • addToAttributeIndex

      protected void addToAttributeIndex(Object key, Attribute value)
    • removeFromAttributeIndex

      protected void removeFromAttributeIndex(Attribute attribute)
    • removeFromAttributeIndex

      protected void removeFromAttributeIndex(Object key, Attribute value)
    • createIndex

      protected <T> Map<Object,T> createIndex()
      Factory method to return a new map implementation for indices
      Type Parameters:
      T - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • createList

      protected <T extends Node> List<T> createList()
      Factory method to return a list implementation for indices
      Type Parameters:
      T - DOCUMENT ME!
      Returns:
      DOCUMENT ME!