Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xpath
Class NodeSet

    java.lang.Object
      |
      +--org.apache.xalan.utils.NodeVector
            |
            +--org.apache.xpath.NodeSet

public class NodeSet
extends NodeVector
implements NodeList, NodeIterator, java.lang.Cloneable, ContextNodeList

**For advanced use only** The NodeSet class can act as either a NodeVector, NodeList, or NodeIterator. However, in order for it to act as a NodeVector or NodeList, it's required that setShouldCacheNodes(true) be called before the first nextNode() is called, in order that nodes can be added as they are fetched. Derived classes that implement iterators must override runTo(int index), in order that they may run the iteration to the given index.

See Also:
  Serialized Form

Constructor Summary
`NodeSet()` **For advanced use only** Create an empty nodelist.
`NodeSet(int blocksize)` **For advanced use only** Create an empty nodelist.
`NodeSet(Node node)` **For advanced use only** Create a NodeSet, and copy the members of the given nodelist into it.
`NodeSet(NodeIterator ni)` **For advanced use only** Create a NodeSet, and copy the members of the given nodelist into it.
`NodeSet(NodeList nodelist)` **For advanced use only** Create a NodeSet, and copy the members of the given nodelist into it.
`NodeSet(NodeSet nodelist)` **For advanced use only** Create a NodeSet, and copy the members of the given NodeSet into it.

Method Summary
`void` | `addElement(Node value)` **For advanced use only** Append a Node onto the vector.
`void` | `addNode(Node n)` **For advanced use only** Add a node.
`int` | `addNodeInDocOrder(Node node, boolean test, XPathContext support)` **For advanced use only** Add the node into a vector of nodes where it should occur in document order.
`int` | `addNodeInDocOrder(Node node, XPathContext support)` **For advanced use only** Add the node into a vector of nodes where it should occur in document order.
`void` | `addNodes(NodeIterator iterator)` **For advanced use only** Copy NodeList members into this nodelist, adding in document order.
`void` | `addNodes(NodeList nodelist)` **For advanced use only** Copy NodeList members into this nodelist, adding in document order.
`void` | `addNodes(NodeSet ns)` **For advanced use only** Copy NodeList members into this nodelist, adding in document order.
`void` | `addNodesInDocOrder(NodeIterator iterator, XPathContext support)` **For advanced use only** Copy NodeList members into this nodelist, adding in document order.
`void` | `addNodesInDocOrder(NodeList nodelist, XPathContext support)` **For advanced use only** Copy NodeList members into this nodelist, adding in document order.
`void` | `appendNodes(NodeVector nodes)` **For advanced use only** Append the nodes to the list.
`java.lang.Object` | `clone()` **For advanced use only** Get a cloned LocPathIterator.
`NodeIterator` | `cloneWithReset()` **For advanced use only** Get a cloned Iterator.
`boolean` | `contains(Node s)` **For advanced use only** Tell if the table contains the given node.
`void` | `detach()` **For advanced use only** Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.
`Node` | `elementAt(int i)` **For advanced use only** Get the nth element.
`Node` | `getCurrentNode()` **For advanced use only** Return the last fetched node.
`int` | `getCurrentPos()` **For advanced use only** Get the current position, which is one less than the next nextNode() call will retreave.
`boolean` | `getExpandEntityReferences()` **For advanced use only** The value of this flag determines whether the children of entity reference nodes are visible to the iterator.
`NodeFilter` | `getFilter()` **For advanced use only** The filter used to screen nodes.
`int` | `getLength()` **For advanced use only** The number of nodes in the list.
`Node` | `getRoot()` **For advanced use only** The root node of the Iterator, as specified when it was created.
`boolean` | `getShouldCacheNodes()` **For advanced use only**
`int` | `getWhatToShow()` **For advanced use only** This attribute determines which node types are presented via the iterator.
`int` | `indexOf(Node elem)` **For advanced use only** Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
`int` | `indexOf(Node elem, int index)` **For advanced use only** Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
`void` | `insertElementAt(Node value, int at)` **For advanced use only** Inserts the specified node in this vector at the specified index.
`void` | `insertNode(Node n, int pos)` **For advanced use only** Insert a node at a given position.
`boolean` | `isFresh()` **For advanced use only** Tells if this NodeSet is "fresh", in other words, if the first nextNode() that is called will return the first node in the set.
`Node` | `item(int index)` **For advanced use only** Returns the `index`th item in the collection.
`Node` | `nextNode()` **For advanced use only** Returns the next node in the set and advances the position of the iterator in the set.
`Node` | `previousNode()` **For advanced use only** Returns the previous node in the set and moves the position of the iterator backwards in the set.
`void` | `removeAllElements()` **For advanced use only** Inserts the specified node in this vector at the specified index.
`boolean` | `removeElement(Node s)` **For advanced use only** Removes the first occurrence of the argument from this vector.
`void` | `removeElementAt(int i)` **For advanced use only** Deletes the component at the specified index.
`void` | `removeNode(Node n)` **For advanced use only** Remove a node.
`void` | `reset()` **For advanced use only** Reset the iterator.
`void` | `runTo(int index)` **For advanced use only** If an index is requested, NodeSet will call this method to run the iterator to the index.
`void` | `setCurrentPos(int i)` **For advanced use only** Set the current position in the node set.
`void` | `setElementAt(Node node, int index)` **For advanced use only** Sets the component at the specified index of this vector to be the specified object.
`void` | `setShouldCacheNodes(boolean b)` **For advanced use only** If setShouldCacheNodes(true) is called, then nodes will be cached.
`int` | `size()` **For advanced use only** Get the length of the list.

Methods inherited from class org.apache.xalan.utils.NodeVector
`peepOrNull, peepTail, peepTailSub1, pop, popPair, popQuick, push, pushPair, setTail, setTailSub1`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### NodeSet

    public NodeSet()

  **For advanced use only** Create an empty nodelist.

### NodeSet

    public NodeSet(int blocksize)

  **For advanced use only** Create an empty nodelist.

### NodeSet

    public NodeSet(NodeList nodelist)

  **For advanced use only** Create a NodeSet, and copy the members of the given nodelist into it.

### NodeSet

    public NodeSet(NodeSet nodelist)

  **For advanced use only** Create a NodeSet, and copy the members of the given NodeSet into it.

### NodeSet

    public NodeSet(NodeIterator ni)

  **For advanced use only** Create a NodeSet, and copy the members of the given nodelist into it.

### NodeSet

    public NodeSet(Node node)

  **For advanced use only** Create a NodeSet, and copy the members of the given nodelist into it.

Method Detail

### getRoot

    public Node getRoot()

  **For advanced use only** The root node of the Iterator, as specified when it was created.
  Specified by:
    getRoot in interface NodeIterator

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  **For advanced use only** Get a cloned LocPathIterator.
  Specified by:
    clone in interface ContextNodeList
  Overrides:
    clone in class NodeVector

### cloneWithReset

    public NodeIterator cloneWithReset()
                                throws java.lang.CloneNotSupportedException

  **For advanced use only** Get a cloned Iterator.
  Specified by:
    cloneWithReset in interface ContextNodeList

### reset

    public void reset()

  **For advanced use only** Reset the iterator.
  Specified by:
    reset in interface ContextNodeList

### getWhatToShow

    public int getWhatToShow()

  **For advanced use only** This attribute determines which node types are presented via the iterator. The available set of constants is defined in the `NodeFilter` interface.
  Specified by:
    getWhatToShow in interface NodeIterator

### getFilter

    public NodeFilter getFilter()

  **For advanced use only** The filter used to screen nodes.
  Specified by:
    getFilter in interface NodeIterator

