|
|||||||||
| Home >> All >> org >> apache >> [ xpath overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.xpath
Class NodeSetDTM

java.lang.Objectorg.apache.xml.utils.NodeVector
org.apache.xpath.NodeSetDTM
- All Implemented Interfaces:
- java.lang.Cloneable, org.apache.xml.dtm.DTMIterator, java.io.Serializable
- public class NodeSetDTM
- extends org.apache.xml.utils.NodeVector
- implements org.apache.xml.dtm.DTMIterator, java.lang.Cloneable
- extends org.apache.xml.utils.NodeVector
The NodeSetDTM 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.
Note that we directly implement the DOM's NodeIterator interface. We do not emulate all the behavior of the standard NodeIterator. In particular, we do not guarantee to present a "live view" of the document ... but in XSLT, the source document should never be mutated, so this should never be an issue.
Thought: Should NodeSetDTM really implement NodeList and NodeIterator, or should there be specific subclasses of it which do so? The advantage of doing it all here is that all NodeSetDTMs will respond to the same calls; the disadvantage is that some of them may return less-than-enlightening results when you do so.
| Field Summary | |
protected boolean |
m_cacheNodes
True if this list is cached. |
private int |
m_last
|
(package private) org.apache.xml.dtm.DTMManager |
m_manager
|
protected boolean |
m_mutable
True if this list can be mutated. |
protected int |
m_next
If this node is being used as an iterator, the next index that nextNode() will return. |
protected int |
m_root
The root of the iteration, if available. |
| Fields inherited from class org.apache.xml.utils.NodeVector |
m_firstFree |
| Fields inherited from interface org.apache.xml.dtm.DTMIterator |
FILTER_ACCEPT, FILTER_REJECT, FILTER_SKIP |
| Constructor Summary | |
NodeSetDTM(org.apache.xml.dtm.DTMIterator ni)
Create a NodeSetDTM, and copy the members of the given DTMIterator into it. |
|
NodeSetDTM(org.apache.xml.dtm.DTMManager dtmManager)
Create an empty nodelist. |
|
NodeSetDTM(int node,
org.apache.xml.dtm.DTMManager dtmManager)
Create a NodeSetDTM which contains the given Node. |
|
NodeSetDTM(int blocksize,
int dummy,
org.apache.xml.dtm.DTMManager dtmManager)
Create an empty, using the given block size. |
|
NodeSetDTM(org.w3c.dom.traversal.NodeIterator iterator,
XPathContext xctxt)
Create a NodeSetDTM, and copy the members of the given DTMIterator into it. |
|
NodeSetDTM(org.w3c.dom.NodeList nodeList,
XPathContext xctxt)
Create a NodeSetDTM, and copy the members of the given DTMIterator into it. |
|
NodeSetDTM(NodeSetDTM nodelist)
Create a NodeSetDTM, and copy the members of the given NodeSetDTM into it. |
|
| Method Summary | |
void |
addElement(int value)
Append a Node onto the vector. |
void |
addNode(int n)
Add a node to the NodeSetDTM. |
int |
addNodeInDocOrder(int node,
boolean test,
XPathContext support)
Add the node into a vector of nodes where it should occur in document order. |
int |
addNodeInDocOrder(int node,
XPathContext support)
Add the node into a vector of nodes where it should occur in document order. |
void |
addNodes(org.apache.xml.dtm.DTMIterator iterator)
Copy NodeList members into this nodelist, adding in document order. |
void |
addNodesInDocOrder(org.apache.xml.dtm.DTMIterator iterator,
XPathContext support)
Copy NodeList members into this nodelist, adding in document order. |
void |
allowDetachToRelease(boolean allowRelease)
Specify if it's OK for detach to release the iterator for reuse. |
void |
appendNodes(org.apache.xml.utils.NodeVector nodes)
Append the nodes to the list. |
java.lang.Object |
clone()
Clone this NodeSetDTM. |
org.apache.xml.dtm.DTMIterator |
cloneWithReset()
Get a cloned Iterator, and reset its state to the beginning of the iteration. |
boolean |
contains(int s)
Tell if the table contains the given node. |
void |
detach()
Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. |
int |
elementAt(int i)
Get the nth element. |
int |
getAxis()
Returns the axis being iterated, if it is known. |
int |
getCurrentNode()
Return the last fetched node. |
int |
getCurrentPos()
Get the current position, which is one less than the next nextNode() call will retrieve. |
org.apache.xml.dtm.DTM |
getDTM(int nodeHandle)
Get an instance of a DTM that "owns" a node handle. |
org.apache.xml.dtm.DTMManager |
getDTMManager()
Get an instance of the DTMManager. |
boolean |
getExpandEntityReferences()
The value of this flag determines whether the children of entity reference nodes are visible to the iterator. |
org.apache.xml.dtm.DTMFilter |
getFilter()
The filter object used to screen nodes. |
int |
getLast()
|
int |
getLength()
The number of nodes in the list. |
int |
getRoot()
The root node of the DTMIterator, as specified when it
was created. |
boolean |
getShouldCacheNodes()
Get whether or not this is a cached node set. |
int |
getWhatToShow()
This attribute determines which node types are presented via the iterator. |
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. |
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. |
void |
insertElementAt(int value,
int at)
Inserts the specified node in this vector at the specified index. |
void |
insertNode(int n,
int pos)
Insert a node at a given position. |
boolean |
isDocOrdered()
Returns true if all the nodes in the iteration well be returned in document order. |
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. |
boolean |
isMutable()
Tells if this iterator can have nodes added to it or set via the setItem(int node, int index) method. |
int |
item(int index)
Returns the indexth item in the collection. |
int |
nextNode()
Returns the next node in the set and advances the position of the iterator in the set. |
int |
previousNode()
Returns the previous node in the set and moves the position of the iterator backwards in the set. |
void |
removeAllElements()
Inserts the specified node in this vector at the specified index. |
boolean |
removeElement(int s)
Removes the first occurrence of the argument from this vector. |
void |
removeElementAt(int i)
Deletes the component at the specified index. |
void |
removeNode(int n)
Remove a node. |
void |
reset()
Reset the iterator. |
void |
runTo(int index)
If an index is requested, NodeSetDTM will call this method to run the iterator to the index. |
void |
setCurrentPos(int i)
Set the current position in the node set. |
void |
setElementAt(int node,
int index)
Sets the component at the specified index of this vector to be the specified object. |
void |
setEnvironment(java.lang.Object environment)
Set the environment in which this iterator operates, which should provide: a node (the context node... |
void |
setItem(int node,
int index)
Same as setElementAt. |
void |
setLast(int last)
|
void |
setRoot(int context,
java.lang.Object environment)
Initialize the context values for this expression after it is cloned. |
void |
setShouldCacheNodes(boolean b)
If setShouldCacheNodes(true) is called, then nodes will be cached. |
int |
size()
Get the length of the list. |
| Methods inherited from class org.apache.xml.utils.NodeVector |
insertInOrder, peepOrNull, peepTail, peepTailSub1, pop, popAndTop, popPair, popQuick, push, pushPair, RemoveAllNoClear, setTail, setTailSub1, sort, sort |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
m_manager
org.apache.xml.dtm.DTMManager m_manager
m_next
protected transient int m_next
- If this node is being used as an iterator, the next index that nextNode()
will return.
m_mutable
protected transient boolean m_mutable
- True if this list can be mutated.
m_cacheNodes
protected transient boolean m_cacheNodes
- True if this list is cached.
m_root
protected int m_root
- The root of the iteration, if available.
m_last
private transient int m_last
| Constructor Detail |
NodeSetDTM
public NodeSetDTM(org.apache.xml.dtm.DTMManager dtmManager)
- Create an empty nodelist.
NodeSetDTM
public NodeSetDTM(int blocksize,
int dummy,
org.apache.xml.dtm.DTMManager dtmManager)
- Create an empty, using the given block size.
NodeSetDTM
public NodeSetDTM(NodeSetDTM nodelist)
- Create a NodeSetDTM, and copy the members of the
given NodeSetDTM into it.
NodeSetDTM
public NodeSetDTM(org.apache.xml.dtm.DTMIterator ni)
- Create a NodeSetDTM, and copy the members of the
given DTMIterator into it.
NodeSetDTM
public NodeSetDTM(org.w3c.dom.traversal.NodeIterator iterator, XPathContext xctxt)
- Create a NodeSetDTM, and copy the members of the
given DTMIterator into it.
NodeSetDTM
public NodeSetDTM(org.w3c.dom.NodeList nodeList, XPathContext xctxt)
- Create a NodeSetDTM, and copy the members of the
given DTMIterator into it.
NodeSetDTM
public NodeSetDTM(int node,
org.apache.xml.dtm.DTMManager dtmManager)
- Create a NodeSetDTM which contains the given Node.
| Method Detail |
setEnvironment
public void setEnvironment(java.lang.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.
getRoot
public int getRoot()
- Description copied from interface:
org.apache.xml.dtm.DTMIterator - The root node of the
DTMIterator, as specified when it was created. Note the root node is not the root node of the document tree, but the context node from where the iteration begins and ends.- Specified by:
getRootin interfaceorg.apache.xml.dtm.DTMIterator
setRoot
public void setRoot(int context,
java.lang.Object environment)
- Initialize the context values for this expression
after it is cloned.
- Specified by:
setRootin interfaceorg.apache.xml.dtm.DTMIterator
clone
public java.lang.Object clone() throws java.lang.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:
clonein interfaceorg.apache.xml.dtm.DTMIterator
cloneWithReset
public org.apache.xml.dtm.DTMIterator cloneWithReset() throws java.lang.CloneNotSupportedException
- Get a cloned Iterator, and reset its state to the beginning of the
iteration.
- Specified by:
cloneWithResetin interfaceorg.apache.xml.dtm.DTMIterator
reset
public void reset()
- Reset the iterator. May have no effect on non-iterator Nodesets.
- Specified by:
resetin interfaceorg.apache.xml.dtm.DTMIterator
getWhatToShow
public int getWhatToShow()
- This attribute determines which node types are presented via the
iterator. The available set of constants is defined in the
DTMFilterinterface. 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:
getWhatToShowin interfaceorg.apache.xml.dtm.DTMIterator
getFilter
public org.apache.xml.dtm.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.
getExpandEntityReferences
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:
getExpandEntityReferencesin interfaceorg.apache.xml.dtm.DTMIterator
getDTM
public org.apache.xml.dtm.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:
getDTMin interfaceorg.apache.xml.dtm.DTMIterator
getDTMManager
public org.apache.xml.dtm.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:
getDTMManagerin interfaceorg.apache.xml.dtm.DTMIterator
nextNode
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:
nextNodein interfaceorg.apache.xml.dtm.DTMIterator
previousNode
public int previousNode()
- Returns the previous node in the set and moves the position of the
iterator backwards in the set.
- Specified by:
previousNodein interfaceorg.apache.xml.dtm.DTMIterator
detach
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. After
detachhas been invoked, calls tonextNodeorpreviousNodewill 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:
detachin interfaceorg.apache.xml.dtm.DTMIterator
allowDetachToRelease
public void allowDetachToRelease(boolean allowRelease)
- Specify if it's OK for detach to release the iterator for reuse.
- Specified by:
allowDetachToReleasein interfaceorg.apache.xml.dtm.DTMIterator
isFresh
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:
isFreshin interfaceorg.apache.xml.dtm.DTMIterator
runTo
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:
runToin interfaceorg.apache.xml.dtm.DTMIterator
item
public int item(int index)
- Returns the
indexth item in the collection. Ifindexis 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:
itemin interfaceorg.apache.xml.dtm.DTMIterator
getLength
public int getLength()
- The number of nodes in the list. The range of valid child node indices is
0 to
length-1inclusive. Note that this operation requires finding all the matching nodes, which may defeat attempts to defer that work.- Specified by:
getLengthin interfaceorg.apache.xml.dtm.DTMIterator
addNode
public void addNode(int n)
- Add a node to the NodeSetDTM. Not all types of NodeSetDTMs support this
operation
insertNode
public void insertNode(int n,
int pos)
- Insert a node at a given position.
removeNode
public void removeNode(int n)
- Remove a node.
addNodes
public void addNodes(org.apache.xml.dtm.DTMIterator iterator)
- Copy NodeList members into this nodelist, adding in
document order. Null references are not added.
addNodesInDocOrder
public void addNodesInDocOrder(org.apache.xml.dtm.DTMIterator iterator, XPathContext support)
- Copy NodeList members into this nodelist, adding in
document order. If a node is null, don't add it.
addNodeInDocOrder
public int addNodeInDocOrder(int node,
boolean test,
XPathContext support)
- Add the node into a vector of nodes where it should occur in
document order.
addNodeInDocOrder
public int addNodeInDocOrder(int node,
XPathContext support)
- Add the node into a vector of nodes where it should occur in
document order.
size
public int size()
- Get the length of the list.
addElement
public void addElement(int value)
- Append a Node onto the vector.
insertElementAt
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.
appendNodes
public void appendNodes(org.apache.xml.utils.NodeVector nodes)
- Append the nodes to the list.
removeAllElements
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.
removeElement
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.
removeElementAt
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.
setElementAt
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.
setItem
public void setItem(int node,
int index)
- Same as setElementAt.
- Specified by:
setItemin interfaceorg.apache.xml.dtm.DTMIterator
elementAt
public int elementAt(int i)
- Get the nth element.
contains
public boolean contains(int s)
- Tell if the table contains the given node.
indexOf
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.
indexOf
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.
getCurrentPos
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:
getCurrentPosin interfaceorg.apache.xml.dtm.DTMIterator
setCurrentPos
public void setCurrentPos(int i)
- Set the current position in the node set.
- Specified by:
setCurrentPosin interfaceorg.apache.xml.dtm.DTMIterator
getCurrentNode
public int getCurrentNode()
- Return the last fetched node. Needed to support the UnionPathIterator.
- Specified by:
getCurrentNodein interfaceorg.apache.xml.dtm.DTMIterator
getShouldCacheNodes
public boolean getShouldCacheNodes()
- Get whether or not this is a cached node set.
setShouldCacheNodes
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:
setShouldCacheNodesin interfaceorg.apache.xml.dtm.DTMIterator
isMutable
public boolean isMutable()
- Tells if this iterator can have nodes added to it or set via
the
setItem(int node, int index)method.- Specified by:
isMutablein interfaceorg.apache.xml.dtm.DTMIterator
getLast
public int getLast()
setLast
public void setLast(int last)
isDocOrdered
public boolean isDocOrdered()
- Returns true if all the nodes in the iteration well be returned in document
order.
- Specified by:
isDocOrderedin interfaceorg.apache.xml.dtm.DTMIterator
getAxis
public int getAxis()
- Returns the axis being iterated, if it is known.
- Specified by:
getAxisin interfaceorg.apache.xml.dtm.DTMIterator
|
|||||||||
| Home >> All >> org >> apache >> [ xpath overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC