org.exist.dom
Class ElementImpl

java.lang.Object
  extended by org.exist.dom.NodeImpl
      extended by org.exist.dom.StoredNode
          extended by org.exist.dom.NamedNode
              extended by org.exist.dom.ElementImpl
All Implemented Interfaces:
QNameable, Visitable, Element, Node

public class ElementImpl
extends NamedNode
implements Element

ElementImpl.java

Author:
Wolfgang Meier

Field Summary
static int LENGTH_ATTRIBUTES_COUNT
           
static int LENGTH_ELEMENT_CHILD_COUNT
           
static int LENGTH_NS_ID
           
static int LENGTH_PREFIX_LENGTH
           
 
Fields inherited from class org.exist.dom.StoredNode
LENGTH_SIGNATURE_LENGTH, UNKNOWN_NODE_IMPL_ADDRESS
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
ElementImpl()
           
ElementImpl(ElementImpl other)
           
ElementImpl(QName nodeName)
          Constructor for the ElementImpl object
 
Method Summary
 boolean accept(Iterator iterator, NodeVisitor visitor)
          Visit the current node.
 void addNamespaceMapping(String prefix, String ns)
           
 void appendAttributes(Txn transaction, NodeList attribs)
           
 Node appendChild(Node child)
           
 void appendChildInternal(StoredNode prevNode, StoredNode child)
          Append a child to this node.
 void appendChildren(Txn transaction, NodeList nodes, int child)
           
 void clear()
          Reset this element to its initial state.
 short compareDocumentPosition(Node other)
          ? @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node)
 boolean declaresNamespacePrefixes()
           
static StoredNode deserialize(byte[] data, int start, int len, DocumentImpl doc, boolean pooled)
           
 String getAttribute(String name)
           
 Attr getAttributeNode(String name)
           
 Attr getAttributeNodeNS(String namespaceURI, String localName)
           
 String getAttributeNS(String namespaceURI, String localName)
           
 NamedNodeMap getAttributes()
           
 short getAttributesCount()
           
 String getBaseURI()
          ? @see org.w3c.dom.Node#getBaseURI()
 int getChildCount()
           
 NodeList getChildNodes()
           
 NodeList getElementsByTagName(String tagName)
           
 NodeList getElementsByTagNameNS(String namespaceURI, String localName)
           
 Object getFeature(String feature, String version)
          ? @see org.w3c.dom.Node#getFeature(java.lang.String, java.lang.String)
 Node getFirstChild()
           
 int getIndexType()
           
 Node getLastChild()
           
 String getNamespaceForPrefix(String prefix)
           
 String getNodeValue()
           
 int getPosition()
           
 int getPrefixCount()
           
 Iterator getPrefixes()
           
 TypeInfo getSchemaTypeInfo()
          ? @see org.w3c.dom.Element#getSchemaTypeInfo()
 String getTagName()
           
 String getTextContent()
          ? @see org.w3c.dom.Node#getTextContent()
 Object getUserData(String key)
          ? @see org.w3c.dom.Node#getUserData(java.lang.String)
 boolean hasAttribute(String name)
           
 boolean hasAttributeNS(String namespaceURI, String localName)
           
 boolean hasAttributes()
           
 boolean hasChildNodes()
           
 void insertAfter(Txn transaction, NodeList nodes, Node refChild)
          Insert a list of nodes at the position following the reference child.
 Node insertBefore(Node newChild, Node refChild)
           
 void insertBefore(Txn transaction, NodeList nodes, Node refChild)
          Insert a list of nodes at the position before the reference child.
 boolean isDefaultNamespace(String namespaceURI)
          ? @see org.w3c.dom.Node#isDefaultNamespace(java.lang.String)
 boolean isDirty()
          Returns true if the node was modified recently and nodes were inserted at the start or in the middle of its children.
 boolean isEqualNode(Node arg)
          ? @see org.w3c.dom.Node#isEqualNode(org.w3c.dom.Node)
 boolean isSameNode(Node other)
          ? @see org.w3c.dom.Node#isSameNode(org.w3c.dom.Node)
 String lookupNamespaceURI(String prefix)
          ? @see org.w3c.dom.Node#lookupNamespaceURI(java.lang.String)
 String lookupPrefix(String namespaceURI)
          ? @see org.w3c.dom.Node#lookupPrefix(java.lang.String)
 boolean preserveSpace()
           
static void readNamespaceDecls(List namespaces, Value value, DocumentImpl document, NodeId nodeId)
           
