org.apache.xalan.stree
Class ElementImpl

java.lang.Object
  |
  +--org.apache.xml.utils.UnImplNode
        |
        +--org.apache.xalan.stree.Child
              |
              +--org.apache.xalan.stree.Parent
                    |
                    +--org.apache.xalan.stree.ElementImpl
Direct Known Subclasses:
ElementImplWithNS

public class ElementImpl
extends Parent
implements Attributes, NamedNodeMap

**For internal use only** This class represents an element in an HTML or XML document. Elements may have attributes associated with them as well as children nodes.


Method Summary
 Attr createAttribute(java.lang.String name)
          Create an attribute node.
 Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Create an attribute node with a namespace .
 int getAttrCount()
          Return the number of attributes in the list.
 java.lang.String getAttribute(java.lang.String name)
          Look up an attribute's value by name.
 NamedNodeMap getAttributes()
          Get attributes of this node.
 AttrImpl getChildAttribute(int i)
          Get the nth attribute child.
 int getChildCount()
          Get the number of children this node currently contains.
 int getIndex(java.lang.String rawName)
          Look up the index of an attribute by raw XML 1.0 name.
 int getIndex(java.lang.String uri, java.lang.String localPart)
          Look up the index of an attribute by Namespace name.
 int getLength()
          The number of nodes (attributes) in this map.
 java.lang.String getLocalName()
          Returns the local part of the qualified name of this node.
 java.lang.String getLocalName(int index)
          Look up an attribute's local name by index.
 Node getNamedItem(java.lang.String name)
          Get the child attribute with the specified attribute name
 Node getNamedItemNS(java.lang.String namespaceURI, java.lang.String localName)
          Retrieves a node specified by local name and namespace URI.
 java.lang.String getNodeName()
          Returns the node name.
 short getNodeType()
          A short integer indicating what type of node this is.
 java.lang.String getQName(int index)
          Look up an attribute's raw XML 1.0 name by index.
 java.lang.String getTagName()
          Returns the tag name of this node.
 java.lang.String getType(int index)
          Look up an attribute's type by index.
 java.lang.String getType(java.lang.String rawName)
          Look up an attribute's type by raw XML 1.0 name.
 java.lang.String getType(java.lang.String uri, java.lang.String localName)
          Look up an attribute's type by Namespace name.
 java.lang.String getURI(int index)
          Look up an attribute's Namespace URI by index.
 java.lang.String getValue(int index)
          Look up an attribute's value by index.
 java.lang.String getValue(java.lang.String rawName)
          Look up an attribute's value by raw XML 1.0 name.
 java.lang.String getValue(java.lang.String uri, java.lang.String localName)
          Look up an attribute's value by Namespace name.
 Node item(int index)
          Returns the index th item in the map.
 Node removeItem(int index)
          Remove the attribute at the specified index from the attribute list
 Node removeNamedItem(java.lang.String name)
          Removes a node specified by name.
 Node removeNamedItemNS(java.lang.String namespaceURI, java.lang.String localName)
          Removes a node specified by local name and namespace URI.
 void setAttribute(java.lang.String name, java.lang.String value)
          Set attributes of this node.
 void setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value)
          Set attributes of this node.
 void setAttributes(Attributes atts)
          Set a list of attributes of this node.
 void setIDAttribute(java.lang.String value)
          Set the ID string to element association for this node.
 Node setNamedItem(Node arg)
          Adds a node using its nodeName attribute.
 Node setNamedItemNS(Node arg)
          Adds a node using its namespaceURI and localName .
 
Methods inherited from class org.apache.xalan.stree.Parent
appendChild, dispatchCharactersEvent, getChild, getChildUID, getFirstChild, getLastChild, hasChildNodes, isComplete, setComplete
 
Methods inherited from class org.apache.xalan.stree.Child
getLevel, getNamespaceURI, getNextSibling, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getUid, isNamespaceNode, isSupported, setLevel
 
