Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.xml.utils.NodeVector
org.apache.xpath.NodeSetDTM
Fields inherited from interface org.apache.xml.dtm.DTMIterator | |
FILTER_ACCEPT , FILTER_REJECT , FILTER_SKIP |
Constructor Summary | |
| |
| |
| |
| |
| |
| |
|
Method Summary | |
void |
|
void |
|
int |
|
int |
|
void |
|
void |
|
void |
|
void |
|
Object |
|
DTMIterator |
|
boolean |
|
void |
|
int |
|
int |
|
int |
|
int |
|
DTM |
|
DTMManager |
|
boolean |
|
DTMFilter |
|
int |
|
int |
|
int |
|
boolean |
|
int |
|
int |
|
int |
|
void |
|
void |
|
boolean |
|
boolean |
|
boolean |
|
int |
|
int |
|
int |
|
void |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
int |
|
Methods inherited from class org.apache.xml.utils.NodeVector | |
RemoveAllNoClear , addElement , appendNodes , clone , contains , elementAt , indexOf , indexOf , insertElementAt , insertInOrder , peepOrNull , peepTail , peepTailSub1 , pop , popAndTop , popPair , popQuick , push , pushPair , removeAllElements , removeElement , removeElementAt , setElementAt , setTail , setTailSub1 , size , sort , sort |
public NodeSetDTM(NodeIterator iterator, XPathContext xctxt)
Create a NodeSetDTM, and copy the members of the given DTMIterator into it.
- Parameters:
iterator
- Iterator which yields Nodes to be made members of the new set.
public NodeSetDTM(NodeList nodeList, XPathContext xctxt)
Create a NodeSetDTM, and copy the members of the given DTMIterator into it.
public NodeSetDTM(int blocksize, int dummy, DTMManager dtmManager)
Create an empty, using the given block size.
- Parameters:
blocksize
- Size of blocks to allocatedummy
- pass zero for right now...
public NodeSetDTM(int node, DTMManager dtmManager)
Create a NodeSetDTM which contains the given Node.
- Parameters:
node
- Single node to be added to the new set.
public NodeSetDTM(DTMIterator ni)
Create a NodeSetDTM, and copy the members of the given DTMIterator into it.
- Parameters:
ni
- Iterator which yields Nodes to be made members of the new set.
public NodeSetDTM(NodeSetDTM nodelist)
Create a NodeSetDTM, and copy the members of the given NodeSetDTM into it.
- Parameters:
nodelist
- Set of Nodes to be made members of the new set.
public void addElement(int value)
Append a Node onto the vector.
- Overrides:
- addElement in interface NodeVector
- Parameters:
value
- The node to be added.
public void addNode(int n)
Add a node to the NodeSetDTM. Not all types of NodeSetDTMs support this operation
- Parameters:
n
- Node to be added
public int addNodeInDocOrder(int node, boolean test, XPathContext support)
Add the node into a vector of nodes where it should occur in document order.
- Parameters:
node
- The node to be added.test
- true if we should test for doc ordersupport
- The XPath runtime context.
- Returns:
- insertIndex.
public int addNodeInDocOrder(int node, XPathContext support)
Add the node into a vector of nodes where it should occur in document order.
- Parameters:
node
- The node to be added.support
- The XPath runtime context.
- Returns:
- The index where it was inserted.
public void addNodes(DTMIterator iterator)
Copy NodeList members into this nodelist, adding in document order. Null references are not added.
- Parameters:
iterator
- DTMIterator which yields the nodes to be added.
public void addNodesInDocOrder(DTMIterator iterator, XPathContext support)
Copy NodeList members into this nodelist, adding in document order. If a node is null, don't add it.
- Parameters:
iterator
- DTMIterator which yields the nodes to be added.support
- The XPath runtime context.
public void allowDetachToRelease(boolean allowRelease)
Specify if it's OK for detach to release the iterator for reuse.
- Specified by:
- allowDetachToRelease in interface DTMIterator
- Parameters:
allowRelease
- true if it is OK for detach to release this iterator for pooling.
public void appendNodes(NodeVector nodes)
Append the nodes to the list.
- Overrides:
- appendNodes in interface NodeVector
- Parameters:
nodes
- The nodes to be appended to this node set.
public Object clone() throws CloneNotSupportedException
Clone this NodeSetDTM. At this time, we only expect this to be used with LocPathIterators; it may not work with other kinds of NodeSetDTMs.
- Specified by:
- clone in interface DTMIterator
- Overrides:
- clone in interface NodeVector
- Returns:
- a new NodeSetDTM of the same type, having the same state... though unless overridden in the subclasses, it may not copy all the state information.
public DTMIterator cloneWithReset() throws CloneNotSupportedException
Get a cloned Iterator, and reset its state to the beginning of the iteration.
- Specified by:
- cloneWithReset in interface DTMIterator
- Returns:
- a new NodeSetDTM of the same type, having the same state... except that the reset() operation has been called.
public boolean contains(int s)
Tell if the table contains the given node.
- Overrides:
- contains in interface NodeVector
- Parameters:
s
- Node to look for
- Returns:
- True if the given node was found.
public void detach()
Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. Afterdetach
has been invoked, calls tonextNode
orpreviousNode
will raise the exception INVALID_STATE_ERR. This operation is a no-op in NodeSetDTM, and will not cause INVALID_STATE_ERR to be raised by later operations.
- Specified by:
- detach in interface DTMIterator
public int elementAt(int i)
Get the nth element.
- Overrides:
- elementAt in interface NodeVector
- Parameters:
i
- The index of the requested node.
- Returns:
- Node at specified index.
public int getAxis()
Returns the axis being iterated, if it is known.
- Specified by:
- getAxis in interface DTMIterator
- Returns:
- Axis.CHILD, etc., or -1 if the axis is not known or is of multiple types.
public int getCurrentNode()
Return the last fetched node. Needed to support the UnionPathIterator.
- Specified by:
- getCurrentNode in interface DTMIterator
- Returns:
- the last fetched node.
public int getCurrentPos()
Get the current position, which is one less than the next nextNode() call will retrieve. 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 DTMIterator
- Returns:
- The the current position index.
public DTM getDTM(int nodeHandle)
Get an instance of a DTM that "owns" a node handle. Since a node iterator may be passed without a DTMManager, this allows the caller to easily get the DTM using just the iterator.
- Specified by:
- getDTM in interface DTMIterator
- Parameters:
nodeHandle
- the nodeHandle.
- Returns:
- a non-null DTM reference.
public DTMManager getDTMManager()
Get an instance of the DTMManager. Since a node iterator may be passed without a DTMManager, this allows the caller to easily get the DTMManager using just the iterator.
- Specified by:
- getDTMManager in interface DTMIterator
- Returns:
- a non-null DTMManager reference.
public boolean getExpandEntityReferences()
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 DTMIterator
- Returns:
- true for all iterators based on NodeSetDTM, meaning that the contents of EntityRefrence nodes may be returned (though whatToShow says that the EntityReferences themselves are not shown.)
public DTMFilter getFilter()
The filter object used to screen nodes. Filters are applied to further reduce (and restructure) the DTMIterator's view of the document. In our case, we will be using hardcoded filters built into our iterators... but getFilter() is part of the DOM's DTMIterator interface, so we have to support it.
- Returns:
- null, which is slightly misleading. True, there is no user-written filter object, but in fact we are doing some very sophisticated custom filtering. A DOM purist might suggest returning a placeholder object just to indicate that this is not going to return all nodes selected by whatToShow.
public int getLast()
public int getLength()
The number of nodes in the list. The range of valid child node indices is 0 tolength-1
inclusive. Note that this operation requires finding all the matching nodes, which may defeat attempts to defer that work.
- Specified by:
- getLength in interface DTMIterator
- Returns:
- integer indicating how many nodes are represented by this list.
public int getRoot()
- Specified by:
- getRoot in interface DTMIterator
- Returns:
- The root node of the Iterator, as specified when it was created. For non-Iterator NodeSetDTMs, this will be null.
public boolean getShouldCacheNodes()
Get whether or not this is a cached node set.
- Returns:
- True if this list is cached.
public int getWhatToShow()
This attribute determines which node types are presented via the iterator. The available set of constants is defined in theDTMFilter
interface. For NodeSetDTMs, the mask has been hardcoded to show all nodes except EntityReference nodes, which have no equivalent in the XPath data model.
- Specified by:
- getWhatToShow in interface DTMIterator
- Returns:
- integer used as a bit-array, containing flags defined in the DOM's DTMFilter class. The value will be
SHOW_ALL & ~SHOW_ENTITY_REFERENCE
, meaning that only entity references are suppressed.
public int indexOf(int elem)
Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
- Overrides:
- indexOf in interface NodeVector
- Parameters:
elem
- Node to look for
- 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.
public int indexOf(int elem, int index)
Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
- Overrides:
- indexOf in interface NodeVector
- Parameters:
elem
- Node to look forindex
- Index of where to start the search
- 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.
public void insertElementAt(int value, int at)
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 interface NodeVector
- Parameters:
value
- The node to be inserted.at
- The index where the insert should occur.
public void insertNode(int n, int pos)
Insert a node at a given position.
- Parameters:
n
- Node to be addedpos
- Offset at which the node is to be inserted, with 0 being the first position.
public boolean isDocOrdered()
Returns true if all the nodes in the iteration well be returned in document order.
- Specified by:
- isDocOrdered in interface DTMIterator
- Returns:
- true as a default.
public boolean isFresh()
Tells if this NodeSetDTM 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 DTMIterator
- Returns:
- true if nextNode() would return the first node in the set, false if it would return a later one.
public boolean isMutable()
Tells if this iterator can have nodes added to it or set via thesetItem(int node, int index)
method.
- Specified by:
- isMutable in interface DTMIterator
- Returns:
- True if the nodelist can be mutated.
public int item(int index)
Returns theindex
th item in the collection. Ifindex
is greater than or equal to the number of nodes in the list, this returnsnull
. TODO: What happens if index is out of range?
- Specified by:
- item in interface DTMIterator
- Parameters:
index
- Index into the collection.
- Returns:
- The node at the
index
th position in theNodeList
, ornull
if that is not a valid index.
public int nextNode()
Returns the next node in the set and advances the position of the iterator in the set. After a DTMIterator is created, the first call to nextNode() returns the first node in the set.
- Specified by:
- nextNode in interface DTMIterator
- Returns:
- The next
Node
in the set being iterated over, orDTM.NULL
if there are no more members in that set.
public int previousNode()
Returns the previous node in the set and moves the position of the iterator backwards in the set.
- Specified by:
- previousNode in interface DTMIterator
- Returns:
- The previous
Node
in the set being iterated over, orDTM.NULL
if there are no more members in that set.
public void removeAllElements()
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 interface NodeVector
public boolean removeElement(int s)
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 interface NodeVector
- Parameters:
s
- The node to be removed.
- Returns:
- True if the node was successfully removed
public void removeElementAt(int i)
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 interface NodeVector
- Parameters:
i
- The index of the node to be removed.
public void removeNode(int n)
Remove a node.
- Parameters:
n
- Node to be added
public void reset()
Reset the iterator. May have no effect on non-iterator Nodesets.
- Specified by:
- reset in interface DTMIterator
public void runTo(int index)
If an index is requested, NodeSetDTM 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 DTMIterator
- Parameters:
index
- Position to advance (or retreat) to, with 0 requesting the reset ("fresh") position and -1 (or indeed any out-of-bounds value) requesting the final position.
public void setCurrentPos(int i)
Set the current position in the node set.
- Specified by:
- setCurrentPos in interface DTMIterator
- Parameters:
i
- Must be a valid index.
public void setElementAt(int node, int index)
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 interface NodeVector
- Parameters:
node
- The node to be set.index
- The index of the node to be replaced.
public void setEnvironment(Object environment)
Set the environment in which this iterator operates, which should provide: a node (the context node... same value as "root" defined below) a pair of non-zero positive integers (the context position and the context size) a set of variable bindings a function library the set of namespace declarations in scope for the expression. At this time the exact implementation of this environment is application dependent. Probably a proper interface will be created fairly soon.
- Parameters:
environment
- The environment object.
public void setItem(int node, int index)
Same as setElementAt.
- Specified by:
- setItem in interface DTMIterator
- Parameters:
node
- The node to be set.index
- The index of the node to be replaced.
public void setLast(int last)
public void setRoot(int context, Object environment)
Initialize the context values for this expression after it is cloned.
- Specified by:
- setRoot in interface DTMIterator
- Parameters:
context
- The XPath runtime context for this transformation.
public void setShouldCacheNodes(boolean b)
If setShouldCacheNodes(true) is called, then nodes will be cached. They are not cached by default. This switch must be set before the first call to nextNode is made, to ensure that all nodes are cached.
- Specified by:
- setShouldCacheNodes in interface DTMIterator
- Parameters:
b
- true if this node set should be cached.
public int size()
Get the length of the list.
- Overrides:
- size in interface NodeVector
- Returns:
- The size of this node set.