org.exist.memtree
Class NodeImpl

java.lang.Object
  extended byorg.exist.memtree.NodeImpl
All Implemented Interfaces:
java.lang.Comparable, Item, org.w3c.dom.Node, NodeValue, QNameable, Sequence
Direct Known Subclasses:
AttributeImpl, CDATASectionImpl, CommentImpl, DocumentImpl, ElementImpl, NamespaceNode, ProcessingInstructionImpl, ReferenceNode, TextImpl

public class NodeImpl
extends java.lang.Object
implements org.w3c.dom.Node, NodeValue, QNameable, java.lang.Comparable


Field Summary
static short NAMESPACE_NODE
           
static short REFERENCE_NODE
           
 
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
 
Fields inherited from interface org.exist.xquery.value.NodeValue
IN_MEMORY_NODE, PERSISTENT_NODE
 
Fields inherited from interface org.exist.xquery.value.Sequence
EMPTY_SEQUENCE
 
Constructor Summary
NodeImpl(DocumentImpl doc, int nodeNumber)
           
 
Method Summary
 void add(Item item)
          Add an item to the current sequence.
 void addAll(Sequence other)
          Add all items of the other sequence to this item.
 void addContextNode(int contextId, NodeValue node)
           
 boolean after(NodeValue other, boolean isFollowing)
          Returns true if this node comes after another node in document order.
 org.w3c.dom.Node appendChild(org.w3c.dom.Node arg0)
           
 AtomicValue atomize()
           
 boolean before(NodeValue other, boolean isPreceding)
          Returns true if this node comes before another node in document order.
 void clearContext(int contextId)
          For every item in the sequence, clear any context-dependant information that is stored during query processing.
 org.w3c.dom.Node cloneNode(boolean arg0)
           
 short compareDocumentPosition(org.w3c.dom.Node other)
          ? @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node)
 int compareTo(java.lang.Object other)
           
 int conversionPreference(java.lang.Class javaClass)
          Returns a preference indicator, indicating the preference of a value to be converted into the given Java class.
 AtomicValue convertTo(int requiredType)
          Convert this item into an atomic value, whose type corresponds to the specified target type.
 void copyTo(DBBroker broker, DocumentBuilderReceiver receiver)
           
 void deepCopy()
           
 boolean effectiveBooleanValue()
          Get the effective boolean value of this sequence.
 boolean equals(NodeValue other)
          Returns true if this node has the same identity as another node.
 boolean equals(java.lang.Object obj)
           
 void expand()
           
 org.w3c.dom.NamedNodeMap getAttributes()
           
 java.lang.String getBaseURI()
          ? @see org.w3c.dom.Node#getBaseURI()
 int getCardinality()
          Returns the cardinality of this sequence.
 org.w3c.dom.NodeList getChildNodes()
           
 DocumentImpl getDocument()
           
 DocumentSet getDocumentSet()
          Returns the set of documents from which the node items in this sequence have been selected.
 java.lang.Object getFeature(java.lang.String feature, java.lang.String version)
          ? @see org.w3c.dom.Node#getFeature(java.lang.String, java.lang.String)
 org.w3c.dom.Node getFirstChild()
           
 int getImplementationType()
          Returns the implementation-type of this node, i.e.
 int getItemType()
          Return the primary type to which all items in this sequence belong.
 org.w3c.dom.Node getLastChild()
           
 int getLength()
          Returns the number of items contained in the sequence.
 java.lang.String getLocalName()
           
 java.lang.String getNamespaceURI()
           
 org.w3c.dom.Node getNextSibling()
           
 org.w3c.dom.Node getNode()
           
 java.lang.String getNodeName()
           
 int getNodeNumber()
           
 short getNodeType()
           
 java.lang.String getNodeValue()
           
 org.w3c.dom.Document getOwnerDocument()
           
 org.w3c.dom.Node getParentNode()
           
 java.lang.String getPrefix()
           
 org.w3c.dom.Node getPreviousSibling()
           
 QName getQName()
           
 java.lang.String getStringValue()
          Return the string value of this item (see the definition of string value in XPath).
 java.lang.String getTextContent()
          ? @see org.w3c.dom.Node#getTextContent()
 int getType()
          Return the type of this item according to the type constants defined in class Type.
 java.lang.Object getUserData(java.lang.String key)
          ? @see org.w3c.dom.Node#getUserData(java.lang.String)
 boolean hasAttributes()
           
 boolean hasChildNodes()
           
 boolean hasMany()
          Returns whether the sequence more than one item or not.
 boolean hasOne()
          Returns whether the sequence has just one item or not.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node arg0, org.w3c.dom.Node arg1)
           
 boolean isCached()
          Returns true if the sequence is the result of a previous operation and has been cached.
 boolean isDefaultNamespace(java.lang.String namespaceURI)
          ? @see org.w3c.dom.Node#isDefaultNamespace(java.lang.String)
 boolean isEmpty()
          Returns whether the sequence is empty or not.
 boolean isEqualNode(org.w3c.dom.Node arg)
          ? @see org.w3c.dom.Node#isEqualNode(org.w3c.dom.Node)
 boolean isPersistentSet()
           
 boolean isSameNode(org.w3c.dom.Node other)
          ? @see org.w3c.dom.Node#isSameNode(org.w3c.dom.Node)
 boolean isSupported(java.lang.String arg0, java.lang.String arg1)
           
 Item itemAt(int pos)
          Returns the item located at the specified position within this sequence.
 SequenceIterator iterate()
          Returns an iterator over all items in the sequence.
 java.lang.String lookupNamespaceURI(java.lang.String prefix)
          ? @see org.w3c.dom.Node#lookupNamespaceURI(java.lang.String)
 java.lang.String lookupPrefix(java.lang.String namespaceURI)
          ? @see org.w3c.dom.Node#lookupPrefix(java.lang.String)
 void normalize()
           
 org.w3c.dom.Node removeChild(org.w3c.dom.Node arg0)
           
 void removeDuplicates()
          Explicitely remove all duplicate nodes from this sequence.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node arg0, org.w3c.dom.Node arg1)
           
 void setIsCached(boolean cached)
          Indicates that the sequence is the result of a previous operation and has not been recomputed.
 void setNodeValue(java.lang.String arg0)
           
 void setPrefix(java.lang.String arg0)
           
 void setSelfAsContext(int contextId)
           
 void setTextContent(java.lang.String textContent)
          ? @see org.w3c.dom.Node#setTextContent(java.lang.String)
 java.lang.Object setUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)
          ? @see org.w3c.dom.Node#setUserData(java.lang.String, java.lang.Object, org.w3c.dom.UserDataHandler)
 void streamTo(Serializer serializer, Receiver receiver)
           
 java.lang.Object toJavaObject(java.lang.Class target)
          Convert the value into an instance of the specified Java class.
 NodeSet toNodeSet()
          Convert the sequence into a NodeSet.
 void toSAX(DBBroker broker, org.xml.sax.ContentHandler handler)
           
 Sequence toSequence()
          Convert this item into a sequence, containing only the item.
 SequenceIterator unorderedIterator()
          Returns an iterator over all items in the sequence.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REFERENCE_NODE

public static final short REFERENCE_NODE
See Also:
Constant Field Values

NAMESPACE_NODE

public static final short NAMESPACE_NODE
See Also:
Constant Field Values
Constructor Detail

NodeImpl

public NodeImpl(DocumentImpl doc,
                int nodeNumber)
Method Detail

getNodeNumber

public int getNodeNumber()

getImplementationType

public int getImplementationType()
Description copied from interface: NodeValue
Returns the implementation-type of this node, i.e. either NodeValue.IN_MEMORY_NODE or NodeValue.PERSISTENT_NODE.

Specified by:
getImplementationType in interface NodeValue

getDocumentSet

public DocumentSet getDocumentSet()
Description copied from interface: Sequence
Returns the set of documents from which the node items in this sequence have been selected. This is for internal use only.

Specified by:
getDocumentSet in interface Sequence

getNode

public org.w3c.dom.Node getNode()
Specified by:
getNode in interface NodeValue

getNodeName

public java.lang.String getNodeName()
Specified by:
getNodeName in interface org.w3c.dom.Node

getQName

public QName getQName()
Specified by:
getQName in interface QNameable

expand

public void expand()
            throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

deepCopy

public void deepCopy()
              throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

getNodeValue

public java.lang.String getNodeValue()
                              throws org.w3c.dom.DOMException
Specified by:
getNodeValue in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

setNodeValue

public void setNodeValue(java.lang.String arg0)
                  throws org.w3c.dom.DOMException
Specified by:
setNodeValue in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

getNodeType

public short getNodeType()
Specified by:
getNodeType in interface org.w3c.dom.Node

getParentNode

public org.w3c.dom.Node getParentNode()
Specified by:
getParentNode in interface org.w3c.dom.Node

addContextNode

public void addContextNode(int contextId,
                           NodeValue node)
Specified by:
addContextNode in interface NodeValue

equals

public boolean equals(java.lang.Object obj)

equals

public boolean equals(NodeValue other)
               throws XPathException
Description copied from interface: NodeValue
Returns true if this node has the same identity as another node. Used to implement "is" and "isnot" comparisons.

Specified by:
equals in interface NodeValue
Parameters:
other -
Throws:
XPathException

after

public boolean after(NodeValue other,
                     boolean isFollowing)
              throws XPathException
Description copied from interface: NodeValue
Returns true if this node comes after another node in document order.

