Methods Summary |
---|
public void | addElement(int value)Append a Node onto the vector.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
super.addElement(value);
|
public void | addNode(int n)Add a node to the NodeSetDTM. Not all types of NodeSetDTMs support this
operation
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
this.addElement(n);
|
public int | addNodeInDocOrder(int node, boolean test, com.sun.org.apache.xpath.internal.XPathContext support)Add the node into a vector of nodes where it should occur in
document order.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
int insertIndex = -1;
if (test)
{
// This needs to do a binary search, but a binary search
// is somewhat tough because the sequence test involves
// two nodes.
int size = size(), i;
for (i = size - 1; i >= 0; i--)
{
int child = elementAt(i);
if (child == node)
{
i = -2; // Duplicate, suppress insert
break;
}
DTM dtm = support.getDTM(node);
if (!dtm.isNodeAfter(node, child))
{
break;
}
}
if (i != -2)
{
insertIndex = i + 1;
insertElementAt(node, insertIndex);
}
}
else
{
insertIndex = this.size();
boolean foundit = false;
for (int i = 0; i < insertIndex; i++)
{
if (i == node)
{
foundit = true;
break;
}
}
if (!foundit)
addElement(node);
}
// checkDups();
return insertIndex;
|
public int | addNodeInDocOrder(int node, com.sun.org.apache.xpath.internal.XPathContext support)Add the node into a vector of nodes where it should occur in
document order.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
return addNodeInDocOrder(node, true, support);
|
public void | addNodes(com.sun.org.apache.xml.internal.dtm.DTMIterator iterator)Copy NodeList members into this nodelist, adding in
document order. Null references are not added.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
if (null != iterator) // defensive to fix a bug that Sanjiva reported.
{
int obj;
while (DTM.NULL != (obj = iterator.nextNode()))
{
addElement(obj);
}
}
// checkDups();
|
public void | addNodesInDocOrder(com.sun.org.apache.xml.internal.dtm.DTMIterator iterator, com.sun.org.apache.xpath.internal.XPathContext support)Copy NodeList members into this nodelist, adding in
document order. If a node is null, don't add it.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
int node;
while (DTM.NULL != (node = iterator.nextNode()))
{
addNodeInDocOrder(node, support);
}
|
public void | allowDetachToRelease(boolean allowRelease)Specify if it's OK for detach to release the iterator for reuse.
// no action for right now.
|
public void | appendNodes(com.sun.org.apache.xml.internal.utils.NodeVector nodes)Append the nodes to the list.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
super.appendNodes(nodes);
|
public java.lang.Object | 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.
NodeSetDTM clone = (NodeSetDTM) super.clone();
return clone;
|
public com.sun.org.apache.xml.internal.dtm.DTMIterator | cloneWithReset()Get a cloned Iterator, and reset its state to the beginning of the
iteration.
NodeSetDTM clone = (NodeSetDTM) clone();
clone.reset();
return clone;
|
public boolean | contains(int s)Tell if the table contains the given node.
runTo(-1);
return super.contains(s);
|
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 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 int | elementAt(int i)Get the nth element.
runTo(i);
return super.elementAt(i);
|
public int | getAxis()Returns the axis being iterated, if it is known.
return -1;
|
public int | getCurrentNode()Return the last fetched node. Needed to support the UnionPathIterator.
if (!m_cacheNodes)
throw new RuntimeException(
"This NodeSetDTM can not do indexing or counting functions!");
int saved = m_next;
// because nextNode always increments
// But watch out for copy29, where the root iterator didn't
// have nextNode called on it.
int current = (m_next > 0) ? m_next-1 : m_next;
int n = (current < m_firstFree) ? elementAt(current) : DTM.NULL;
m_next = saved; // HACK: I think this is a bit of a hack. -sb
return n;
|
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.
return m_next;
|
public com.sun.org.apache.xml.internal.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.
return m_manager.getDTM(nodeHandle);
|
public com.sun.org.apache.xml.internal.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.
return m_manager;
|
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.
return true;
|
public com.sun.org.apache.xml.internal.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.
return null;
|
public int | getLast()
return m_last;
|
public int | 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.
runTo(-1);
return this.size();
|
public int | getRoot()
if(DTM.NULL == m_root)
{
if(size() > 0)
return item(0);
else
return DTM.NULL;
}
else
return m_root;
|
public boolean | getShouldCacheNodes()Get whether or not this is a cached node set.
return m_cacheNodes;
|
public int | 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.
return DTMFilter.SHOW_ALL & ~DTMFilter.SHOW_ENTITY_REFERENCE;
|
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.
runTo(-1);
return super.indexOf(elem, index);
|
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.
runTo(-1);
return super.indexOf(elem);
|
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.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
super.insertElementAt(value, at);
|
public void | insertNode(int n, int pos)Insert a node at a given position.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
insertElementAt(n, pos);
|
public boolean | isDocOrdered()Returns true if all the nodes in the iteration well be returned in document
order.
return true;
|
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.
return (m_next == 0);
|
public boolean | isMutable()Tells if this iterator can have nodes added to it or set via
the setItem(int node, int index) method.
return m_mutable;
|
public int | item(int index)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 .
TODO: What happens if index is out of range?
runTo(index);
return this.elementAt(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.
if ((m_next) < this.size())
{
int next = this.elementAt(m_next);
m_next++;
return next;
}
else
return DTM.NULL;
|
public int | previousNode()Returns the previous node in the set and moves the position of the
iterator backwards in the set.
if (!m_cacheNodes)
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_ITERATE, null)); //"This NodeSetDTM can not iterate to a previous node!");
if ((m_next - 1) > 0)
{
m_next--;
return this.elementAt(m_next);
}
else
return DTM.NULL;
|
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.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
super.removeAllElements();
|
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.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
return super.removeElement(s);
|
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.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
super.removeElementAt(i);
|
public void | removeNode(int n)Remove a node.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
this.removeElement(n);
|
public void | reset()Reset the iterator. May have no effect on non-iterator Nodesets.
m_next = 0;
|
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.
if (!m_cacheNodes)
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_INDEX, null)); //"This NodeSetDTM can not do indexing or counting functions!");
if ((index >= 0) && (m_next < m_firstFree))
m_next = index;
else
m_next = m_firstFree - 1;
|
public void | setCurrentPos(int i)Set the current position in the node set.
if (!m_cacheNodes)
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_INDEX, null)); //"This NodeSetDTM can not do indexing or counting functions!");
m_next = i;
|
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.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
super.setElementAt(node, index);
|
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.
// no-op
|
public void | setItem(int node, int index)Same as setElementAt.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");
super.setElementAt(node, index);
|
public void | setLast(int last)
m_last = last;
|
public void | setRoot(int context, java.lang.Object environment)Initialize the context values for this expression
after it is cloned.
// no-op, I guess... (-sb)
|
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.
if (!isFresh())
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_CALL_SETSHOULDCACHENODE, null)); //"Can not call setShouldCacheNodes after nextNode has been called!");
m_cacheNodes = b;
m_mutable = true;
|
public int | size()Get the length of the list.
return super.size();
|