Methods inherited from class org.apache.xml.utils.UnImplNode
appendData, cloneNode, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, error, error, getAttributeNode, getAttributeNodeNS, getAttributeNS, getChildNodes, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, getNodeValue, getOwnerElement, getSpecified, hasAttribute, hasAttributeNS, hasAttributes, importNode, insertBefore, insertData, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, setAttributeNode, setAttributeNodeNS, setData, setNodeValue, setPrefix, setValue, splitText, substringData
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNodeType

public short getNodeType()
A short integer indicating what type of node this is. The named constants for this value are defined in the org.w3c.dom.Node interface.
Returns:
This node's type
Overrides:
getNodeType in class UnImplNode

getNodeName

public java.lang.String getNodeName()
Returns the node name.
Returns:
This node's name
Overrides:
getNodeName in class UnImplNode

getLocalName

public java.lang.String getLocalName()
Returns the local part of the qualified name of this node.
For nodes created with a DOM Level 1 method, such as createElement from the Document interface, it is null.
Returns:
the local part of the qualified name of this node
Overrides:
getLocalName in class Child
Since:
DOM Level 2

getTagName

public java.lang.String getTagName()
Returns the tag name of this node.
For nodes created with a DOM Level 1 method, such as createElement from the Document interface, it is null.
Returns:
the tag name of this node
Overrides:
getTagName in class Child
Since:
DOM Level 2

getChildAttribute

public AttrImpl getChildAttribute(int i)
                           throws java.lang.ArrayIndexOutOfBoundsException,
                                  java.lang.NullPointerException
Get the nth attribute child.
Parameters:
i - the index of the child.
Returns:
the attribute child at the specified position
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index is out of bounds.
java.lang.NullPointerException - if there are no children.

getChildCount

public int getChildCount()
Get the number of children this node currently contains. Factor in the number of attributes at beginning of list. Note that this will only return the number of children added so far. If the isComplete property is false, it is likely that more children will be added. DON'T CALL THIS FUNCTION IF YOU CAN HELP IT!!!!!!
Returns:
the number of children this node currently contains
Overrides:
getChildCount in class Parent

getAttributes

public NamedNodeMap getAttributes()
Get attributes of this node.
For nodes created with a DOM Level 1 method, such as createElement from the Document interface, it is null.
Returns:
a NamedNodeMap containing this node's attributes
Overrides:
getAttributes in class Child
Since:
DOM Level 2

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
                  throws DOMException
Set attributes of this node.
For nodes created with a DOM Level 1 method, such as createElement from the Document interface, it is null.
Parameters:
name - attribute name
value - attribute value
Throws:
DOMException -  
Overrides:
setAttribute in class Child
Since:
DOM Level 2

setAttributeNS

public void setAttributeNS(java.lang.String namespaceURI,
                           java.lang.String qualifiedName,
                           java.lang.String value)
                    throws DOMException
Set attributes of this node.
For nodes created with a DOM Level 1 method, such as createElement from the Document interface, it is null.
Parameters:
namespaceURI - Attribute name space
qualifiedName - Attribute qualified name
value - Attribute value
Throws:
DOMException -  
Overrides:
setAttributeNS in class UnImplNode
Since:
DOM Level 2

setAttributes

public void setAttributes(Attributes atts)
                   throws DOMException
Set a list of attributes of this node.
For nodes created with a DOM Level 1 method, such as createElement from the Document interface, it is null.
Parameters:
atts - List of attributes to set for this node
Throws:
DOMException -  
Since:
DOM Level 2

setIDAttribute

public void setIDAttribute(java.lang.String value)
Set the ID string to element association for this node.
Parameters:
value - The ID string, should not be null.

createAttribute

public Attr createAttribute(java.lang.String name)
                     throws DOMException
Create an attribute node.
Parameters:
name - Attribute name to create
Returns:
the created attribute object
Throws:
DOMException -  
Overrides:
createAttribute in class UnImplNode

createAttributeNS

public Attr createAttributeNS(java.lang.String namespaceURI,
                              java.lang.String qualifiedName)
                       throws DOMException
Create an attribute node with a namespace .
Parameters:
namespaceURI - name space of the attribute to create
qualifiedName - qualified name of the attribute to create
Returns:
the created attribute object
Throws:
DOMException -  
Overrides:
createAttributeNS in class UnImplNode

getAttrCount

public int getAttrCount()
Return the number of attributes in the list.
Returns:
The number of attributes in the list.

getURI

public java.lang.String getURI(int index)
Look up an attribute's Namespace URI by index.
Specified by:
getURI in interface Attributes
Parameters:
index - The attribute index (zero-based).
Returns:
The Namespace URI, or the empty string if none is available, or null if the index is out of range.

getLocalName

public java.lang.String getLocalName(int index)
Look up an attribute's local name by index.
Specified by:
getLocalName in interface Attributes
Parameters:
index - The attribute index (zero-based).
Returns:
The local name, or the empty string if Namespace processing is not being performed, or null if the index is out of range.

getQName

public java.lang.String getQName(int index)
Look up an attribute's raw XML 1.0 name by index.
Specified by:
getQName in interface Attributes
Parameters:
index - The attribute index (zero-based).
Returns:
The raw XML 1.0 name, or the empty string if none is available, or null if the index is out of range.

getType

public java.lang.String getType(int index)
Look up an attribute's type by index.
Specified by:
getType in interface Attributes
Parameters:
index - The attribute index (zero-based).
Returns:
The attribute's type as a string, or null if the index is out of range.

getValue

public java.lang.String getValue(int index)
Look up an attribute's value by index.
Specified by:
getValue in interface Attributes
Parameters:
index - The attribute index (zero-based).
Returns:
The attribute's value as a string, or null if the index is out of range.

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Look up an attribute's value by name.
Parameters:
name - The attribute name to look up
Returns:
The attribute's value as a string, or null if the index is out of range.
Overrides:
getAttribute in class UnImplNode

getIndex

public int getIndex(java.lang.String uri,
                    java.lang.String localPart)
Look up the index of an attribute by Namespace name.
Specified by:
getIndex in interface Attributes
Parameters:
uri - The Namespace URI, or the empty string if the name has no Namespace URI.
localPart - The attribute's local name.
Returns:
The index of the attribute, or -1 if it does not appear in the list.

getIndex

public int getIndex(java.lang.String rawName)
Look up the index of an attribute by raw XML 1.0 name.
Specified by:
getIndex in interface Attributes
Parameters:
rawName - The raw (prefixed) name.
Returns:
The index of the attribute, or -1 if it does not appear in the list.

getType

public java.lang.String getType(java.lang.String uri,
                                java.lang.String localName)
Look up an attribute's type by Namespace name.
Specified by:
getType in interface Attributes
Parameters:
uri - The Namespace URI, or the empty String if the name has no Namespace URI.
localName - The local name of the attribute.
Returns:
The attribute type as a string, or null if the attribute is not in the list or if Namespace processing is not being performed.

getType

public java.lang.String getType(java.lang.String rawName)
Look up an attribute's type by raw XML 1.0 name.
Specified by:
getType in interface Attributes
Parameters:
rawName - The raw XML 1.0 name.
Returns:
The attribute type as a string, or null if the attribute is not in the list or if raw names are not available.

getValue

public java.lang.String getValue(java.lang.String uri,
                                 java.lang.String localName)
Look up an attribute's value by Namespace name.
Specified by:
getValue in interface Attributes
Parameters:
uri - The Namespace URI, or the empty String if the name has no Namespace URI.
localName - The local name of the attribute.
Returns:
The attribute value as a string, or null if the attribute is not in the list.

getValue

public java.lang.String getValue(java.lang.String rawName)
Look up an attribute's value by raw XML 1.0 name.
Specified by:
getValue in interface Attributes
Parameters:
rawName - The raw XML 1.0 name.
Returns:
The attribute value as a string, or null if the attribute is not in the list or if raw names are not available.

getNamedItem

public Node getNamedItem(java.lang.String name)
Get the child attribute with the specified attribute name
Specified by:
getNamedItem in interface NamedNodeMap
Parameters:
name - Attribute name to look up
Returns:
The found attribute node or null if not found

setNamedItem

public Node setNamedItem(Node arg)
                  throws DOMException
Adds a node using its nodeName attribute. If a node with that name is already present in this map, it is replaced by the new one.
As the nodeName attribute is used to derive the name which the node must be stored under, multiple nodes of certain types (those that have a "special" string value) cannot be stored as the names would clash. This is seen as preferable to allowing nodes to be aliased.
Specified by:
setNamedItem in interface NamedNodeMap
Parameters:
arg - A node to store in this map. The node will later be accessible using the value of its nodeName attribute.
Returns:
If the new Node replaces an existing node the replaced Node is returned, otherwise null is returned.
Throws:
DOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.

removeNamedItem

public Node removeNamedItem(java.lang.String name)
                     throws DOMException
Removes a node specified by name. A removed attribute may be known to have a default value when this map contains the attributes attached to an element, as returned by the attributes attribute of the Node interface. If so, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.
Specified by:
removeNamedItem in interface NamedNodeMap
Parameters:
name - The nodeName of the node to remove.
Returns:
The node removed from this map if a node with such a name exists.
Throws:
DOMException - NOT_FOUND_ERR: Raised if there is no node named name in this map.
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.

removeItem

public Node removeItem(int index)
                throws DOMException
Remove the attribute at the specified index from the attribute list
Parameters:
index - Position of attribute to remove in attribute list
Returns:
the removed attribute or null if not found
Throws:
DOMException -  

getLength

public int getLength()
The number of nodes (attributes) in this map. The range of valid child node indices is 0 to length-1 inclusive.
Specified by:
getLength in interface Attributes
Returns:
The nunber of attribute nodes associated with this element.
Overrides:
getLength in class UnImplNode

item

public Node item(int index)
Returns the index th item in the map. If index is greater than or equal to the number of nodes in this map, this returns null .
Specified by:
item in interface NamedNodeMap
Parameters:
index - Index into this map.
Returns:
The node at the index th position in the map, or null if that is not a valid index.
Overrides:
item in class UnImplNode

getNamedItemNS

public Node getNamedItemNS(java.lang.String namespaceURI,
                           java.lang.String localName)
Retrieves a node specified by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.
Specified by:
getNamedItemNS in interface NamedNodeMap
Parameters:
namespaceURI - The namespace URI of the node to retrieve.
localName - The local name of the node to retrieve.
Returns:
A Node (of any type) with the specified local name and namespace URI, or null if they do not identify any node in this map.
Since:
DOM Level 2

setNamedItemNS

public Node setNamedItemNS(Node arg)
                    throws DOMException
Adds a node using its namespaceURI and localName . If a node with that namespace URI and that local name is already present in this map, it is replaced by the new one.
HTML-only DOM implementations do not need to implement this method.
Specified by:
setNamedItemNS in interface NamedNodeMap
Parameters:
arg - A node to store in this map. The node will later be accessible using the value of its namespaceURI and localName attributes.
Returns:
If the new Node replaces an existing node the replaced Node is returned, otherwise null is returned.
Throws:
DOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.
Since:
DOM Level 2

removeNamedItemNS

public Node removeNamedItemNS(java.lang.String namespaceURI,
                              java.lang.String localName)
                       throws DOMException
Removes a node specified by local name and namespace URI. A removed attribute may be known to have a default value when this map contains the attributes attached to an element, as returned by the attributes attribute of the Node interface. If so, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.
HTML-only DOM implementations do not need to implement this method.
Specified by:
removeNamedItemNS in interface NamedNodeMap
Parameters:
namespaceURI - The namespace URI of the node to remove.
localName - The local name of the node to remove.
Returns:
The node removed from this map if a node with such a local name and namespace URI exists.
Throws:
DOMException - NOT_FOUND_ERR: Raised if there is no node with the specified namespaceURI and localName in this map.
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
Since:
DOM Level 2


Copyright � 2000 Apache XML Project. All Rights Reserved.