Top Description Fields Constructors Methods
org.dom4j.util

public Class IndexedElement

extends DefaultElement
Class Inheritance
Annotations
@SuppressWarnings:unused
Imports
java.util.ArrayList, .HashMap, .Iterator, .List, .Map, org.dom4j.Attribute, .Element, .Node, .QName, org.dom4j.tree.BackedList, .DefaultAttribute, .DefaultElement

IndexedElement is an implementation of Elementwhich maintains an index of the attributes and elements it contains to optimise lookups via name.
Author
James Strachan
Version
$Revision: 1.10 $

Field Summary

Modifier and TypeField and Description
private Map<Object, Attribute>
attributeIndex

Lazily constructed index for attributes Keys are of type QName and String Values are of type <A>

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>

Constructor Summary

AccessConstructor and Description
public
public
public
IndexedElement(QName qname, int attributeCount)

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
protected void
protected void
protected void
protected Element
asElement(Object object)

protected Iterator<Element>

Returns:

DOCUMENT ME!
asElementIterator
(Object
DOCUMENT ME!
object
)

Deprecated WILL BE REMOVED IN dom4j-1.6 !!
DOCUMENT ME!
protected List<Element>
public Attribute
attribute(String
DOCUMENT ME!
name
)

Overrides org.dom4j.tree.DefaultElement.attribute.

Implements org.dom4j.Element.attribute.

Returns the attribute with the given name
public Attribute
attribute(QName
is the fully qualified name
qName
)

Overrides org.dom4j.tree.DefaultElement.attribute.

Implements org.dom4j.Element.attribute.

DOCUMENT ME!
protected Map<Object, Attribute>
protected Map<Object, Attribute>

Returns:

DOCUMENT ME!
createAttributeIndex
()

A Factory Method to create the index for attributes

protected Map<Object, Object>

Returns:

DOCUMENT ME!
createElementIndex
()

A Factory Method to create the index for elements

protected <
DOCUMENT ME!
T
>
Map<Object, T>

Returns:

DOCUMENT ME!
createIndex
()

Factory method to return a new map implementation for indices

protected <
DOCUMENT ME!
T extends Node
>
List<T>

Returns:

DOCUMENT ME!
createList
()

Factory method to return a list implementation for indices

public Element
element(String
DOCUMENT ME!
name
)

Overrides org.dom4j.tree.DefaultElement.element.

Implements org.dom4j.Element.element.

Returns the first element for the given local name and any namespace.
public Element
element(QName
is the fully qualified name to search for
qName
)

Overrides org.dom4j.tree.DefaultElement.element.

Implements org.dom4j.Element.element.

Returns the first element for the given fully qualified name.
protected Map<Object, Object>
public List<Element>
elements(String
DOCUMENT ME!
name
)

Overrides org.dom4j.tree.AbstractElement.elements.

Implements org.dom4j.Element.elements.

Returns the elements contained in this element with the given local name and any namespace.
public List<Element>
elements(QName
is the fully qualified name to search for
qName
)

Overrides org.dom4j.tree.AbstractElement.elements.

Implements org.dom4j.Element.elements.

Returns the elements contained in this element with the given fully qualified name.
protected void
protected void
protected void
protected void
protected boolean
Inherited from org.dom4j.tree.DefaultElement:
addadditionalNamespacesadditionalNamespacesaddNewNodeattributeattributeattributeCountattributeIteratorattributeListattributeListattributesclearContentclonecontentListdeclaredNamespaceselementgetDocumentgetDocumentFactorygetNamespaceForPrefixgetNamespaceForURIgetParentgetQNamegetStringValuegetTextindexOfnodenodeCountnodeIteratorprocessingInstructionprocessingInstructionsprocessingInstructionsremoveremoveProcessingInstructionsetAttributeListsetAttributessetContentsetDocumentsetParentsetQNamesupportsParent

Field Detail

attributeIndexback to summary
private Map<Object, Attribute> attributeIndex

Lazily constructed index for attributes Keys are of type QName and String Values are of type <A>

elementIndexback to summary
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>

Constructor Detail

IndexedElementback to summary
public IndexedElement(String name)
IndexedElementback to summary
public IndexedElement(QName qname)
IndexedElementback to summary
public IndexedElement(QName qname, int attributeCount)

Method Detail

addNodeback to summary
protected void addNode(Node node)

Overrides org.dom4j.tree.AbstractElement.addNode.

addToAttributeIndexback to summary
protected void addToAttributeIndex(Attribute attribute)
addToAttributeIndexback to summary
protected void addToAttributeIndex(Object key, Attribute value)
addToElementIndexback to summary
protected void addToElementIndex(Element element)
addToElementIndexback to summary
protected void addToElementIndex(Object key, Element value)
asElementback to summary
protected Element asElement(Object object)
asElementIteratorback to summary
protected Iterator<Element> asElementIterator(Object object)

Deprecated

WILL BE REMOVED IN dom4j-1.6 !!

DOCUMENT ME!

Parameters
object:Object

DOCUMENT ME!

Returns:Iterator<Element>

DOCUMENT ME!

asElementListback to summary
protected List<Element> asElementList(Object object)
attributeback to summary
public Attribute attribute(String name)

Overrides org.dom4j.tree.DefaultElement.attribute.

Implements org.dom4j.Element.attribute.

Doc from org.dom4j.Element.attribute.

Returns the attribute with the given name

Parameters
name:String

DOCUMENT ME!

Returns:Attribute

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.

attributeback to summary
public Attribute attribute(QName qName)

Overrides org.dom4j.tree.DefaultElement.attribute.

Implements org.dom4j.Element.attribute.

Doc from org.dom4j.Element.attribute.

DOCUMENT ME!

Parameters
qName:QName

is the fully qualified name

Returns:Attribute

the attribute for the given fully qualified name or null if it could not be found.

attributeIndexback to summary
protected Map<Object, Attribute> attributeIndex()
createAttributeIndexback to summary
protected Map<Object, Attribute> createAttributeIndex()

A Factory Method to create the index for attributes

Returns:Map<Object, Attribute>

DOCUMENT ME!

createElementIndexback to summary
protected Map<Object, Object> createElementIndex()

A Factory Method to create the index for elements

Returns:Map<Object, Object>

DOCUMENT ME!

createIndexback to summary
protected <T> Map<Object, T> createIndex()

Factory method to return a new map implementation for indices

Parameters
<T>
DOCUMENT ME!
Returns:Map<Object, T>

DOCUMENT ME!

createListback to summary
protected <T extends Node> List<T> createList()

Factory method to return a list implementation for indices

Parameters
<T>
DOCUMENT ME!
Returns:List<T>

DOCUMENT ME!

elementback to summary
public Element element(String name)

Overrides org.dom4j.tree.DefaultElement.element.

Implements org.dom4j.Element.element.

Doc from org.dom4j.Element.element.

Returns the first element for the given local name and any namespace.

Parameters
name:String

DOCUMENT ME!

Returns:Element

the first element with the given local name

elementback to summary
public Element element(QName qName)

Overrides org.dom4j.tree.DefaultElement.element.

Implements org.dom4j.Element.element.

Doc from org.dom4j.Element.element.

Returns the first element for the given fully qualified name.

Parameters
qName:QName

is the fully qualified name to search for

Returns:Element

the first element with the given fully qualified name

elementIndexback to summary
protected Map<Object, Object> elementIndex()
elementsback to summary
public List<Element> elements(String name)

Overrides org.dom4j.tree.AbstractElement.elements.

Implements org.dom4j.Element.elements.

Doc from org.dom4j.Element.elements.

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.

Parameters
name:String

DOCUMENT ME!

Returns:List<Element>

a list of all the elements in this element for the given local name

elementsback to summary
public List<Element> elements(QName qName)

Overrides org.dom4j.tree.AbstractElement.elements.

Implements org.dom4j.Element.elements.

Doc from org.dom4j.Element.elements.

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.

Parameters
qName:QName

is the fully qualified name to search for

Returns:List<Element>

a list of all the elements in this element for the given fully qualified name.

removeFromAttributeIndexback to summary
protected void removeFromAttributeIndex(Attribute attribute)
removeFromAttributeIndexback to summary
protected void removeFromAttributeIndex(Object key, Attribute value)
removeFromElementIndexback to summary
protected void removeFromElementIndex(Element element)
removeFromElementIndexback to summary
protected void removeFromElementIndex(Object key, Element value)
removeNodeback to summary
protected boolean removeNode(Node node)

Overrides org.dom4j.tree.DefaultElement.removeNode.