org.exist.dom
Class VirtualNodeSet

java.lang.Object
  extended by org.exist.xquery.value.AbstractSequence
      extended by org.exist.dom.AbstractNodeSet
          extended by org.exist.dom.VirtualNodeSet
All Implemented Interfaces:
NodeSet, Sequence, NodeList

public class VirtualNodeSet
extends AbstractNodeSet

This node set is called virtual because it is just a placeholder for the set of relevant nodes. For XPath expressions like //* or //node(), it would be totally unefficient to actually retrieve all descendant nodes. In many cases, the expression can be resolved at a later point in time without retrieving the whole node set. VirtualNodeSet basically provides method getFirstParent to retrieve the first matching descendant of its context according to the primary type axis. Class LocationStep will always return an instance of VirtualNodeSet if it finds something like descendant::* etc..

Author:
Wolfgang Meier, Timo Boehme

Field Summary
 
Fields inherited from interface org.exist.dom.NodeSet
ANCESTOR, DESCENDANT, EMPTY_SET, FOLLOWING, PRECEDING
 
Fields inherited from interface org.exist.xquery.value.Sequence
EMPTY_SEQUENCE
 
Constructor Summary
VirtualNodeSet(DBBroker broker, int axis, NodeTest test, int contextId, NodeSet context)
          Creates a new VirtualNodeSet instance.
 
Method Summary
 void add(DocumentImpl doc, long nodeId)
          The method add
 void add(Node node)
          The method add
 void add(NodeProxy proxy)
          The method add
 void addAll(NodeList other)
          The method addAll
 void addAll(NodeSet other)
          The method addAll
 void clearContext()
          The method clearContext
 boolean contains(NodeProxy p)
          The method contains
 NodeSet filterDocuments(NodeSet otherSet)
          The method filterDocuments
 NodeProxy get(DocumentImpl doc, NodeId nodeId)
          The method get
 NodeProxy get(int pos)
          The method get
 NodeProxy get(NodeProxy proxy)
          The method get
 Iterator getCollectionIterator()
          The method getCollectionIterator
 DocumentSet getDocumentSet()
          Returns the set of documents from which the node items in this sequence have been selected.
 int getItemCount()
          The method getItemCount
 int getLength()
          The method getLength
 boolean hasIndex()
           
 boolean hasMany()
          The method hasMany
 boolean hasOne()
          The method hasOne
 NodeSet intersection(NodeSet other)
          The method intersection
 boolean isEmpty()
          The method isEmpty
 Node item(int pos)
          The method item
 Item itemAt(int pos)
          The method itemAt
 SequenceIterator iterate()
          Returns an iterator over all items in the sequence.
 NodeSetIterator iterator()
          The method iterator
 NodeProxy parentWithChild(DocumentImpl doc, NodeId nodeId, boolean restrictToDirectParent, boolean includeSelf)
          The method parentWithChild
 NodeProxy parentWithChild(NodeProxy proxy, boolean restrictToDirectParent, boolean includeSelf, int level)
          The method parentWithChild
 boolean preferTreeTraversal()
          The method preferTreeTraversal
 void realize()
          The method realize
 void remove(NodeProxy node)
          The method remove
 void set(int position, DocumentImpl doc, long nodeId)
          The method set
 void setContextId(int contextId)
          The method setContextId
 void setInPredicate(boolean predicate)
          The method setInPredicate
 void setSelfIsContext()
          The method setSelfIsContext
 String toString()
          The method toString
 NodeSet union(NodeSet other)
          The method union
 SequenceIterator unorderedIterator()
          Returns an iterator over all items in the sequence.
 
Methods inherited from class org.exist.dom.AbstractNodeSet
add, add, addAll, clearContext, deepIntersection, directSelectAttribute, except, getAncestors, getContextNodes, getIndexType, getItemType, getParents, getProcessInReverseOrder, getSizeHint, getState, hasChanged, hasMixedContent, hasTextIndex, isCached, isPersistentSet, nodeMoved, removeDuplicates, selectAncestorDescendant, selectAncestors, selectFollowing, selectFollowingSiblings, selectParentChild, selectParentChild, selectPreceding, selectPrecedingSiblings, setIsCached, setProcessInReverseOrder, toNodeSet
 
Methods inherited from class org.exist.xquery.value.AbstractSequence
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, isCacheable, setSelfAsContext, toJavaObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.exist.xquery.value.Sequence
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, isCacheable, setSelfAsContext, toJavaObject
 

Constructor Detail

VirtualNodeSet

public VirtualNodeSet(DBBroker broker,
                      int axis,
                      NodeTest test,
                      int contextId,
                      NodeSet context)
Creates a new VirtualNodeSet instance.

Parameters:
axis - an int value
test - a NodeTest value
contextId - an int value
context - a NodeSet value
Method Detail

contains

public boolean contains(NodeProxy p)
The method contains

Specified by:
contains in interface NodeSet
Specified by:
contains in class AbstractNodeSet
Parameters:
p - a NodeProxy value
Returns:
a boolean value

setInPredicate

public void setInPredicate(boolean predicate)
The method setInPredicate

Parameters:
predicate - a boolean value

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 NodeSet
Specified by:
getDocumentSet in interface Sequence
Overrides:
getDocumentSet in class AbstractNodeSet

getCollectionIterator

public Iterator getCollectionIterator()
The method getCollectionIterator

Specified by:
getCollectionIterator in interface NodeSet
Specified by:
getCollectionIterator in interface Sequence
Overrides:
getCollectionIterator in class AbstractNodeSet
Returns:
an Iterator value