### getExpandEntityReferences

    public boolean getExpandEntityReferences()

  **For advanced use only** The value of this flag determines whether the children of entity reference nodes are visible to the iterator. If false, they will be skipped over.
  To produce a view of the document that has entity references expanded and does not expose the entity reference node itself, use the whatToShow flags to hide the entity reference node and set expandEntityReferences to true when creating the iterator. To produce a view of the document that has entity reference nodes but no entity expansion, use the whatToShow flags to show the entity reference node and set expandEntityReferences to false.
  Specified by:
    getExpandEntityReferences in interface NodeIterator

### nextNode

    public Node nextNode()
                  throws DOMException

  **For advanced use only** Returns the next node in the set and advances the position of the iterator in the set. After a NodeIterator is created, the first call to nextNode() returns the first node in the set.
  Specified by:
    nextNode in interface NodeIterator
  Returns:
    The next `Node` in the set being iterated over, or `null` if there are no more members in that set.
  Throws:
    DOMException - INVALID_STATE_ERR: Raised if this method is called after the `detach` method was invoked.

### previousNode

    public Node previousNode()
                      throws DOMException

  **For advanced use only** Returns the previous node in the set and moves the position of the iterator backwards in the set.
  Specified by:
    previousNode in interface NodeIterator
  Returns:
    The previous `Node` in the set being iterated over, or`null` if there are no more members in that set.
  Throws:
    DOMException - INVALID_STATE_ERR: Raised if this method is called after the `detach` method was invoked.

### detach

    public void detach()

  **For advanced use only** Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. After`detach` has been invoked, calls to `nextNode` or`previousNode` will raise the exception INVALID_STATE_ERR.
  Specified by:
    detach in interface NodeIterator

### isFresh

    public boolean isFresh()

  **For advanced use only** Tells if this NodeSet is "fresh", in other words, if the first nextNode() that is called will return the first node in the set.
  Specified by:
    isFresh in interface ContextNodeList

### runTo

    public void runTo(int index)

  **For advanced use only** If an index is requested, NodeSet will call this method to run the iterator to the index. By default this sets m_next to the index. If the index argument is -1, this signals that the iterator should be run to the end.
  Specified by:
    runTo in interface ContextNodeList

### item

    public Node item(int index)

  **For advanced use only** Returns the `index`th item in the collection. If `index` is greater than or equal to the number of nodes in the list, this returns `null`.
  Specified by:
    item in interface NodeList
  Parameters:
    `index` - Index into the collection.
  Returns:
    The node at the `index`th position in the `NodeList`, or `null` if that is not a valid index.

### getLength

    public int getLength()

  **For advanced use only** The number of nodes in the list. The range of valid child node indices is 0 to `length-1` inclusive.
  Specified by:
    getLength in interface NodeList

### addNode

    public void addNode(Node n)

  **For advanced use only** Add a node.

### insertNode

    public void insertNode(Node n,
                           int pos)

  **For advanced use only** Insert a node at a given position.

### removeNode

    public void removeNode(Node n)

  **For advanced use only** Remove a node.

### addNodes

    public void addNodes(NodeList nodelist)

  **For advanced use only** Copy NodeList members into this nodelist, adding in document order. If a node is null, don't add it.

### addNodes

    public void addNodes(NodeSet ns)

  **For advanced use only** Copy NodeList members into this nodelist, adding in document order. If a node is null, don't add it.

### addNodes

    public void addNodes(NodeIterator iterator)

  **For advanced use only** Copy NodeList members into this nodelist, adding in document order. If a node is null, don't add it.

### addNodesInDocOrder

    public void addNodesInDocOrder(NodeList nodelist,
                                   XPathContext support)

  **For advanced use only** Copy NodeList members into this nodelist, adding in document order. If a node is null, don't add it.

### addNodesInDocOrder

    public void addNodesInDocOrder(NodeIterator iterator,
                                   XPathContext support)

  **For advanced use only** Copy NodeList members into this nodelist, adding in document order. If a node is null, don't add it.

