org.exist.dom
Class NodeSet

java.lang.Object
  extended byorg.exist.dom.NodeSet
All Implemented Interfaces:
org.w3c.dom.NodeList
Direct Known Subclasses:
ArraySet, EmptyNodeSet, NodeIDSet, SingleNodeSet, SortedNodeSet, VirtualNodeSet

public abstract class NodeSet
extends java.lang.Object
implements org.w3c.dom.NodeList

Base class for all node set implementations returned by most xpath expressions. It implements NodeList plus some additional methods needed by the xpath engine. There are three classes extending NodeSet: NodeIDSet, ArraySet and VirtualNodeSet. Depending on the context each of these implementations has its advantages and drawbacks. ArraySet uses a sorted array and binary search, while NodeIDSet is based on a HashSet. VirtualNodeSet is specifically used for steps like descendant::* etc..


Field Summary
static int ANCESTOR
           
static int DESCENDANT
           
static NodeSet EMPTY_SET
           
static int FOLLOWING
           
static int PRECEDING
           
 
Constructor Summary
NodeSet()
           
 
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)
           
abstract  void addAll(NodeSet other)
           
 boolean contains(DocumentImpl doc)
           
abstract  boolean contains(DocumentImpl doc, long nodeId)
           
abstract  boolean contains(NodeProxy proxy)
           
abstract  NodeProxy get(DocumentImpl doc, long nodeId)
           
abstract  NodeProxy get(int pos)
           
abstract  NodeProxy get(NodeProxy p)
           
 NodeSet getAncestors(NodeSet al, boolean includeSelf, boolean rememberContext)
          For a given set of potential ancestor nodes, get the descendants in this node set
 ArraySet getChildren(NodeSet al, int mode)
           
 ArraySet getChildren(NodeSet al, int mode, boolean rememberContext)
           
 NodeSet getContextNodes(NodeSet contextNodes, boolean rememberContext)
           
 NodeSet getDescendants(NodeSet al, int mode)
           
 NodeSet getDescendants(NodeSet al, int mode, boolean includeSelf)
           
 NodeSet getDescendants(NodeSet al, int mode, boolean includeSelf, boolean rememberContext)
          For a given set of potential ancestor nodes, get the descendants in this node set
abstract  int getLength()
           
 NodeSet getParents()
           
 NodeSet getRange(DocumentImpl doc, long lower, long upper)
           
 NodeSet getSiblings(NodeSet siblings, int mode)
          Select all nodes from the passed node set, which are preceding or following siblings of the nodes in this set.
 boolean hasIndex()
           
 NodeSet intersection(NodeSet other)
           
abstract  org.w3c.dom.Node item(int pos)
           
abstract  java.util.Iterator iterator()
           
 NodeProxy nodeHasParent(DocumentImpl doc, long gid, boolean directParent, boolean includeSelf)
           
 NodeProxy nodeHasParent(DocumentImpl doc, long gid, boolean directParent, boolean includeSelf, int level)
          Check if node has a parent contained in this node set.
 NodeProxy nodeHasParent(NodeProxy p, boolean directParent)
           
 NodeProxy nodeHasParent(NodeProxy p, 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)
           
protected  NodeProxy parentWithChild(DocumentImpl doc, long gid, boolean directParent, boolean includeSelf, int level)
          Search for a node contained in this node set, which is an ancestor of the argument node.
 NodeProxy parentWithChild(NodeProxy proxy, boolean directParent, boolean includeSelf)
           
 void remove(NodeProxy node)
           
 NodeSet union(NodeSet other)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANCESTOR

public static final int ANCESTOR
See Also:
Constant Field Values

DESCENDANT

public static final int DESCENDANT
See Also:
Constant Field Values

PRECEDING

public static final int PRECEDING
See Also:
Constant Field Values

FOLLOWING

public static final int FOLLOWING
See Also:
Constant Field Values

EMPTY_SET

public static NodeSet EMPTY_SET
Constructor Detail

NodeSet

