Xindice API
version 1.2m1

org.apache.xindice.xml.dom
Class ElementImpl

java.lang.Object
  extended byorg.apache.xindice.xml.dom.NodeImpl
      extended byorg.apache.xindice.xml.dom.ContainerNodeImpl
          extended byorg.apache.xindice.xml.dom.ElementImpl
All Implemented Interfaces:
CompressedNode, DBNode, org.w3c.dom.Element, org.w3c.dom.Node

public final class ElementImpl
extends ContainerNodeImpl
implements org.w3c.dom.Element

ElementImpl

Version:
$Revision: 571948 $, $Date: 2007-09-02 06:51:37 -0400 (Sun, 02 Sep 2007) $

Field Summary
 
Fields inherited from class org.apache.xindice.xml.dom.ContainerNodeImpl
childNodes
 
Fields inherited from class org.apache.xindice.xml.dom.NodeImpl
data, dirty, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, EX_DOMSTRING_SIZE, EX_HIERARCHY_REQUEST, EX_INDEX_SIZE, EX_INUSE_ATTRIBUTE, EX_INVALID_STATE, EX_NO_DATA_ALLOWED, EX_NO_MODIFICATION_ALLOWED, EX_NOT_FOUND, EX_WRONG_DOCUMENT, handlers, key, len, loaded, nodeName, nodeValue, nsURI, OBJECT_HREF, OBJECT_NS, OBJECT_TYPE, ownerDocument, parentNode, pos, source, TYPE_APPEND, TYPE_CONTENT, TYPE_INSERT, TYPE_REPLACE, userData, XMLNS_PREFIX, XMLNS_URI
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
ElementImpl()
           
ElementImpl(NodeImpl parent, boolean dirty)
           
ElementImpl(NodeImpl parent, byte[] data, int pos, int len)
           
ElementImpl(NodeImpl parent, String nodeName)
           
 
Method Summary
protected  void checkLoaded()
           
 void expandSource()
          Add "src" and "col" attributes in NodeSource.SOURCE_NS namespace.
 String getAttribute(String name)
          Retrieves an attribute value by name.
 org.w3c.dom.Attr getAttributeNode(String name)
          Retrieves an Attr node by name.
 org.w3c.dom.Attr getAttributeNodeNS(String namespaceURI, String localName)
          Retrieves an Attr node by local name and namespace URI.
 String getAttributeNS(String namespaceURI, String localName)
          Retrieves an attribute value by local name and namespace URI.
 org.w3c.dom.NamedNodeMap getAttributes()
          A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
 short getNodeType()
          A code representing the type of the underlying object, as defined above.
 org.w3c.dom.TypeInfo getSchemaTypeInfo()
           
 short getSymbolID()
          getSymbolID returns the Symbol ID for the current node.
 String getTagName()
          The name of the element.
 boolean hasAttribute(String name)
           
 boolean hasAttributeNS(String namespaceURI, String localName)
           
 boolean hasAttributes()
           
 boolean isEqualNode(org.w3c.dom.Node other)
          Tests whether two nodes are equal.
protected  boolean isNodeTypeValid(short type)
           
protected  void loadAttributes(SymbolTable st)
           
 void removeAttribute(String name)
          Removes an attribute by name.
 org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
          Removes the specified attribute.
 void removeAttributeNS(String namespaceURI, String localName)
          Removes an attribute by local name and namespace URI.
 void setAttribute(String name, String value)
          Adds a new attribute.
 org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
          Adds a new attribute.
 org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
          Adds a new attribute.
 void setAttributeNS(String namespaceURI, String qualifiedName, String value)
          Adds a new attribute.
 void setIdAttribute(String name, boolean isId)
           
 void setIdAttributeNode(org.w3c.dom.Attr idAttr, boolean isId)
           
 void setIdAttributeNS(String namespaceURI, String localName, boolean isId)
           
 
Methods inherited from class org.apache.xindice.xml.dom.ContainerNodeImpl
appendChild, getChildNodes, getElementById, getElementsByTagName, getElementsByTagNameNS, getFirstChild, getLastChild, getNextSibling, getPreviousSibling, getTextContent, hasChildNodes, insertBefore, loadChildren, normalize, removeChild, replaceChild
 
Methods inherited from class org.apache.xindice.xml.dom.NodeImpl
checkReadOnly, cloneNode, cloneNode, compareDocumentPosition, getBaseURI, getDataBytes, getDataLen, getDataPos, getFeature, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getSource, getUserData, invokeHandlers, invokeHandlers, isDefaultNamespace, isDefined, isDirty, isLoaded, isSameNode, isSupported, load, lookupDefaultNamespaceURI, lookupNamespaceURI, lookupPrefix, setDataBytes, setDataBytes, setDataLen, setDataPos, setDirty, setNodeName, setNodeValue, setParentNode, setPrefix, setSource, setTextContent, setUserData, toString, unload
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Element
getElementsByTagName, getElementsByTagNameNS
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Constructor Detail

ElementImpl

public ElementImpl()

ElementImpl

public ElementImpl(NodeImpl parent,
                   byte[] data,
                   int pos,
                   int len)

ElementImpl

public ElementImpl(NodeImpl parent,
                   boolean dirty)

ElementImpl

public ElementImpl(NodeImpl parent,
                   String nodeName)
Method Detail

isNodeTypeValid

protected boolean isNodeTypeValid(short type)
Overrides:
isNodeTypeValid in class ContainerNodeImpl

checkLoaded

protected void checkLoaded()
Overrides:
checkLoaded in class ContainerNodeImpl

getSymbolID

public short getSymbolID()
Description copied from interface: CompressedNode
getSymbolID returns the Symbol ID for the current node. Some nodes will not have a Symbol ID, in which case, a value of -1 is returned.

Specified by:
getSymbolID in interface CompressedNode
Overrides:
getSymbolID in class NodeImpl

expandSource

public void expandSource()
Add "src" and "col" attributes in NodeSource.SOURCE_NS namespace.

Specified by:
expandSource in interface DBNode
Overrides:
expandSource in class NodeImpl

loadAttributes

protected void loadAttributes(SymbolTable st)
                       throws IOException
Throws:
IOException

getNodeType

public short getNodeType()
Description copied from class: NodeImpl
A code representing the type of the underlying object, as defined above.

Specified by:
getNodeType in interface org.w3c.dom.Node
Specified by:
getNodeType in class NodeImpl

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

Specified by:
getAttributes in interface org.w3c.dom.Node
Overrides:
getAttributes in class NodeImpl

hasAttributes

public boolean hasAttributes()
Specified by:
hasAttributes in interface org.w3c.dom.Node
Overrides:
hasAttributes in class NodeImpl

hasAttribute

public boolean hasAttribute(String name)
Specified by:
hasAttribute in interface org.w3c.dom.Element

removeAttribute

public void removeAttribute(String name)
                     throws org.w3c.dom.DOMException
Removes an attribute by name. If the removed attribute has a default value it is immediately replaced. If the named attribute does not exist, this method has no effect.

Specified by:
removeAttribute in interface org.w3c.dom.Element
Parameters:
name - The name of the attribute to remove.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

getTagName

public String getTagName()
The name of the element. For example, in: <elementExample id="demo"> ... </elementExample> , tagName has the value "elementExample". Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the tagName of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.

Specified by:
getTagName in interface org.w3c.dom.Element

getAttribute

public String getAttribute(String name)
Retrieves an attribute value by name.

Specified by:
getAttribute in interface org.w3c.dom.Element
Parameters:
name - The name of the attribute to retrieve.
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.

setAttributeNode

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
                                  throws org.w3c.dom.DOMException
Adds a new attribute. If an attribute with that name is already present in the element, it is replaced by the new one.

Specified by:
setAttributeNode in interface org.w3c.dom.Element
Parameters:
newAttr - The Attr node to add to the attribute list.
Returns:
If the newAttr attribute replaces an existing attribute with the same name, the previously existing Attr node is returned, otherwise null is returned.
Throws:
org.w3c.dom.DOMException - WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different document than the one that created the element.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.

setAttribute

public void setAttribute(String name,
                         String value)
                  throws org.w3c.dom.DOMException
Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string, it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNode to assign it as the value of an attribute.

Specified by:
setAttribute in interface org.w3c.dom.Element
Parameters:
name - The name of the attribute to create or alter.
value - Value to set in string form.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

getAttributeNode

public org.w3c.dom.Attr getAttributeNode(String name)
Retrieves an Attr node by name.

Specified by:
getAttributeNode in interface org.w3c.dom.Element
Parameters:
name - The name of the attribute to retrieve.
Returns:
The Attr node with the specified attribute name or null if there is no such attribute.

removeAttributeNode

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
                                     throws org.w3c.dom.DOMException
Removes the specified attribute.

Specified by:
removeAttributeNode in interface org.w3c.dom.Element
Parameters:
oldAttr - The Attr node to remove from the attribute list. If the removed Attr has a default value it is immediately replaced.
Returns:
The Attr node that was removed.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldAttr is not an attribute of the element.

getAttributeNS

public String getAttributeNS(String namespaceURI,
                             String localName)
Retrieves an attribute value by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.

Specified by:
getAttributeNS in interface org.w3c.dom.Element
Parameters:
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.
Since:
DOM Level 2

setAttributeNS

public void setAttributeNS(String namespaceURI,
                           String qualifiedName,
                           String value)
Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName , and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute.
HTML-only DOM implementations do not need to implement this method.

Specified by:
setAttributeNS in interface org.w3c.dom.Element
Parameters:
namespaceURI - The namespace URI of the attribute to create or alter.
qualifiedName - The qualified name of the attribute to create or alter.
value - The value to set in string form.
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null or an empty string, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace", if the qualifiedName has a prefix that is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/", or if the qualifiedName is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/".
Since:
DOM Level 2

removeAttributeNS

public void removeAttributeNS(String namespaceURI,
                              String localName)
Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.
HTML-only DOM implementations do not need to implement this method.

Specified by:
removeAttributeNS in interface org.w3c.dom.Element
Parameters:
namespaceURI - The namespace URI of the attribute to remove.
localName - The local name of the attribute to remove.
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
Since:
DOM Level 2

getAttributeNodeNS

public org.w3c.dom.Attr getAttributeNodeNS(String namespaceURI,
                                           String localName)
Retrieves an Attr node by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.

Specified by:
getAttributeNodeNS in interface org.w3c.dom.Element
Parameters:
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
The Attr node with the specified attribute local name and namespace URI or null if there is no such attribute.
Since:
DOM Level 2

setAttributeNodeNS

public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.
HTML-only DOM implementations do not need to implement this method.

Specified by:
setAttributeNodeNS in interface org.w3c.dom.Element
Parameters:
newAttr - The Attr node to add to the attribute list.
Returns:
If the newAttr attribute replaces an existing attribute with the same local name and namespace URI , the replaced Attr node is returned, otherwise null is returned.
Throws:
org.w3c.dom.DOMException - WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different document than the one that created the element.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
INUSE_ATTRIBUTE_ERR: Raised if newAttr 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

hasAttributeNS

public boolean hasAttributeNS(String namespaceURI,
                              String localName)
Specified by:
hasAttributeNS in interface org.w3c.dom.Element
Since:
DOM Level 2

getSchemaTypeInfo

public org.w3c.dom.TypeInfo getSchemaTypeInfo()
Since:
DOM Level 3

setIdAttribute

public void setIdAttribute(String name,
                           boolean isId)
                    throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException
Since:
DOM Level 3

setIdAttributeNS

public void setIdAttributeNS(String namespaceURI,
                             String localName,
                             boolean isId)
                      throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException
Since:
DOM Level 3

setIdAttributeNode

public void setIdAttributeNode(org.w3c.dom.Attr idAttr,
                               boolean isId)
                        throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException
Since:
DOM Level 3

isEqualNode

public boolean isEqualNode(org.w3c.dom.Node other)
Description copied from class: NodeImpl
Tests whether two nodes are equal. This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested with Node.isSameNode(). All nodes that are the same will also be equal, though the reverse may not be true.
Two nodes are equal if and only if the following conditions are satisfied:
For two DocumentType nodes to be equal, the following conditions must also be satisfied:
On the other hand, the following do not affect equality: the ownerDocument, baseURI, and parentNode attributes, the specified attribute for Attr nodes, the schemaTypeInfo attribute for Attr and Element nodes, the Text.isElementContentWhitespace attribute for Text nodes, as well as any user data or event listeners registered on the nodes.

Overrides:
isEqualNode in class ContainerNodeImpl
Since:
DOM Level 3

Xindice API
version 1.2m1

Copyright (c) 1999-2007 The Apache Software Foundation. All Rights Reserved.