### addNodeInDocOrder

    public int addNodeInDocOrder(Node node,
                                 boolean test,
                                 XPathContext support)

  **For advanced use only** Add the node into a vector of nodes where it should occur in document order.
  Parameters:
    `v` - Vector of nodes, presumably containing Nodes
    `obj` - Node object.
    `test` - true if we should test for doc order
  Returns:
    insertIndex.

### addNodeInDocOrder

    public int addNodeInDocOrder(Node node,
                                 XPathContext support)

  **For advanced use only** Add the node into a vector of nodes where it should occur in document order.
  Parameters:
    `v` - Vector of nodes, presumably containing Nodes
    `obj` - Node object.

### size

    public int size()

  **For advanced use only** Get the length of the list.
  Specified by:
    size in interface ContextNodeList
  Overrides:
    size in class NodeVector

### addElement

    public void addElement(Node value)

  **For advanced use only** Append a Node onto the vector.
  Overrides:
    addElement in class NodeVector

### insertElementAt

    public void insertElementAt(Node value,
                                int at)

  **For advanced use only** Inserts the specified node in this vector at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.
  Overrides:
    insertElementAt in class NodeVector

### appendNodes

    public void appendNodes(NodeVector nodes)

  **For advanced use only** Append the nodes to the list.
  Overrides:
    appendNodes in class NodeVector

### removeAllElements

    public void removeAllElements()

  **For advanced use only** Inserts the specified node in this vector at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.
  Overrides:
    removeAllElements in class NodeVector

### removeElement

    public boolean removeElement(Node s)

  **For advanced use only** Removes the first occurrence of the argument from this vector. If the object is found in this vector, each component in the vector with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously.
  Overrides:
    removeElement in class NodeVector

### removeElementAt

    public void removeElementAt(int i)

  **For advanced use only** Deletes the component at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously.
  Overrides:
    removeElementAt in class NodeVector

### setElementAt

    public void setElementAt(Node node,
                             int index)

  **For advanced use only** Sets the component at the specified index of this vector to be the specified object. The previous component at that position is discarded. The index must be a value greater than or equal to 0 and less than the current size of the vector.
  Overrides:
    setElementAt in class NodeVector

### elementAt

    public Node elementAt(int i)

  **For advanced use only** Get the nth element.
  Overrides:
    elementAt in class NodeVector

### contains

    public boolean contains(Node s)

  **For advanced use only** Tell if the table contains the given node.
  Overrides:
    contains in class NodeVector

### indexOf

    public int indexOf(Node elem,
                       int index)

  **For advanced use only** Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
  Returns:
    the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.
  Overrides:
    indexOf in class NodeVector

### indexOf

    public int indexOf(Node elem)

  **For advanced use only** Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
  Returns:
    the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.
  Overrides:
    indexOf in class NodeVector

### getCurrentPos

    public int getCurrentPos()

  **For advanced use only** Get the current position, which is one less than the next nextNode() call will retreave. i.e. if you call getCurrentPos() and the return is 0, the next fetch will take place at index 1.
  Specified by:
    getCurrentPos in interface ContextNodeList

### setCurrentPos

    public void setCurrentPos(int i)

  **For advanced use only** Set the current position in the node set.
  Specified by:
    setCurrentPos in interface ContextNodeList
  Parameters:
    `i` - Must be a valid index.

### getCurrentNode

    public Node getCurrentNode()

  **For advanced use only** Return the last fetched node. Needed to support the UnionPathIterator.
  Specified by:
    getCurrentNode in interface ContextNodeList

### getShouldCacheNodes

    public boolean getShouldCacheNodes()

### setShouldCacheNodes

    public void setShouldCacheNodes(boolean b)

  **For advanced use only** If setShouldCacheNodes(true) is called, then nodes will be cached. They are not cached by default.
  Specified by:
    setShouldCacheNodes in interface ContextNodeList

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000 Apache XML Project. All Rights Reserved.