Specified by:
after in interface NodeValue
Parameters:
other -
Throws:
XPathException

before

public boolean before(NodeValue other,
                      boolean isPreceding)
               throws XPathException
Description copied from interface: NodeValue
Returns true if this node comes before another node in document order.

Specified by:
before in interface NodeValue
Parameters:
other -
Throws:
XPathException

compareTo

public int compareTo(java.lang.Object other)
Specified by:
compareTo in interface java.lang.Comparable

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Specified by:
getChildNodes in interface org.w3c.dom.Node

getFirstChild

public org.w3c.dom.Node getFirstChild()
Specified by:
getFirstChild in interface org.w3c.dom.Node

getLastChild

public org.w3c.dom.Node getLastChild()
Specified by:
getLastChild in interface org.w3c.dom.Node

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
Specified by:
getPreviousSibling in interface org.w3c.dom.Node

getNextSibling

public org.w3c.dom.Node getNextSibling()
Specified by:
getNextSibling in interface org.w3c.dom.Node

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
Specified by:
getAttributes in interface org.w3c.dom.Node

getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()
Specified by:
getOwnerDocument in interface org.w3c.dom.Node

getDocument

public DocumentImpl getDocument()

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node arg0,
                                     org.w3c.dom.Node arg1)
                              throws org.w3c.dom.DOMException
Specified by:
insertBefore in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node arg0,
                                     org.w3c.dom.Node arg1)
                              throws org.w3c.dom.DOMException
Specified by:
replaceChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node arg0)
                             throws org.w3c.dom.DOMException
Specified by:
removeChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node arg0)
                             throws org.w3c.dom.DOMException
Specified by:
appendChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

hasChildNodes

public boolean hasChildNodes()
Specified by:
hasChildNodes in interface org.w3c.dom.Node

cloneNode

public org.w3c.dom.Node cloneNode(boolean arg0)
Specified by:
cloneNode in interface org.w3c.dom.Node

normalize

public void normalize()
Specified by:
normalize in interface org.w3c.dom.Node

isSupported

public boolean isSupported(java.lang.String arg0,
                           java.lang.String arg1)
Specified by:
isSupported in interface org.w3c.dom.Node

getNamespaceURI

public java.lang.String getNamespaceURI()
Specified by:
getNamespaceURI in interface org.w3c.dom.Node

getPrefix

public java.lang.String getPrefix()
Specified by:
getPrefix in interface org.w3c.dom.Node

setPrefix

public void setPrefix(java.lang.String arg0)
               throws org.w3c.dom.DOMException
Specified by:
setPrefix in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

getLocalName

public java.lang.String getLocalName()
Specified by:
getLocalName in interface org.w3c.dom.Node

hasAttributes

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

getType

public int getType()
Description copied from interface: Item
Return the type of this item according to the type constants defined in class Type.

Specified by:
getType in interface Item

getStringValue

public java.lang.String getStringValue()
Description copied from interface: Item
Return the string value of this item (see the definition of string value in XPath).

Specified by:
getStringValue in interface Item

toSequence

public Sequence toSequence()
Description copied from interface: Item
Convert this item into a sequence, containing only the item.

Specified by:
toSequence in interface Item

convertTo

public AtomicValue convertTo(int requiredType)
                      throws XPathException
Description copied from interface: Item
Convert this item into an atomic value, whose type corresponds to the specified target type. requiredType should be one of the type constants defined in Type. An XPathException is thrown if the conversion is impossible.

Specified by:
convertTo in interface Item
Parameters:
requiredType -
Throws:
XPathException

atomize

public AtomicValue atomize()
                    throws XPathException
Specified by:
atomize in interface Item
Throws:
XPathException

isEmpty

public boolean isEmpty()
Description copied from interface: Sequence
Returns whether the sequence is empty or not.

Specified by:
isEmpty in interface Sequence
Returns:
true is the sequence is empty

hasOne

public boolean hasOne()
Description copied from interface: Sequence
Returns whether the sequence has just one item or not.

Specified by:
hasOne in interface Sequence
Returns:
true is the sequence has just one item

hasMany

public boolean hasMany()
Description copied from interface: Sequence
Returns whether the sequence more than one item or not.

Specified by:
hasMany in interface Sequence
Returns:
true is the sequence more than one item

add

public void add(Item item)
         throws XPathException
Description copied from interface: Sequence
Add an item to the current sequence. An XPathException may be thrown if the item's type is incompatible with this type of sequence (e.g. if the sequence is a node set). The sequence may or may not allow duplicate values.

Specified by:
add in interface Sequence
Parameters:
item -
Throws:
XPathException

addAll

public void addAll(Sequence other)
            throws XPathException
Description copied from interface: Sequence
Add all items of the other sequence to this item. An XPathException may be thrown if the type of the items in the other sequence is incompatible with the primary type of this sequence.

Specified by:
addAll in interface Sequence
Parameters:
other -
Throws:
XPathException

getItemType

public int getItemType()
Description copied from interface: Sequence
Return the primary type to which all items in this sequence belong. This is Type.NODE for node sets, Type.ITEM for other sequences with mixed items.

Specified by:
getItemType in interface Sequence
Returns:
the primary type of the items in this sequence.

iterate

public SequenceIterator iterate()
                         throws XPathException
Description copied from interface: Sequence
Returns an iterator over all items in the sequence. The items are returned in document order where applicable.

Specified by:
iterate in interface Sequence
Throws:
XPathException - TODO

unorderedIterator

public SequenceIterator unorderedIterator()
Description copied from interface: Sequence
Returns an iterator over all items in the sequence. The returned items may - but need not - to be in document order.

Specified by:
unorderedIterator in interface Sequence

getLength

public int getLength()
Description copied from interface: Sequence
Returns the number of items contained in the sequence. Call this method only when necessary, since it can be resource consuming.

Specified by:
getLength in interface Sequence
Returns:
The sequence's length

getCardinality

public int getCardinality()
Description copied from interface: Sequence
Returns the cardinality of this sequence. The returned value is a combination of flags as defined in Cardinality.

Specified by:
getCardinality in interface Sequence
See Also:
Cardinality

itemAt

public Item itemAt(int pos)
Description copied from interface: Sequence
Returns the item located at the specified position within this sequence. Items are counted beginning at 0.

Specified by:
itemAt in interface Sequence
Parameters:
pos -

effectiveBooleanValue

public boolean effectiveBooleanValue()
                              throws XPathException
Description copied from interface: Sequence
Get the effective boolean value of this sequence. Will be false if the sequence is empty, true otherwise.

Specified by:
effectiveBooleanValue in interface Sequence
Throws:
XPathException

toNodeSet

public NodeSet toNodeSet()
                  throws XPathException
Description copied from interface: Sequence
Convert the sequence into a NodeSet. If the sequence contains items which are not nodes, an XPathException is thrown.

Specified by:
toNodeSet in interface Sequence
Throws:
XPathException - if the sequence contains items which are not nodes.

toSAX

public void toSAX(DBBroker broker,
                  org.xml.sax.ContentHandler handler)
           throws org.xml.sax.SAXException
Specified by:
toSAX in interface Item
Throws:
org.xml.sax.SAXException

copyTo

public void copyTo(DBBroker broker,
                   DocumentBuilderReceiver receiver)
            throws org.xml.sax.SAXException
Specified by:
copyTo in interface Item
Throws:
org.xml.sax.SAXException

streamTo

public void streamTo(Serializer serializer,
                     Receiver receiver)
              throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

conversionPreference

public int conversionPreference(java.lang.Class javaClass)
Description copied from interface: Sequence
Returns a preference indicator, indicating the preference of a value to be converted into the given Java class. Low numbers mean that the value can be easily converted into the given class.

Specified by:
conversionPreference in interface Item

toJavaObject

public java.lang.Object toJavaObject(java.lang.Class target)
                              throws XPathException
Description copied from interface: Sequence
Convert the value into an instance of the specified Java class.

Specified by:
toJavaObject in interface Item
Throws:
XPathException

setSelfAsContext

public void setSelfAsContext(int contextId)
Specified by:
setSelfAsContext in interface Sequence

isCached

public boolean isCached()
Description copied from interface: Sequence
Returns true if the sequence is the result of a previous operation and has been cached.

Specified by:
isCached in interface Sequence

setIsCached

public void setIsCached(boolean cached)
Description copied from interface: Sequence
Indicates that the sequence is the result of a previous operation and has not been recomputed.

Specified by:
setIsCached in interface Sequence
Parameters:
cached -

removeDuplicates

public void removeDuplicates()
Description copied from interface: Sequence
Explicitely remove all duplicate nodes from this sequence.

Specified by:
removeDuplicates in interface Sequence

getBaseURI

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


compareDocumentPosition

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

Throws:
org.w3c.dom.DOMException

getTextContent

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

Throws:
org.w3c.dom.DOMException

setTextContent

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

Throws:
org.w3c.dom.DOMException

isSameNode

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


lookupPrefix

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


isDefaultNamespace

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


lookupNamespaceURI

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


isEqualNode

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


getFeature

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


setUserData

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


getUserData

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


isPersistentSet

public boolean isPersistentSet()
Specified by:
isPersistentSet in interface Sequence

clearContext

public void clearContext(int contextId)
Description copied from interface: Sequence
For every item in the sequence, clear any context-dependant information that is stored during query processing. This feature is used for node sets, which may store information about their context node.

Specified by:
clearContext in interface Sequence


Copyright (C) Wolfgang Meier. All rights reserved.