org.exist.fluent
Class Node

java.lang.Object
  extended by org.exist.fluent.Resource
      extended by org.exist.fluent.Item
          extended by org.exist.fluent.Node

public class Node
extends Item

A node in the database. Nodes are most often contained in XML documents, but can also be transient in-memory nodes created by a query.

Author:
Piotr Kaminski

Method Summary
 ElementBuilder<Node> append()
          Return a builder that will append elements to this node's children.
 Comparable<Object> comparableValue()
          Return the comparable value of this item, if available.
 int compareDocumentOrderTo(Node node)
          Compare the order of two nodes in a document.
 void delete()
          Delete this node from its parent.
 XMLDocument document()
          Return the document to which this node belongs.
 boolean equals(Object o)
          Return whether this node represents the same node in the database as the given object.
 boolean extant()
          Return whether this item really exists.
 int hashCode()
          Warning: computing a node's hash code is surprisingly expensive, and the value is not cached.
 NamespaceMap inScopeNamespaces()
          Return the namespace bindings in force in the scope of this node.
 String name()
          Return the name of this node, in the "prefix:localName" form.
 Node node()
          Return this node.
 QName qname()
          Return the qualified name of this node, including its namespace URI, local name and prefix.
 ElementBuilder<?> replace()
          Return a builder that will replace this node.
 AttributeBuilder update()
          Return a builder for updating the attribute values of this element.
 
Methods inherited from class org.exist.fluent.Item
booleanValue, dateTimeValue, doubleValue, durationValue, instantValue, intValue, longValue, toAtomicItem, toItemList, toString, type, value, valueWithDefault
 
Methods inherited from class org.exist.fluent.Resource
database, namespaceBindings, query
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

extant

public boolean extant()
Description copied from class: Item
Return whether this item really exists. Examples of items that don't exist even though they have an object representing them include virtual placeholders returned for an optional query that didn't select an item, and items that were deleted from the database after being selected.

Overrides:
extant in class Item
Returns:
true if the item exists, false otherwise

node

public Node node()
Return this node.

Overrides:
node in class Item
Returns:
this node

comparableValue

public Comparable<Object> comparableValue()
Description copied from class: Item
Return the comparable value of this item, if available. The resulting object will directly compare the XQuery value without converting to a string first, unless the item is untyped and atomic, in which case it will be cast to a string. Items of different types will compare in an arbitrary but stable order. Nodes are never comparable.

Overrides:
comparableValue in class Item
Returns:
the comparable value of this item

equals

public boolean equals(Object o)
Return whether this node represents the same node in the database as the given object.

Overrides:
equals in class Item

hashCode

public int hashCode()
Warning: computing a node's hash code is surprisingly expensive, and the value is not cached. You should not use nodes in situations where they might get hashed.

Overrides:
hashCode in class Item

inScopeNamespaces

public NamespaceMap inScopeNamespaces()
Return the namespace bindings in force in the scope of this node. Only works on nodes that are XML elements. Namespaces reserved by the XML spec, and implicitly in scope for all XML elements, are not reported.

Returns:
the namespace bindings in force for this node

compareDocumentOrderTo

public int compareDocumentOrderTo(Node node)
Compare the order of two nodes in a document.

Parameters:
node - the node to compare this one to
Returns:
node 0 if this node is the same as the given node, a value less than 0 if it precedes the given node in the document, and a value great than 0 if it follows the given node in the document
Throws:
DatabaseException - if this node and the given one are not in the same document

document

public XMLDocument document()
Return the document to which this node belongs.

Returns:
the document to which this node belongs
Throws:
UnsupportedOperationException - if this node does not belong to a document

append

public ElementBuilder<Node> append()
Return a builder that will append elements to this node's children. The builder will return the appended node if a single node was appended, otherwise null.

Returns:
a builder that will append nodes to this node

delete

public void delete()
Delete this node from its parent. This can delete an element from a document, or an attribute from an element, etc. Trying to delete the root element of a document will delete the document instead. If the node cannot be found, assume it's already been deleted and return silently.


name

public String name()
Return the name of this node, in the "prefix:localName" form.

Returns:
the name of this node

qname

public QName qname()
Return the qualified name of this node, including its namespace URI, local name and prefix.

Returns:
the qname of this node

replace

public ElementBuilder<?> replace()
Return a builder that will replace this node. The builder returns null.

Returns:
a builder that will replace this node
Throws:
UnsupportedOperationException - if the node does not have a parent

update

public AttributeBuilder update()
Return a builder for updating the attribute values of this element.

Returns:
an attribute builder for this element
Throws:
UnsupportedOperationException - if this node is not an element


Copyright (C) All rights reserved.