APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xpath.internal

public Class NodeSetDTM

extends NodeVector
implements DTMIterator, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, com.sun.org.apache.xml.internal.dtm.DTMIterator
Known Direct Subclasses
com.sun.org.apache.xpath.internal.axes.RTFIterator
Imports
com.sun.org.apache.xalan.internal.res.XSLMessages, com.sun.org.apache.xml.internal.dtm.DTM, .DTMFilter, .DTMIterator, .DTMManager, com.sun.org.apache.xml.internal.utils.NodeVector, com.sun.org.apache.xpath.internal.res.XPATHErrorResources, org.w3c.dom.Node, .NodeList, org.w3c.dom.traversal.NodeIterator

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

Modifier and TypeField and Description
protected transient boolean
m_cacheNodes

True if this list is cached.

private transient int
pack-priv DTMManager
protected transient 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.

pack-priv static final long
Inherited from com.sun.org.apache.xml.internal.utils.NodeVector:
m_firstFree

Constructor Summary

AccessConstructor and Description
public
NodeSetDTM(DTMManager dtmManager)

Create an empty nodelist.

public
NodeSetDTM(int
Size of blocks to allocate
blocksize
,
int
pass zero for right now...
dummy
,
DTMManager dtmManager)

Create an empty, using the given block size.

public
NodeSetDTM(NodeSetDTM
Set of Nodes to be made members of the new set.
nodelist
)

Create a NodeSetDTM, and copy the members of the given NodeSetDTM into it.

public
NodeSetDTM(DTMIterator
Iterator which yields Nodes to be made members of the new set.
ni
)

Create a NodeSetDTM, and copy the members of the given DTMIterator into it.

public
NodeSetDTM(NodeIterator
Iterator which yields Nodes to be made members of the new set.
iterator
,
XPathContext xctxt)

Create a NodeSetDTM, and copy the members of the given DTMIterator into it.

public
NodeSetDTM(NodeList nodeList, XPathContext xctxt)

Create a NodeSetDTM, and copy the members of the given DTMIterator into it.

public
NodeSetDTM(int
Single node to be added to the new set.
node
,
DTMManager dtmManager)

Create a NodeSetDTM which contains the given Node.

Method Summary