static QName readQName(Value value, DocumentImpl document, NodeId nodeId)
           
 void removeAppendAttributes(Txn transaction, NodeList removeList, NodeList appendList)
           
 void removeAttribute(String name)
           
 Attr removeAttributeNode(Attr oldAttr)
           
 void removeAttributeNS(String namespaceURI, String name)
           
 Node removeChild(Txn transaction, Node oldChild)
           
 Node replaceChild(Txn transaction, Node newChild, Node oldChild)
          Replaces the oldNode with the newChild
 byte[] serialize()
           
 void setAttribute(String name, String value)
           
 Attr setAttributeNode(Attr newAttr)
           
 Attr setAttributeNodeNS(Attr newAttr)
           
 void setAttributeNS(String namespaceURI, String qualifiedName, String value)
           
 void setAttributes(short attribNum)
          Set the attributes that belong to this node.
 void setChildCount(int count)
          Set the number of children.
 void setDirty(boolean dirty)
           
 void setIdAttribute(String name, boolean isId)
          ? @see org.w3c.dom.Element#setIdAttribute(java.lang.String, boolean)
 void setIdAttributeNode(Attr idAttr, boolean isId)
          ? @see org.w3c.dom.Element#setIdAttributeNode(org.w3c.dom.Attr, boolean)
 void setIdAttributeNS(String namespaceURI, String localName, boolean isId)
          ? @see org.w3c.dom.Element#setIdAttributeNS(java.lang.String, java.lang.String, boolean)
 void setIndexType(int idxType)
           
 void setNamespaceMappings(Map map)
           
 void setPosition(int position)
           
 void setPreserveSpace(boolean preserveWS)
           
 void setTextContent(String textContent)
          ? @see org.w3c.dom.Node#setTextContent(java.lang.String)
 Object setUserData(String key, Object data, UserDataHandler handler)
          ? @see org.w3c.dom.Node#setUserData(java.lang.String, java.lang.Object, org.w3c.dom.UserDataHandler)
 String toString()
           
 String toString(boolean top)
           
 String toString(boolean top, TreeSet namespaces)
          Method toString.
 void update(Txn transaction, NodeList newContent)
          Update the contents of this element.
 StoredNode updateChild(Txn transaction, Node oldChild, Node newChild)
          Update a child node.
 
Methods inherited from class org.exist.dom.NamedNode
getQName, setNodeName
 
Methods inherited from class org.exist.dom.StoredNode
accept, deserialize, equals, getDocId, getDocument, getInternalAddress, getNextSibling, getNodeId, getNodeType, getOwnerDocument, getParentNode, getPath, getPath, getPreviousSibling, release, setInternalAddress, setNodeId, setOwnerDocument
 
Methods inherited from class org.exist.dom.NodeImpl
cloneNode, getLocalName, getNamespaceURI, getNodeName, getPrefix, insertAfter, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix, supports, updateChild
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
cloneNode, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

LENGTH_ELEMENT_CHILD_COUNT

public static final int LENGTH_ELEMENT_CHILD_COUNT
See Also:
Constant Field Values

LENGTH_ATTRIBUTES_COUNT

public static final int LENGTH_ATTRIBUTES_COUNT
See Also:
Constant Field Values

LENGTH_NS_ID

public static final int LENGTH_NS_ID
See Also:
Constant Field Values

LENGTH_PREFIX_LENGTH

public static final int LENGTH_PREFIX_LENGTH
See Also:
Constant Field Values
Constructor Detail

ElementImpl

public ElementImpl()

ElementImpl

public ElementImpl(QName nodeName)
Constructor for the ElementImpl object

Parameters:
nodeName - Description of the Parameter

ElementImpl

public ElementImpl(ElementImpl other)
Method Detail

clear

public void clear()
Reset this element to its initial state.

Overrides:
clear in class NamedNode

setIndexType

public void setIndexType(int idxType)

getIndexType

public int getIndexType()

isDirty

public boolean isDirty()
Description copied from class: StoredNode
Returns true if the node was modified recently and nodes were inserted at the start or in the middle of its children.

Overrides:
isDirty in class StoredNode
Returns:
TRUE when node is 'dirty'

setDirty

public void setDirty(boolean dirty)
Overrides:
setDirty in class StoredNode

setPosition

public void setPosition(int position)

getPosition

public int getPosition()

declaresNamespacePrefixes

public boolean declaresNamespacePrefixes()

serialize

public byte[] serialize()
Overrides:
serialize in class StoredNode

deserialize

public static StoredNode deserialize(byte[] data,
                                     int start,
                                     int len,
                                     DocumentImpl doc,
                                     boolean pooled)

readQName

public static QName readQName(Value value,
                              DocumentImpl document,
                              NodeId nodeId)

readNamespaceDecls

public static void readNamespaceDecls(List namespaces,
                                      Value value,
                                      DocumentImpl document,
                                      NodeId nodeId)

addNamespaceMapping

public void addNamespaceMapping(String prefix,
                                String ns)

appendChildInternal

public void appendChildInternal(StoredNode prevNode,
                                StoredNode child)
                         throws DOMException
Append a child to this node. This method does not rearrange the node tree and is only used internally by the parser.

Parameters:
child -
Throws:
DOMException

appendChild

public Node appendChild(Node child)
                 throws DOMException
Specified by:
appendChild in interface Node
Overrides:
appendChild in class NodeImpl
Throws:
DOMException
See Also:
Node.appendChild(org.w3c.dom.Node)

appendAttributes

public void appendAttributes(Txn transaction,
                             NodeList attribs)
                      throws DOMException
Throws:
DOMException

appendChildren

public void appendChildren(Txn transaction,
                           NodeList nodes,
                           int child)
                    throws DOMException
Overrides:
appendChildren in class NodeImpl
Throws:
DOMException

getAttributesCount

public short getAttributesCount()
Overrides:
getAttributesCount in class NodeImpl

setAttributes

public void setAttributes(short attribNum)
Set the attributes that belong to this node.

Overrides:
setAttributes in class NodeImpl
Parameters:
attribNum - The new attributes value

getAttribute

public String getAttribute(String name)
Specified by:
getAttribute in interface Element
See Also:
Element.getAttribute(java.lang.String)

getAttributeNS

public String getAttributeNS(String namespaceURI,
                             String localName)
Specified by:
getAttributeNS in interface Element
See Also:
Element.getAttributeNS(java.lang.String, java.lang.String)

getAttributeNode

public Attr getAttributeNode(String name)
Specified by:
getAttributeNode in interface Element
See Also:
Element.getAttributeNode(java.lang.String)

getAttributeNodeNS

public Attr getAttributeNodeNS(String namespaceURI,
                               String localName)
Specified by:
getAttributeNodeNS in interface Element
See Also:
Element.getAttributeNodeNS(java.lang.String, java.lang.String)

getAttributes

public NamedNodeMap getAttributes()
Specified by:
getAttributes in interface Node
Overrides:
getAttributes in class NodeImpl
See Also:
Node.getAttributes()

getChildCount

public int getChildCount()
Overrides:
getChildCount in class NodeImpl
See Also:
NodeImpl.getChildCount()

getChildNodes

public NodeList getChildNodes()
Specified by:
getChildNodes in interface Node
Overrides:
getChildNodes in class NodeImpl

getElementsByTagName

public NodeList getElementsByTagName(String tagName)
Specified by:
getElementsByTagName in interface Element
See Also:
Element.getElementsByTagName(java.lang.String)

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI,
                                       String localName)
Specified by:
getElementsByTagNameNS in interface Element
See Also:
Element.getElementsByTagNameNS(java.lang.String, java.lang.String)

getFirstChild

public Node getFirstChild()
Specified by:
getFirstChild in interface Node
Overrides:
getFirstChild in class NodeImpl
See Also:
Node.getFirstChild()

getLastChild

public Node getLastChild()
Specified by:
getLastChild in interface Node
Overrides:
getLastChild in class NodeImpl
See Also:
Node.getLastChild()

getTagName

public String getTagName()
Specified by:
getTagName in interface Element
See Also:
Element.getTagName()

hasAttribute

public boolean hasAttribute(String name)
Specified by:
hasAttribute in interface Element
See Also:
Element.hasAttribute(java.lang.String)

hasAttributeNS

public boolean hasAttributeNS(String namespaceURI,
                              String localName)
Specified by:
hasAttributeNS in interface Element
See Also:
Element.hasAttributeNS(java.lang.String, java.lang.String)

hasAttributes

public boolean hasAttributes()
Specified by:
hasAttributes in interface Node
Overrides:
hasAttributes in class NodeImpl
See Also:
Node.hasAttributes()

hasChildNodes

public boolean hasChildNodes()
Specified by:
hasChildNodes in interface Node
Overrides:
hasChildNodes in class NodeImpl
See Also:
Node.hasChildNodes()

getNodeValue

public String getNodeValue()
Specified by:
getNodeValue in interface Node
Overrides:
getNodeValue in class NodeImpl
See Also:
Node.getNodeValue()

removeAttribute

public void removeAttribute(String name)
                     throws DOMException
Specified by:
removeAttribute in interface Element
Throws:
DOMException
See Also:
Element.removeAttribute(java.lang.String)

removeAttributeNS

public void removeAttributeNS(String namespaceURI,
                              String name)
                       throws DOMException
Specified by:
removeAttributeNS in interface Element
Throws:
DOMException
See Also:
Element.removeAttributeNS(java.lang.String, java.lang.String)

removeAttributeNode

public Attr removeAttributeNode(Attr oldAttr)
                         throws DOMException
Specified by:
removeAttributeNode in interface Element
Throws:
DOMException

setAttribute

public void setAttribute(String name,
                         String value)
                  throws DOMException
Specified by:
setAttribute in interface Element
Throws:
DOMException

setAttributeNS

public void setAttributeNS(String namespaceURI,
                           String qualifiedName,
                           String value)
                    throws DOMException
Specified by:
setAttributeNS in interface Element
Throws:
DOMException

setAttributeNode

public Attr setAttributeNode(Attr newAttr)
                      throws DOMException
Specified by:
setAttributeNode in interface Element
Throws:
DOMException

setAttributeNodeNS

public Attr setAttributeNodeNS(Attr newAttr)
Specified by:
setAttributeNodeNS in interface Element

setChildCount

public void setChildCount(int count)
Description copied from class: NodeImpl
Set the number of children.

Parameters:
count - The new childCount value

setNamespaceMappings

public void setNamespaceMappings(Map map)

getPrefixes

public Iterator getPrefixes()

getNamespaceForPrefix

public String getNamespaceForPrefix(String prefix)

getPrefixCount

public int getPrefixCount()

toString

public String toString()
Overrides:
toString in class StoredNode
See Also:
Object.toString()

toString

public String toString(boolean top)
Overrides:
toString in class StoredNode

toString

public String toString(boolean top,
                       TreeSet namespaces)
Method toString.


insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Specified by:
insertBefore in interface Node
Overrides:
insertBefore in class NodeImpl
Throws:
DOMException
See Also:
Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)

insertBefore

public void insertBefore(Txn transaction,
                         NodeList nodes,
                         Node refChild)
                  throws DOMException
Insert a list of nodes at the position before the reference child.

Overrides:
insertBefore in class NodeImpl
Throws:
DOMException

insertAfter

public void insertAfter(Txn transaction,
                        NodeList nodes,
                        Node refChild)
                 throws DOMException
Insert a list of nodes at the position following the reference child.

Overrides:
insertAfter in class NodeImpl
Throws:
DOMException

update

public void update(Txn transaction,
                   NodeList newContent)
            throws DOMException
Update the contents of this element. The passed list of nodes becomes the new content.

Parameters:
newContent -
Throws:
DOMException

updateChild

public StoredNode updateChild(Txn transaction,
                              Node oldChild,
                              Node newChild)
                       throws DOMException
Update a child node. This method will only update the child node but not its potential descendant nodes.

Overrides:
updateChild in class NodeImpl
Parameters:
oldChild -
newChild -
Throws:
DOMException

removeChild

public Node removeChild(Txn transaction,
                        Node oldChild)
                 throws DOMException
Overrides:
removeChild in class NodeImpl
Throws:
DOMException
See Also:
Node.removeChild(org.w3c.dom.Node)

removeAppendAttributes

public void removeAppendAttributes(Txn transaction,
                                   NodeList removeList,
                                   NodeList appendList)

replaceChild

public Node replaceChild(Txn transaction,
                         Node newChild,
                         Node oldChild)
                  throws DOMException
Replaces the oldNode with the newChild

Overrides:
replaceChild in class NodeImpl
Parameters:
transaction -
newChild -
oldChild -
Returns:
The new node (this differs from the Node.replaceChild(Node, Node) specification)
Throws:
DOMException
See Also:
Node.replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)

setPreserveSpace

public void setPreserveSpace(boolean preserveWS)

preserveSpace

public boolean preserveSpace()

getSchemaTypeInfo

public TypeInfo getSchemaTypeInfo()
? @see org.w3c.dom.Element#getSchemaTypeInfo()

Specified by:
getSchemaTypeInfo in interface Element

setIdAttribute

public void setIdAttribute(String name,
                           boolean isId)
                    throws DOMException
? @see org.w3c.dom.Element#setIdAttribute(java.lang.String, boolean)

Specified by:
setIdAttribute in interface Element
Throws:
DOMException

setIdAttributeNS

public void setIdAttributeNS(String namespaceURI,
                             String localName,
                             boolean isId)
                      throws DOMException
? @see org.w3c.dom.Element#setIdAttributeNS(java.lang.String, java.lang.String, boolean)

Specified by:
setIdAttributeNS in interface Element
Throws:
DOMException

setIdAttributeNode

public void setIdAttributeNode(Attr idAttr,
                               boolean isId)
                        throws DOMException
? @see org.w3c.dom.Element#setIdAttributeNode(org.w3c.dom.Attr, boolean)

Specified by:
setIdAttributeNode in interface Element
Throws:
DOMException

getBaseURI

public String getBaseURI()
? @see org.w3c.dom.Node#getBaseURI()

Specified by:
getBaseURI in interface Node
Overrides:
getBaseURI in class NodeImpl

compareDocumentPosition

public short compareDocumentPosition(Node other)
                              throws DOMException
? @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node)

Specified by:
compareDocumentPosition in interface Node
Overrides:
compareDocumentPosition in class NodeImpl
Throws:
DOMException

getTextContent

public String getTextContent()
                      throws DOMException
? @see org.w3c.dom.Node#getTextContent()

Specified by:
getTextContent in interface Node
Overrides:
getTextContent in class NodeImpl
Throws:
DOMException

setTextContent

public void setTextContent(String textContent)
                    throws DOMException
? @see org.w3c.dom.Node#setTextContent(java.lang.String)

Specified by:
setTextContent in interface Node
Overrides:
setTextContent in class NodeImpl
Throws:
DOMException

isSameNode

public boolean isSameNode(Node other)
? @see org.w3c.dom.Node#isSameNode(org.w3c.dom.Node)

Specified by:
isSameNode in interface Node
Overrides:
isSameNode in class NodeImpl

lookupPrefix

public String lookupPrefix(String namespaceURI)
? @see org.w3c.dom.Node#lookupPrefix(java.lang.String)

Specified by:
lookupPrefix in interface Node
Overrides:
lookupPrefix in class NodeImpl

isDefaultNamespace

public boolean isDefaultNamespace(String namespaceURI)
? @see org.w3c.dom.Node#isDefaultNamespace(java.lang.String)

Specified by:
isDefaultNamespace in interface Node
Overrides:
isDefaultNamespace in class NodeImpl

lookupNamespaceURI

public String lookupNamespaceURI(String prefix)
? @see org.w3c.dom.Node#lookupNamespaceURI(java.lang.String)

Specified by:
lookupNamespaceURI in interface Node
Overrides:
lookupNamespaceURI in class NodeImpl

isEqualNode

public boolean isEqualNode(Node arg)
? @see org.w3c.dom.Node#isEqualNode(org.w3c.dom.Node)

Specified by:
isEqualNode in interface Node
Overrides:
isEqualNode in class NodeImpl

getFeature

public Object getFeature(String feature,
                         String version)
? @see org.w3c.dom.Node#getFeature(java.lang.String, java.lang.String)

Specified by:
getFeature in interface Node
Overrides:
getFeature in class NodeImpl

setUserData

public Object setUserData(String key,
                          Object data,
                          UserDataHandler handler)
? @see org.w3c.dom.Node#setUserData(java.lang.String, java.lang.Object, org.w3c.dom.UserDataHandler)

Specified by:
setUserData in interface Node
Overrides:
setUserData in class NodeImpl

getUserData

public Object getUserData(String key)
? @see org.w3c.dom.Node#getUserData(java.lang.String)

Specified by:
getUserData in interface Node
Overrides:
getUserData in class NodeImpl

accept

public boolean accept(Iterator iterator,
                      NodeVisitor visitor)
Description copied from interface: Visitable
Visit the current node. For element nodes, the method recursively traverses through the child nodes and calls accept on each of them.

Specified by:
accept in interface Visitable
Overrides:
accept in class StoredNode
Parameters:
iterator - an iterator positioned at the current node
visitor - the visitor to call.
Returns:
the value returned by the NodeVisitor.visit method.


Copyright (C) Wolfgang Meier. All rights reserved.