org.exist.dom
Class VirtualNodeSet

java.lang.Object
  extended byorg.exist.dom.NodeSet
      extended byorg.exist.dom.VirtualNodeSet
All Implemented Interfaces:
org.w3c.dom.NodeList

public class VirtualNodeSet
extends NodeSet

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
protected  int axis
           
protected  NodeSet context
           
protected  boolean inPredicate
           
protected  NodeSet realSet
           
protected  TypeTest test
           
protected  boolean useSelfAsContext
           
 
Fields inherited from class org.exist.dom.NodeSet
ANCESTOR, DESCENDANT, EMPTY_SET, FOLLOWING, PRECEDING
 
Constructor Summary
VirtualNodeSet(int axis, TypeTest test, NodeSet context)
           
 
Method Summary
 void add(DocumentImpl doc, long nodeId)
           
 void add(org.w3c.dom.Node node)
           
 void add(NodeProxy proxy)
           
 void addAll(org.w3c.dom.NodeList other)
           
 void addAll(NodeSet other)
           
 boolean contains(DocumentImpl doc, long nodeId)
           
 boolean contains(NodeProxy p)
           
 NodeProxy get(DocumentImpl doc, long gid)
           
 NodeProxy get(int pos)
           
 NodeProxy get(NodeProxy proxy)
           
protected  NodeProxy getFirstParent(NodeProxy node, long gid, boolean includeSelf)
           
protected  NodeProxy getFirstParent(NodeProxy node, NodeProxy first, boolean includeSelf, boolean directParent, int recursions)
           
protected  NodeProxy getFirstParent(NodeProxy node, NodeProxy first, boolean includeSelf, int recursions)
           
 int getLast()
           
 int getLength()
           
 boolean hasValues()
           
 NodeSet intersection(NodeSet other)
           
 org.w3c.dom.Node item(int pos)
           
 java.util.Iterator iterator()
           
 NodeProxy nodeHasParent(DocumentImpl doc, long gid, boolean directParent, boolean includeSelf)
           
 NodeProxy nodeHasParent(NodeProxy node, boolean directParent, boolean includeSelf)
           
 NodeProxy parentWithChild(DocumentImpl doc, long gid, boolean directParent)
          Search for a node contained in this node set, which is an ancestor of the argument node.
 NodeProxy parentWithChild(DocumentImpl doc, long gid, boolean directParent, boolean includeSelf)
           
 NodeProxy parentWithChild(NodeProxy proxy, boolean directParent, boolean includeSelf)
           
 void remove(NodeProxy node)
           
 void set(int position, DocumentImpl doc, long nodeId)
           
 void setInPredicate(boolean predicate)
           
 void setSelfIsContext()
           
 NodeSet union(NodeSet other)
           
 
Methods inherited from class org.exist.dom.NodeSet
contains, getAncestors, getChildren, getChildren, getContextNodes, getDescendants, getDescendants, getDescendants, getParents, getRange, getSiblings, hasIndex, nodeHasParent, nodeHasParent, parentWithChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

axis

protected int axis

test

protected TypeTest test

context

protected NodeSet context

realSet

protected NodeSet realSet

inPredicate

protected boolean inPredicate

useSelfAsContext

protected boolean useSelfAsContext
Constructor Detail

VirtualNodeSet

public VirtualNodeSet(int axis,
                      TypeTest test,
                      NodeSet context)
Method Detail

contains

public boolean contains(DocumentImpl doc,
                        long nodeId)
Specified by:
contains in class NodeSet

contains

public boolean contains(NodeProxy p)
Specified by:
contains in class NodeSet

setInPredicate

public void setInPredicate(boolean predicate)

getFirstParent

protected NodeProxy getFirstParent(NodeProxy node,
                                   long gid,
                                   boolean includeSelf)

getFirstParent

protected NodeProxy getFirstParent(NodeProxy node,
                                   NodeProxy first,
                                   boolean includeSelf,
                                   int recursions)

getFirstParent

protected NodeProxy getFirstParent(NodeProxy node,
                                   NodeProxy first,
                                   boolean includeSelf,
                                   boolean directParent,
                                   int recursions)

nodeHasParent

public NodeProxy nodeHasParent(DocumentImpl doc,
                               long gid,
                               boolean directParent,
                               boolean includeSelf)
Overrides:
nodeHasParent in class NodeSet

nodeHasParent

public NodeProxy nodeHasParent(NodeProxy node,
                               boolean directParent,
                               boolean includeSelf)
Overrides:
nodeHasParent in class NodeSet

parentWithChild

public NodeProxy parentWithChild(DocumentImpl doc,
                                 long gid,
                                 boolean directParent)
Description copied from class: NodeSet
Search for a node contained in this node set, which is an ancestor of the argument node. If directParent is true, only immediate ancestors are considered.

Overrides:
parentWithChild in class NodeSet

parentWithChild

public NodeProxy parentWithChild(DocumentImpl doc,
                                 long gid,
                                 boolean directParent,
                                 boolean includeSelf)
Overrides:
parentWithChild in class NodeSet

parentWithChild

public NodeProxy parentWithChild(NodeProxy proxy,
                                 boolean directParent,
                                 boolean includeSelf)
Overrides:
parentWithChild in class NodeSet

setSelfIsContext

public void setSelfIsContext()

add

public void add(DocumentImpl doc,
                long nodeId)
Overrides:
add in class NodeSet

add

public void add(org.w3c.dom.Node node)
Overrides:
add in class NodeSet

add

public void add(NodeProxy proxy)
Overrides:
add in class NodeSet

addAll

public void addAll(org.w3c.dom.NodeList other)
Overrides:
addAll in class NodeSet

addAll

public void addAll(NodeSet other)
Specified by:
addAll in class NodeSet

set

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

remove

public void remove(NodeProxy node)
Overrides:
remove in class NodeSet

getLength

public int getLength()
Specified by:
getLength in interface org.w3c.dom.NodeList
Specified by:
getLength in class NodeSet

item

public org.w3c.dom.Node item(int pos)
Specified by:
item in interface org.w3c.dom.NodeList
Specified by:
item in class NodeSet

get

public NodeProxy get(int pos)
Specified by:
get in class NodeSet

get

public NodeProxy get(DocumentImpl doc,
                     long gid)
Specified by:
get in class NodeSet

get

public NodeProxy get(NodeProxy proxy)
Specified by:
get in class NodeSet

iterator

public java.util.Iterator iterator()
Specified by:
iterator in class NodeSet

intersection

public NodeSet intersection(NodeSet other)
Overrides:
intersection in class NodeSet

union

public NodeSet union(NodeSet other)
Overrides:
union in class NodeSet

hasValues

public boolean hasValues()

getLast

public int getLast()


Copyright (C) Wolfgang Meier. All rights reserved.