public NodeSet()
Method Detail

iterator

public abstract java.util.Iterator iterator()

contains

public abstract boolean contains(DocumentImpl doc,
                                 long nodeId)

contains

public abstract boolean contains(NodeProxy proxy)

contains

public boolean contains(DocumentImpl doc)

add

public void add(DocumentImpl doc,
                long nodeId)

add

public void add(org.w3c.dom.Node node)

add

public void add(NodeProxy proxy)

addAll

public void addAll(org.w3c.dom.NodeList other)

addAll

public abstract void addAll(NodeSet other)

remove

public void remove(NodeProxy node)

getLength

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

item

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

get

public abstract NodeProxy get(int pos)

get

public abstract NodeProxy get(NodeProxy p)

get

public abstract NodeProxy get(DocumentImpl doc,
                              long nodeId)

nodeHasParent

public NodeProxy nodeHasParent(NodeProxy p,
                               boolean directParent)

nodeHasParent

public NodeProxy nodeHasParent(NodeProxy p,
                               boolean directParent,
                               boolean includeSelf)

nodeHasParent

public NodeProxy nodeHasParent(DocumentImpl doc,
                               long gid,
                               boolean directParent,
                               boolean includeSelf)

nodeHasParent

public NodeProxy nodeHasParent(DocumentImpl doc,
                               long gid,
                               boolean directParent,
                               boolean includeSelf,
                               int level)
Check if node has a parent contained in this node set. If directParent is true, only immediate ancestors are considered. Otherwise the method will call itself recursively for the node's parents. If includeSelf is true, the method returns also true if the node itself is contained in the node set.


getChildren

public ArraySet getChildren(NodeSet al,
                            int mode)

getChildren

public ArraySet getChildren(NodeSet al,
                            int mode,
                            boolean rememberContext)

getDescendants

public NodeSet getDescendants(NodeSet al,
                              int mode)

getDescendants

public NodeSet getDescendants(NodeSet al,
                              int mode,
                              boolean includeSelf)

getDescendants

public NodeSet getDescendants(NodeSet al,
                              int mode,
                              boolean includeSelf,
                              boolean rememberContext)
For a given set of potential ancestor nodes, get the descendants in this node set

Parameters:
al - node set containing potential ancestors
mode - determines if either the ancestor or the descendant nodes should be returned. Possible values are ANCESTOR or DESCENDANT.
Returns:

getAncestors

public NodeSet getAncestors(NodeSet al,
                            boolean includeSelf,
                            boolean rememberContext)
For a given set of potential ancestor nodes, get the descendants in this node set

Parameters:
al - node set containing potential ancestors
Returns:

getSiblings

public NodeSet getSiblings(NodeSet siblings,
                           int mode)
Select all nodes from the passed node set, which are preceding or following siblings of the nodes in this set.

Parameters:
siblings - a node set containing potential siblings
mode - either FOLLOWING or PRECEDING
Returns:

parentWithChild

public 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. If directParent is true, only immediate ancestors are considered.


parentWithChild

public NodeProxy parentWithChild(DocumentImpl doc,
                                 long gid,
                                 boolean directParent,
                                 boolean includeSelf)

parentWithChild

protected NodeProxy parentWithChild(DocumentImpl doc,
                                    long gid,
                                    boolean directParent,
                                    boolean includeSelf,
                                    int level)
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. If includeSelf is true, the method returns true even if the node itself is contained in the node set.


parentWithChild

public NodeProxy parentWithChild(NodeProxy proxy,
                                 boolean directParent,
                                 boolean includeSelf)

getParents

public NodeSet getParents()

hasIndex

public boolean hasIndex()

getRange

public NodeSet getRange(DocumentImpl doc,
                        long lower,
                        long upper)

intersection

public NodeSet intersection(NodeSet other)

union

public NodeSet union(NodeSet other)

getContextNodes

public NodeSet getContextNodes(NodeSet contextNodes,
                               boolean rememberContext)


Copyright (C) Wolfgang Meier. All rights reserved.