Modifier and TypeMethod and Description
public void
addElement(int
The node to be added.
value
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.addElement.

Append a Node onto the vector.

public void
addNode(int
Node to be added
n
)

Add a node to the NodeSetDTM.

public int

Returns:

insertIndex.
addNodeInDocOrder
(int
The node to be added.
node
,
boolean
true if we should test for doc order
test
,
XPathContext
The XPath runtime context.
support
)

Add the node into a vector of nodes where it should occur in document order.

public int

Returns:

The index where it was inserted.
addNodeInDocOrder
(int
The node to be added.
node
,
XPathContext
The XPath runtime context.
support
)

Add the node into a vector of nodes where it should occur in document order.

public void
addNodes(DTMIterator
DTMIterator which yields the nodes to be added.
iterator
)

Copy NodeList members into this nodelist, adding in document order.

public void
addNodesInDocOrder(DTMIterator
DTMIterator which yields the nodes to be added.
iterator
,
XPathContext
The XPath runtime context.
support
)

Copy NodeList members into this nodelist, adding in document order.

public void
allowDetachToRelease(boolean
true if it is OK for detach to release this iterator for pooling.
allowRelease
)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.allowDetachToRelease.

Specify if it's OK for detach to release the iterator for reuse.

public void
appendNodes(NodeVector
The nodes to be appended to this node set.
nodes
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.appendNodes.

Append the nodes to the list.

public Object

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.
clone
()

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.clone.

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.clone.

Clone this NodeSetDTM.

public DTMIterator

Returns:

a new NodeSetDTM of the same type, having the same state... except that the reset() operation has been called.
cloneWithReset
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.cloneWithReset.

Get a cloned Iterator, and reset its state to the beginning of the iteration.

public boolean

Returns:

True if the given node was found.
contains
(int
Node to look for
s
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.contains.

Tell if the table contains the given node.

public void
detach()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.detach.

Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.

public int

Returns:

Node at specified index.
elementAt
(int
The index of the requested node.
i
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.elementAt.

Get the nth element.

public int

Returns:

Axis.CHILD, etc., or -1 if the axis is not known or is of multiple types.
getAxis
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getAxis.

Returns the axis being iterated, if it is known.

public int

Returns:

the last fetched node.
getCurrentNode
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getCurrentNode.

Return the last fetched node.

public int

Returns:

The the current position index.
getCurrentPos
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getCurrentPos.

Get the current position, which is one less than the next nextNode() call will retrieve.

public DTM

Returns:

a non-null DTM reference.
getDTM
(int
the nodeHandle.
nodeHandle
)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getDTM.

Get an instance of a DTM that "owns" a node handle.

public DTMManager

Returns:

a non-null DTMManager reference.
getDTMManager
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getDTMManager.

Get an instance of the DTMManager.

public boolean

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.)
getExpandEntityReferences
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getExpandEntityReferences.

The value of this flag determines whether the children of entity reference nodes are visible to the iterator.

public DTMFilter

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.
getFilter
()

The filter object used to screen nodes.

public int
public int

Returns:

integer indicating how many nodes are represented by this list.
getLength
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getLength.

The number of nodes in the list.

public int

Returns:

The root node of the Iterator, as specified when it was created. For non-Iterator NodeSetDTMs, this will be null.
getRoot
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getRoot.

The root node of the DTMIterator, as specified when it was created.

public boolean

Returns:

True if this list is cached.
getShouldCacheNodes
()

Get whether or not this is a cached node set.

public int

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.
getWhatToShow
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getWhatToShow.

This attribute determines which node types are presented via the iterator.

public int

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.
indexOf
(int
Node to look for
elem
,
int
Index of where to start the search
index
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.indexOf.

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

public int

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.
indexOf
(int
Node to look for
elem
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.indexOf.

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

public void
insertElementAt(int
The node to be inserted.
value
,
int
The index where the insert should occur.
at
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.insertElementAt.

Inserts the specified node in this vector at the specified index.

public void
insertNode(int
Node to be added
n
,
int
Offset at which the node is to be inserted, with 0 being the first position.
pos
)

Insert a node at a given position.

public boolean

Returns:

true as a default.
isDocOrdered
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.isDocOrdered.

Returns true if all the nodes in the iteration well be returned in document order.

public boolean

Returns:

true if nextNode() would return the first node in the set, false if it would return a later one.
isFresh
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.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.

public boolean

Returns:

True if the nodelist can be mutated.
isMutable
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.isMutable.

Tells if this iterator can have nodes added to it or set via the setItem(int node, int index) method.

public int

Returns:

The node at the indexth position in the NodeList, or null if that is not a valid index.
item
(int
Index into the collection.
index
)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.item.

Returns the indexth item in the collection.

public int

Returns:

The next Node in the set being iterated over, or DTM.NULL if there are no more members in that set.
nextNode
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.nextNode.

Returns the next node in the set and advances the position of the iterator in the set.

public int

Returns:

The previous Node in the set being iterated over, orDTM.NULL if there are no more members in that set.
previousNode
()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.previousNode.

Returns the previous node in the set and moves the position of the iterator backwards in the set.

public void
removeAllElements()

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.removeAllElements.

Inserts the specified node in this vector at the specified index.

public boolean

Returns:

True if the node was successfully removed
removeElement
(int
The node to be removed.
s
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.removeElement.

Removes the first occurrence of the argument from this vector.

public void
removeElementAt(int
The index of the node to be removed.
i
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.removeElementAt.

Deletes the component at the specified index.

public void
removeNode(int
Node to be added
n
)

Remove a node.

public void
public void
runTo(int
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.
index
)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.runTo.

If an index is requested, NodeSetDTM will call this method to run the iterator to the index.

public void
setCurrentPos(int
Must be a valid index.
i
)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.setCurrentPos.

Set the current position in the node set.

public void
setElementAt(int
The node to be set.
node
,
int
The index of the node to be replaced.
index
)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.setElementAt.

Sets the component at the specified index of this vector to be the specified object.

public void
setEnvironment(Object
The environment object.
environment
)

Set the environment in which this iterator operates, which should provide: a node (the context node...

public void
setItem(int
The node to be set.
node
,
int
The index of the node to be replaced.
index
)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.setItem.

Same as setElementAt.

public void
setLast(int last)

public void
setRoot(int
The XPath runtime context for this transformation.
context
,
Object environment)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.setRoot.

Initialize the context values for this expression after it is cloned.

public void
setShouldCacheNodes(boolean
true if this node set should be cached.
b
)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.setShouldCacheNodes.

If setShouldCacheNodes(true) is called, then nodes will be cached.

public int

Returns:

The size of this node set.
size
()

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.size.

Get the length of the list.

Inherited from com.sun.org.apache.xml.internal.utils.NodeVector:
insertInOrderpeepOrNullpeepTailpeepTailSub1poppopAndToppopPairpopQuickpushpushPairRemoveAllNoClearsetTailsetTailSub1sortsort

Field Detail

m_cacheNodesback to summary
protected transient boolean m_cacheNodes

True if this list is cached.

m_lastback to summary
private transient int m_last
m_managerback to summary
pack-priv DTMManager m_manager
Annotations
@SuppressWarnings:serial
m_nextback to summary
protected transient int m_next

If this node is being used as an iterator, the next index that nextNode() will return.

m_rootback to summary
protected int m_root

The root of the iteration, if available.

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides com.sun.org.apache.xml.internal.utils.NodeVector.serialVersionUID.

Constructor Detail

NodeSetDTMback to summary
public NodeSetDTM(DTMManager dtmManager)

Create an empty nodelist.

NodeSetDTMback to summary
public NodeSetDTM(int blocksize, int dummy, DTMManager dtmManager)

Create an empty, using the given block size.

Parameters
blocksize:int

Size of blocks to allocate

dummy:int

pass zero for right now...

NodeSetDTMback to summary
public NodeSetDTM(NodeSetDTM nodelist)

Create a NodeSetDTM, and copy the members of the given NodeSetDTM into it.

Parameters
nodelist:NodeSetDTM

Set of Nodes to be made members of the new set.

NodeSetDTMback to summary
public NodeSetDTM(DTMIterator ni)

Create a NodeSetDTM, and copy the members of the given DTMIterator into it.

Parameters
ni:DTMIterator

Iterator which yields Nodes to be made members of the new set.

NodeSetDTMback to summary
public NodeSetDTM(NodeIterator iterator, XPathContext xctxt)

Create a NodeSetDTM, and copy the members of the given DTMIterator into it.

Parameters
iterator:NodeIterator

Iterator which yields Nodes to be made members of the new set.

NodeSetDTMback to summary
public NodeSetDTM(NodeList nodeList, XPathContext xctxt)

Create a NodeSetDTM, and copy the members of the given DTMIterator into it.

NodeSetDTMback to summary
public NodeSetDTM(int node, DTMManager dtmManager)

Create a NodeSetDTM which contains the given Node.

Parameters
node:int

Single node to be added to the new set.

Method Detail

addElementback to summary
public void addElement(int value)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.addElement.

Append a Node onto the vector.

Parameters
value:int

The node to be added.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
addNodeback to summary
public void addNode(int n)

Add a node to the NodeSetDTM. Not all types of NodeSetDTMs support this operation

Parameters
n:int

Node to be added

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
addNodeInDocOrderback to summary
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:int

The node to be added.

test:boolean

true if we should test for doc order

support:XPathContext

The XPath runtime context.

Returns:int

insertIndex.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
addNodeInDocOrderback to summary
public int addNodeInDocOrder(int node, XPathContext support)

Add the node into a vector of nodes where it should occur in document order.

Parameters
node:int

The node to be added.

support:XPathContext

The XPath runtime context.

Returns:int

The index where it was inserted.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
addNodesback to summary
public void addNodes(DTMIterator iterator)

Copy NodeList members into this nodelist, adding in document order. Null references are not added.

Parameters
iterator:DTMIterator

DTMIterator which yields the nodes to be added.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
addNodesInDocOrderback to summary
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

DTMIterator which yields the nodes to be added.

support:XPathContext

The XPath runtime context.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
allowDetachToReleaseback to summary
public void allowDetachToRelease(boolean allowRelease)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.allowDetachToRelease.

Specify if it's OK for detach to release the iterator for reuse.

Parameters
allowRelease:boolean

true if it is OK for detach to release this iterator for pooling.

appendNodesback to summary
public void appendNodes(NodeVector nodes)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.appendNodes.

Append the nodes to the list.

Parameters
nodes:NodeVector

The nodes to be appended to this node set.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.clone.

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.clone.

Clone this NodeSetDTM. At this time, we only expect this to be used with LocPathIterators; it may not work with other kinds of NodeSetDTMs.

Returns:Object

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.

Exceptions
CloneNotSupportedException:
if this subclass of NodeSetDTM does not support the clone() operation.
cloneWithResetback to summary
public DTMIterator cloneWithReset() throws CloneNotSupportedException

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.cloneWithReset.

Get a cloned Iterator, and reset its state to the beginning of the iteration.

Returns:DTMIterator

a new NodeSetDTM of the same type, having the same state... except that the reset() operation has been called.

Exceptions
CloneNotSupportedException:
if this subclass of NodeSetDTM does not support the clone() operation.
containsback to summary
public boolean contains(int s)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.contains.

Tell if the table contains the given node.

Parameters
s:int

Node to look for

Returns:boolean

True if the given node was found.

detachback to summary
public void detach()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.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 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.

elementAtback to summary
public int elementAt(int i)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.elementAt.

Get the nth element.

Parameters
i:int

The index of the requested node.

Returns:int

Node at specified index.

getAxisback to summary
public int getAxis()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getAxis.

Returns the axis being iterated, if it is known.

Returns:int

Axis.CHILD, etc., or -1 if the axis is not known or is of multiple types.

getCurrentNodeback to summary
public int getCurrentNode()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getCurrentNode.

Return the last fetched node. Needed to support the UnionPathIterator.

Returns:int

the last fetched node.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a cached type, and thus doesn't permit indexed access.
getCurrentPosback to summary
public int getCurrentPos()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.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.

Returns:int

The the current position index.

getDTMback to summary
public DTM getDTM(int nodeHandle)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getDTM.

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.

Parameters
nodeHandle:int

the nodeHandle.

Returns:DTM

a non-null DTM reference.

getDTMManagerback to summary
public DTMManager getDTMManager()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.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.

Returns:DTMManager

a non-null DTMManager reference.

getExpandEntityReferencesback to summary
public boolean getExpandEntityReferences()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.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.

Returns:boolean

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.)

getFilterback to summary
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:DTMFilter

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.

getLastback to summary
public int getLast()
getLengthback to summary
public int getLength()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getLength.

The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive. Note that this operation requires finding all the matching nodes, which may defeat attempts to defer that work.

Returns:int

integer indicating how many nodes are represented by this list.

getRootback to summary
public int getRoot()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getRoot.

Doc from com.sun.org.apache.xml.internal.dtm.DTMIterator.getRoot.

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.

Returns:int

The root node of the Iterator, as specified when it was created. For non-Iterator NodeSetDTMs, this will be null.

getShouldCacheNodesback to summary
public boolean getShouldCacheNodes()

Get whether or not this is a cached node set.

Returns:boolean

True if this list is cached.

getWhatToShowback to summary
public int getWhatToShow()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.getWhatToShow.

This attribute determines which node types are presented via the iterator. The available set of constants is defined in the 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.

Returns:int

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.

indexOfback to summary
public int indexOf(int elem, int index)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.indexOf.

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

Parameters
elem:int

Node to look for

index:int

Index of where to start the search

Returns:int

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.

indexOfback to summary
public int indexOf(int elem)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.indexOf.

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

Parameters
elem:int

Node to look for

Returns:int

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.

insertElementAtback to summary
public void insertElementAt(int value, int at)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.insertElementAt.

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.

Parameters
value:int

The node to be inserted.

at:int

The index where the insert should occur.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
insertNodeback to summary
public void insertNode(int n, int pos)

Insert a node at a given position.

Parameters
n:int

Node to be added

pos:int

Offset at which the node is to be inserted, with 0 being the first position.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
isDocOrderedback to summary
public boolean isDocOrdered()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.isDocOrdered.

Returns true if all the nodes in the iteration well be returned in document order.

Returns:boolean

true as a default.

isFreshback to summary
public boolean isFresh()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.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.

Returns:boolean

true if nextNode() would return the first node in the set, false if it would return a later one.

isMutableback to summary
public boolean isMutable()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.isMutable.

Tells if this iterator can have nodes added to it or set via the setItem(int node, int index) method.

Returns:boolean

True if the nodelist can be mutated.

itemback to summary
public int item(int index)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.item.

Returns the indexth 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?

Parameters
index:int

Index into the collection.

Returns:int

The node at the indexth position in the NodeList, or null if that is not a valid index.

nextNodeback to summary
public int nextNode()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.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.

Returns:int

The next Node in the set being iterated over, or DTM.NULL if there are no more members in that set.

Exceptions
DOMException:
INVALID_STATE_ERR: Raised if this method is called after the detach method was invoked.
previousNodeback to summary
public int previousNode()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.previousNode.

Returns the previous node in the set and moves the position of the iterator backwards in the set.

Returns:int

The previous Node in the set being iterated over, orDTM.NULL if there are no more members in that set.

Exceptions
DOMException:
INVALID_STATE_ERR: Raised if this method is called after the detach method was invoked.
RuntimeException:
thrown if this NodeSetDTM is not of a cached type, and hence doesn't know what the previous node was.
removeAllElementsback to summary
public void removeAllElements()

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.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.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
removeElementback to summary
public boolean removeElement(int s)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.removeElement.

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.

Parameters
s:int

The node to be removed.

Returns:boolean

True if the node was successfully removed

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
removeElementAtback to summary
public void removeElementAt(int i)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.removeElementAt.

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.

Parameters
i:int

The index of the node to be removed.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
removeNodeback to summary
public void removeNode(int n)

Remove a node.

Parameters
n:int

Node to be added

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
resetback to summary
public void reset()

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.reset.

Reset the iterator. May have no effect on non-iterator Nodesets.

runToback to summary
public void runTo(int index)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.runTo.

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.

Parameters
index:int

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.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not one of the types which supports indexing/counting.
setCurrentPosback to summary
public void setCurrentPos(int i)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.setCurrentPos.

Set the current position in the node set.

Parameters
i:int

Must be a valid index.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a cached type, and thus doesn't permit indexed access.
setElementAtback to summary
public void setElementAt(int node, int index)

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.setElementAt.

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.

Parameters
node:int

The node to be set.

index:int

The index of the node to be replaced.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
setEnvironmentback to summary
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:Object

The environment object.

setItemback to summary
public void setItem(int node, int index)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.setItem.

Same as setElementAt.

Parameters
node:int

The node to be set.

index:int

The index of the node to be replaced.

Exceptions
RuntimeException:
thrown if this NodeSetDTM is not of a mutable type.
setLastback to summary
public void setLast(int last)
setRootback to summary
public void setRoot(int context, Object environment)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.setRoot.

Initialize the context values for this expression after it is cloned.

Parameters
context:int

The XPath runtime context for this transformation.

setShouldCacheNodesback to summary
public void setShouldCacheNodes(boolean b)

Implements com.sun.org.apache.xml.internal.dtm.DTMIterator.setShouldCacheNodes.

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.

Parameters
b:boolean

true if this node set should be cached.

Exceptions
RuntimeException:
thrown if an attempt is made to request caching after we've already begun stepping through the nodes in this set.
sizeback to summary
public int size()

Overrides com.sun.org.apache.xml.internal.utils.NodeVector.size.

Get the length of the list.

Returns:int

The size of this node set.