parentWithChild

public NodeProxy parentWithChild(NodeProxy proxy,
                                 boolean restrictToDirectParent,
                                 boolean includeSelf,
                                 int level)
The method parentWithChild

Specified by:
parentWithChild in interface NodeSet
Overrides:
parentWithChild in class AbstractNodeSet
Parameters:
proxy - a NodeProxy value
restrictToDirectParent - a boolean value
includeSelf - a boolean value
level - an int value
Returns:
a NodeProxy value

parentWithChild

public NodeProxy parentWithChild(DocumentImpl doc,
                                 NodeId nodeId,
                                 boolean restrictToDirectParent,
                                 boolean includeSelf)
The method parentWithChild

Specified by:
parentWithChild in interface NodeSet
Overrides:
parentWithChild in class AbstractNodeSet
Parameters:
doc - a DocumentImpl value
nodeId - a NodeId value
restrictToDirectParent - a boolean value
includeSelf - a boolean value
Returns:
a NodeProxy value

realize

public final void realize()
The method realize


preferTreeTraversal

public boolean preferTreeTraversal()
The method preferTreeTraversal

Returns:
a boolean value

setSelfIsContext

public void setSelfIsContext()
The method setSelfIsContext


setContextId

public void setContextId(int contextId)
The method setContextId

Parameters:
contextId - an int value

hasIndex

public boolean hasIndex()

isEmpty

public boolean isEmpty()
The method isEmpty

Specified by:
isEmpty in interface Sequence
Specified by:
isEmpty in class AbstractSequence
Returns:
a boolean value

hasOne

public boolean hasOne()
The method hasOne

Specified by:
hasOne in interface Sequence
Specified by:
hasOne in class AbstractSequence
Returns:
a boolean value

hasMany

public boolean hasMany()
The method hasMany

Specified by:
hasMany in interface Sequence
Overrides:
hasMany in class AbstractSequence
Returns:
a boolean value

add

public void add(DocumentImpl doc,
                long nodeId)
The method add

Parameters:
doc - a DocumentImpl value
nodeId - a long value

add

public void add(Node node)
The method add

Parameters:
node - a Node value

add

public void add(NodeProxy proxy)
The method add

Specified by:
add in interface NodeSet
Specified by:
add in class AbstractNodeSet
Parameters:
proxy - a NodeProxy value

addAll

public void addAll(NodeList other)
The method addAll

Parameters:
other - a NodeList value

addAll

public void addAll(NodeSet other)
The method addAll

Specified by:
addAll in interface NodeSet
Specified by:
addAll in class AbstractNodeSet
Parameters:
other - a NodeSet value

set

public void set(int position,
                DocumentImpl doc,
                long nodeId)
The method set

Parameters:
position - an int value
doc - a DocumentImpl value
nodeId - a long value

remove

public void remove(NodeProxy node)
The method remove

Parameters:
node - a NodeProxy value

getLength

public int getLength()
The method getLength

Specified by:
getLength in interface NodeList
Specified by:
getLength in class AbstractNodeSet
Returns:
an int value

getItemCount

public int getItemCount()
The method getItemCount

Specified by:
getItemCount in interface Sequence
Specified by:
getItemCount in class AbstractSequence
Returns:
an int value

item

public Node item(int pos)
The method item

Specified by:
item in interface NodeList
Specified by:
item in class AbstractNodeSet
Parameters:
pos - an int value
Returns:
a Node value

get

public NodeProxy get(int pos)
The method get

Specified by:
get in interface NodeSet
Specified by:
get in class AbstractNodeSet
Parameters:
pos - an int value
Returns:
a NodeProxy value

itemAt

public Item itemAt(int pos)
The method itemAt

Specified by:
itemAt in interface Sequence
Specified by:
itemAt in class AbstractSequence
Parameters:
pos - an int value
Returns:
an Item value

get

public NodeProxy get(DocumentImpl doc,
                     NodeId nodeId)
The method get

Parameters:
doc - a DocumentImpl value
nodeId - a NodeId value
Returns:
a NodeProxy value

get

public NodeProxy get(NodeProxy proxy)
The method get

Specified by:
get in interface NodeSet
Specified by:
get in class AbstractNodeSet
Parameters:
proxy - a NodeProxy value
Returns:
a NodeProxy value

iterator

public NodeSetIterator iterator()
The method iterator

Specified by:
iterator in interface NodeSet
Specified by:
iterator in class AbstractNodeSet
Returns:
a NodeSetIterator value

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
Specified by:
iterate in class AbstractNodeSet
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
Specified by:
unorderedIterator in class AbstractNodeSet

intersection

public NodeSet intersection(NodeSet other)
The method intersection

Specified by:
intersection in interface NodeSet
Overrides:
intersection in class AbstractNodeSet
Parameters:
other - a NodeSet value
Returns:
a NodeSet value

union

public NodeSet union(NodeSet other)
The method union

Specified by:
union in interface NodeSet
Overrides:
union in class AbstractNodeSet
Parameters:
other - a NodeSet value
Returns:
a NodeSet value

filterDocuments

public NodeSet filterDocuments(NodeSet otherSet)
The method filterDocuments

Specified by:
filterDocuments in interface NodeSet
Overrides:
filterDocuments in class AbstractNodeSet
Parameters:
otherSet - a NodeSet value
Returns:
a NodeSet value

clearContext

public void clearContext()
The method clearContext


toString

public String toString()
The method toString

Overrides:
toString in class AbstractNodeSet
Returns:
a String value


Copyright (C) Wolfgang Meier. All rights reserved.