Methods Summary |
---|
public void | addElement(org.w3c.dom.Node value)Append a Node onto the vector.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
if ((m_firstFree + 1) >= m_mapSize)
{
if (null == m_map)
{
m_map = new Node[m_blocksize];
m_mapSize = m_blocksize;
}
else
{
m_mapSize += m_blocksize;
Node newMap[] = new Node[m_mapSize];
System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);
m_map = newMap;
}
}
m_map[m_firstFree] = value;
m_firstFree++;
|
public void | addNode(org.w3c.dom.Node n)Add a node to the NodeSet. Not all types of NodeSets support this
operation
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
this.addElement(n);
|
public int | addNodeInDocOrder(org.w3c.dom.Node 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_NODESET_NOT_MUTABLE, null)); //XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet 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--)
{
Node child = (Node) elementAt(i);
if (child == node)
{
i = -2; // Duplicate, suppress insert
break;
}
if (!DOM2Helper.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 (this.item(i).equals(node))
{
foundit = true;
break;
}
}
if (!foundit)
addElement(node);
}
// checkDups();
return insertIndex;
|
public int | addNodeInDocOrder(org.w3c.dom.Node 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_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
return addNodeInDocOrder(node, true, support);
|
public void | addNodes(org.w3c.dom.NodeList nodelist)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_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
if (null != nodelist) // defensive to fix a bug that Sanjiva reported.
{
int nChildren = nodelist.getLength();
for (int i = 0; i < nChildren; i++)
{
Node obj = nodelist.item(i);
if (null != obj)
{
addElement(obj);
}
}
}
// checkDups();
|
public void | addNodes(com.sun.org.apache.xpath.internal.NodeSet ns)Copy NodeList members into this nodelist, adding in
document order. Only genuine node references will be copied;
nulls appearing in the source NodeSet will
not be added to this one.
In case you're wondering why this function is needed: NodeSet
implements both NodeIterator and NodeList. If this method isn't
provided, Java can't decide which of those to use when addNodes()
is invoked. Providing the more-explicit match avoids that
ambiguity.)
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
addNodes((NodeIterator) ns);
|
public void | addNodes(org.w3c.dom.traversal.NodeIterator 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_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
if (null != iterator) // defensive to fix a bug that Sanjiva reported.
{
Node obj;
while (null != (obj = iterator.nextNode()))
{
addElement(obj);
}
}
// checkDups();
|
public void | addNodesInDocOrder(org.w3c.dom.NodeList nodelist, 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_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
int nChildren = nodelist.getLength();
for (int i = 0; i < nChildren; i++)
{
Node node = nodelist.item(i);
if (null != node)
{
addNodeInDocOrder(node, support);
}
}
|
public void | addNodesInDocOrder(org.w3c.dom.traversal.NodeIterator 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_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
Node node;
while (null != (node = iterator.nextNode()))
{
addNodeInDocOrder(node, support);
}
|
private boolean | addNodesInDocOrder(int start, int end, int testIndex, org.w3c.dom.NodeList nodelist, com.sun.org.apache.xpath.internal.XPathContext support)Add the node list to this node set in document order.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
boolean foundit = false;
int i;
Node node = nodelist.item(testIndex);
for (i = end; i >= start; i--)
{
Node child = (Node) elementAt(i);
if (child == node)
{
i = -2; // Duplicate, suppress insert
break;
}
if (!DOM2Helper.isNodeAfter(node, child))
{
insertElementAt(node, i + 1);
testIndex--;
if (testIndex > 0)
{
boolean foundPrev = addNodesInDocOrder(0, i, testIndex, nodelist,
support);
if (!foundPrev)
{
addNodesInDocOrder(i, size() - 1, testIndex, nodelist, support);
}
}
break;
}
}
if (i == -1)
{
insertElementAt(node, 0);
}
return foundit;
|
public void | appendNodes(com.sun.org.apache.xpath.internal.NodeSet nodes)Append the nodes to the list.
int nNodes = nodes.size();
if (null == m_map)
{
m_mapSize = nNodes + m_blocksize;
m_map = new Node[m_mapSize];
}
else if ((m_firstFree + nNodes) >= m_mapSize)
{
m_mapSize += (nNodes + m_blocksize);
Node newMap[] = new Node[m_mapSize];
System.arraycopy(m_map, 0, newMap, 0, m_firstFree + nNodes);
m_map = newMap;
}
System.arraycopy(nodes.m_map, 0, m_map, m_firstFree, nNodes);
m_firstFree += nNodes;
|
public java.lang.Object | clone()Get a cloned LocPathIterator. // lazy initialization
NodeSet clone = (NodeSet) super.clone();
if ((null != this.m_map) && (this.m_map == clone.m_map))
{
clone.m_map = new Node[this.m_map.length];
System.arraycopy(this.m_map, 0, clone.m_map, 0, this.m_map.length);
}
return clone;
|
public org.w3c.dom.traversal.NodeIterator | cloneWithReset()Get a cloned Iterator, and reset its state to the beginning of the
iteration.
NodeSet clone = (NodeSet) clone();
clone.reset();
return clone;
|
public boolean | contains(org.w3c.dom.Node s)Tell if the table contains the given node.
runTo(-1);
if (null == m_map)
return false;
for (int i = 0; i < m_firstFree; i++)
{
Node node = m_map[i];
if ((null != node) && node.equals(s))
return true;
}
return false;
|
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 NodeSet, and will not cause
INVALID_STATE_ERR to be raised by later operations.
|
public org.w3c.dom.Node | elementAt(int i)Get the nth element.
if (null == m_map)
return null;
return m_map[i];
|
public org.w3c.dom.Node | getCurrentNode()Return the last fetched node. Needed to support the UnionPathIterator.
if (!m_cacheNodes)
throw new RuntimeException(
XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_CANNOT_INDEX, null)); //"This NodeSet can not do indexing or counting functions!");
int saved = m_next;
Node n = (m_next < m_firstFree) ? elementAt(m_next) : 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 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 org.w3c.dom.traversal.NodeFilter | getFilter()The filter object used to screen nodes. Filters are applied to
further reduce (and restructure) the NodeIterator'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
NodeIterator 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 org.w3c.dom.Node | getRoot()
return null;
|
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
NodeFilter interface. For NodeSets, the mask has been
hardcoded to show all nodes except EntityReference nodes, which have
no equivalent in the XPath data model.
return NodeFilter.SHOW_ALL & ~NodeFilter.SHOW_ENTITY_REFERENCE;
|
public int | indexOf(org.w3c.dom.Node 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);
if (null == m_map)
return -1;
for (int i = index; i < m_firstFree; i++)
{
Node node = m_map[i];
if ((null != node) && node.equals(elem))
return i;
}
return -1;
|
public int | indexOf(org.w3c.dom.Node 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);
if (null == m_map)
return -1;
for (int i = 0; i < m_firstFree; i++)
{
Node node = m_map[i];
if ((null != node) && node.equals(elem))
return i;
}
return -1;
|
public void | insertElementAt(org.w3c.dom.Node 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_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
if (null == m_map)
{
m_map = new Node[m_blocksize];
m_mapSize = m_blocksize;
}
else if ((m_firstFree + 1) >= m_mapSize)
{
m_mapSize += m_blocksize;
Node newMap[] = new Node[m_mapSize];
System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);
m_map = newMap;
}
if (at <= (m_firstFree - 1))
{
System.arraycopy(m_map, at, m_map, at + 1, m_firstFree - at);
}
m_map[at] = value;
m_firstFree++;
|
public void | insertNode(org.w3c.dom.Node n, int pos)Insert a node at a given position.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
insertElementAt(n, pos);
|
public boolean | isFresh()Tells if this NodeSet 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 org.w3c.dom.Node | 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 (Node) this.elementAt(index);
|
public org.w3c.dom.Node | nextNode()Returns the next node in the set and advances the position of the
iterator in the set. After a NodeIterator is created, the first call
to nextNode() returns the first node in the set.
if ((m_next) < this.size())
{
Node next = this.elementAt(m_next);
m_next++;
return next;
}
else
return null;
|
public final org.w3c.dom.Node | peepOrNull()Return the node at the top of the stack without popping the stack.
Special purpose method for TransformerImpl, pushElemTemplateElement.
Performance critical.
return ((null != m_map) && (m_firstFree > 0))
? m_map[m_firstFree - 1] : null;
|
public final org.w3c.dom.Node | peepTail()Return the node at the tail of the vector without popping
Special purpose method for TransformerImpl, pushElemTemplateElement.
Performance critical.
return m_map[m_firstFree - 1];
|
public final org.w3c.dom.Node | peepTailSub1()Return the node one position from the tail without popping.
Special purpose method for TransformerImpl, pushElemTemplateElement.
Performance critical.
return m_map[m_firstFree - 2];
|
public final org.w3c.dom.Node | pop()Pop a node from the tail of the vector and return the result.
m_firstFree--;
Node n = m_map[m_firstFree];
m_map[m_firstFree] = null;
return n;
|
public final org.w3c.dom.Node | popAndTop()Pop a node from the tail of the vector and return the
top of the stack after the pop.
m_firstFree--;
m_map[m_firstFree] = null;
return (m_firstFree == 0) ? null : m_map[m_firstFree - 1];
|
public final void | popPair()Pop a pair of nodes from the tail of the stack.
Special purpose method for TransformerImpl, pushElemTemplateElement.
Performance critical.
m_firstFree -= 2;
m_map[m_firstFree] = null;
m_map[m_firstFree + 1] = null;
|
public final void | popQuick()Pop a node from the tail of the vector.
m_firstFree--;
m_map[m_firstFree] = null;
|
public org.w3c.dom.Node | 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_NODESET_CANNOT_ITERATE, null)); //"This NodeSet can not iterate to a previous node!");
if ((m_next - 1) > 0)
{
m_next--;
return this.elementAt(m_next);
}
else
return null;
|
public final void | push(org.w3c.dom.Node value)Append a Node onto the vector.
int ff = m_firstFree;
if ((ff + 1) >= m_mapSize)
{
if (null == m_map)
{
m_map = new Node[m_blocksize];
m_mapSize = m_blocksize;
}
else
{
m_mapSize += m_blocksize;
Node newMap[] = new Node[m_mapSize];
System.arraycopy(m_map, 0, newMap, 0, ff + 1);
m_map = newMap;
}
}
m_map[ff] = value;
ff++;
m_firstFree = ff;
|
public final void | pushPair(org.w3c.dom.Node v1, org.w3c.dom.Node v2)Push a pair of nodes into the stack.
Special purpose method for TransformerImpl, pushElemTemplateElement.
Performance critical.
if (null == m_map)
{
m_map = new Node[m_blocksize];
m_mapSize = m_blocksize;
}
else
{
if ((m_firstFree + 2) >= m_mapSize)
{
m_mapSize += m_blocksize;
Node newMap[] = new Node[m_mapSize];
System.arraycopy(m_map, 0, newMap, 0, m_firstFree);
m_map = newMap;
}
}
m_map[m_firstFree] = v1;
m_map[m_firstFree + 1] = v2;
m_firstFree += 2;
|
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 (null == m_map)
return;
for (int i = 0; i < m_firstFree; i++)
{
m_map[i] = null;
}
m_firstFree = 0;
|
public boolean | removeElement(org.w3c.dom.Node 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_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
if (null == m_map)
return false;
for (int i = 0; i < m_firstFree; i++)
{
Node node = m_map[i];
if ((null != node) && node.equals(s))
{
if (i < m_firstFree - 1)
System.arraycopy(m_map, i + 1, m_map, i, m_firstFree - i - 1);
m_firstFree--;
m_map[m_firstFree] = null;
return true;
}
}
return false;
|
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 (null == m_map)
return;
if (i >= m_firstFree)
throw new ArrayIndexOutOfBoundsException(i + " >= " + m_firstFree);
else if (i < 0)
throw new ArrayIndexOutOfBoundsException(i);
if (i < m_firstFree - 1)
System.arraycopy(m_map, i + 1, m_map, i, m_firstFree - i - 1);
m_firstFree--;
m_map[m_firstFree] = null;
|
public void | removeNode(org.w3c.dom.Node n)Remove a node.
if (!m_mutable)
throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESET_NOT_MUTABLE, null)); //"This NodeSet 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, NodeSet 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_NODESET_CANNOT_INDEX, null)); //"This NodeSet 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_NODESET_CANNOT_INDEX, null)); //"This NodeSet can not do indexing or counting functions!");
m_next = i;
|
public void | setElementAt(org.w3c.dom.Node 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_NODESET_NOT_MUTABLE, null)); //"This NodeSet is not mutable!");
if (null == m_map)
{
m_map = new Node[m_blocksize];
m_mapSize = m_blocksize;
}
m_map[index] = node;
|
public void | setLast(int last)
m_last = last;
|
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 final void | setTail(org.w3c.dom.Node n)Set the tail of the stack to the given node.
Special purpose method for TransformerImpl, pushElemTemplateElement.
Performance critical.
m_map[m_firstFree - 1] = n;
|
public final void | setTailSub1(org.w3c.dom.Node n)Set the given node one position from the tail.
Special purpose method for TransformerImpl, pushElemTemplateElement.
Performance critical.
m_map[m_firstFree - 2] = n;
|
public int | size()Get the length of the list.
return m_firstFree;
|