|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.xml.utils.NodeVector | +--org.apache.xpath.NodeSetDTM
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.
Constructor Summary | |
NodeSetDTM(DTMIterator ni)
Create a NodeSetDTM, and copy the members of the given DTMIterator into it. |
|
NodeSetDTM(DTMManager dtmManager)
Create an empty nodelist. |
|
NodeSetDTM(int node,
DTMManager dtmManager)
Create a NodeSetDTM which contains the given Node. |
|
NodeSetDTM(int blocksize,
int dummy,
DTMManager dtmManager)
Create an empty, using the given block size. |
|
NodeSetDTM(NodeIterator iterator,
XPathContext xctxt)
Create a NodeSetDTM, and copy the members of the given DTMIterator into it. |
|
NodeSetDTM(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(DTMIterator iterator)
Copy NodeList members into this nodelist, adding in document order. |
void |
addNodesInDocOrder(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(NodeVector nodes)
Append the nodes to the list. |
java.lang.Object |
clone()
Clone this NodeSetDTM. |
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. |
DTM |
getDTM(int nodeHandle)
Get an instance of a DTM that "owns" a node handle. |
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. |
DTMFilter |
getFilter()
The filter object used to screen nodes. |
int |
getLast()
|
int |
getLength()
The number of nodes in the list. |
int |
getRoot()
|
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 index th 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,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public NodeSetDTM(DTMManager dtmManager)
public NodeSetDTM(int blocksize, int dummy, DTMManager dtmManager)
blocksize
- Size of blocks to allocatedummy
- pass zero for right now...public NodeSetDTM(NodeSetDTM nodelist)
nodelist
- Set of Nodes to be made members of the new set.public NodeSetDTM(DTMIterator ni)
ni
- Iterator which yields Nodes to be made members of the new set.public NodeSetDTM(NodeIterator iterator, XPathContext xctxt)
iterator
- Iterator which yields Nodes to be made members of the new set.public NodeSetDTM(NodeList nodeList, XPathContext xctxt)
public NodeSetDTM(int node, DTMManager dtmManager)
node
- Single node to be added to the new set.Method Detail |
public void setEnvironment(java.lang.Object environment)
At this time the exact implementation of this environment is application dependent. Probably a proper interface will be created fairly soon.
environment
- The environment object.public int getRoot()
public void setRoot(int context, java.lang.Object environment)
context
- The XPath runtime context for this
transformation.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
public DTMIterator cloneWithReset() throws java.lang.CloneNotSupportedException
public void reset()
public int getWhatToShow()
DTMFilter
interface. For NodeSetDTMs, the mask has been
hardcoded to show all nodes except EntityReference nodes, which have
no equivalent in the XPath data model.SHOW_ALL & ~SHOW_ENTITY_REFERENCE
, meaning that
only entity references are suppressed.public DTMFilter getFilter()
public boolean getExpandEntityReferences()
public DTM getDTM(int nodeHandle)
nodeHandle
- the nodeHandle.public DTMManager getDTMManager()
public int nextNode()
Node
in the set being iterated over, or
DTM.NULL
if there are no more members in that set.detach
method was invoked.public int previousNode()
Node
in the set being iterated over,
orDTM.NULL
if there are no more members in that set.detach
method was invoked.public void detach()
detach
has been invoked, calls to
nextNode
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.
public void allowDetachToRelease(boolean allowRelease)
allowRelease
- true if it is OK for detach to release this iterator
for pooling.public boolean isFresh()
public void runTo(int index)
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 int item(int index)
index
th item in the collection. If
index
is greater than or equal to the number of nodes in
the list, this returns null
.
TODO: What happens if index is out of range?index
- Index into the collection.index
th position in the
NodeList
, or null
if that is not a valid
index.public int getLength()
length-1
inclusive. Note that this operation requires
finding all the matching nodes, which may defeat attempts to defer
that work.public void addNode(int n)
n
- Node to be addedpublic void insertNode(int n, int pos)
n
- Node to be addedpos
- Offset at which the node is to be inserted,
with 0 being the first position.public void removeNode(int n)
n
- Node to be addedpublic void addNodes(DTMIterator iterator)
iterator
- DTMIterator which yields the nodes to be added.public void addNodesInDocOrder(DTMIterator iterator, XPathContext support)
iterator
- DTMIterator which yields the nodes to be added.support
- The XPath runtime context.public int addNodeInDocOrder(int node, boolean test, XPathContext support)
node
- The node to be added.test
- true if we should test for doc ordersupport
- The XPath runtime context.public int addNodeInDocOrder(int node, XPathContext support)
node
- The node to be added.support
- The XPath runtime context.public int size()
public void addElement(int value)
value
- The node to be added.public void insertElementAt(int value, int at)
value
- The node to be inserted.at
- The index where the insert should occur.public void appendNodes(NodeVector nodes)
nodes
- The nodes to be appended to this node set.public void removeAllElements()
public boolean removeElement(int s)
s
- The node to be removed.public void removeElementAt(int i)
i
- The index of the node to be removed.public void setElementAt(int node, int index)
node
- The node to be set.index
- The index of the node to be replaced.public void setItem(int node, int index)
node
- The node to be set.index
- The index of the node to be replaced.public int elementAt(int i)
i
- The index of the requested node.public boolean contains(int s)
s
- Node to look forpublic int indexOf(int elem, int index)
elem
- Node to look forindex
- Index of where to start the searchpublic int indexOf(int elem)
elem
- Node to look forpublic int getCurrentPos()
public void setCurrentPos(int i)
i
- Must be a valid index.public int getCurrentNode()
public boolean getShouldCacheNodes()
public void setShouldCacheNodes(boolean b)
b
- true if this node set should be cached.public boolean isMutable()
setItem(int node, int index)
method.public int getLast()
public void setLast(int last)
public boolean isDocOrdered()
public int getAxis()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |