Fields Summary |
---|
private com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable | _indexA mapping between values and nodesets for the current document. Used
only while building keys. |
private int | _currentDocumentNodeThe document node currently being processed. Used only while building
keys. |
private com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable | _rootToIndexMapA mapping from a document node to the mapping between values and nodesets |
private IntegerArray | _nodesThe node set associated to the current value passed
to lookupKey(); |
private DOM | _domThe XSLTC DOM object if this KeyIndex is being used to implement the
id() function. |
private DOMEnhancedForDTM | _enhancedDOM |
private int | _markedPositionStore position after call to setMark() |
private static final IntegerArray | EMPTY_NODESUsed to represent an empty node set. |
Methods Summary |
---|
public void | add(java.lang.Object value, int node, int rootNode)Adds a node to the node list for a given value. Nodes will
always be added in document order.
if (_currentDocumentNode != rootNode) {
_currentDocumentNode = rootNode;
_index = new Hashtable();
_rootToIndexMap.put(new Integer(rootNode), _index);
}
IntegerArray nodes = (IntegerArray) _index.get(value);
if (nodes == null) {
nodes = new IntegerArray();
_index.put(value, nodes);
nodes.add(node);
// Because nodes are added in document order,
// duplicates can be eliminated easily at this stage.
} else if (node != nodes.at(nodes.cardinality() - 1)) {
nodes.add(node);
}
|
public com.sun.org.apache.xml.internal.dtm.DTMAxisIterator | cloneIterator()Returns a deep copy of this iterator.
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
KeyIndex other = new KeyIndex(0);
other._index = _index;
other._rootToIndexMap = _rootToIndexMap;
other._nodes = _nodes;
other._position = _position;
return (DTMAxisIterator) other;
|
public int | containsID(int node, java.lang.Object value)Given a context node and the argument to the XPath id
function, checks whether the context node is in the set of nodes that
results from that reference to the id function. This is
used in the implementation of id patterns.
final String string = (String)value;
int rootHandle = _dom.getAxisIterator(Axis.ROOT)
.setStartNode(node).next();
// Get the mapping table for the document containing the context node
Hashtable index =
(Hashtable) _rootToIndexMap.get(new Integer(rootHandle));
// Split argument to id function into XML whitespace separated tokens
final StringTokenizer values = new StringTokenizer(string, " \n\t");
while (values.hasMoreElements()) {
final String token = (String) values.nextElement();
IntegerArray nodes = null;
if (index != null) {
nodes = (IntegerArray) index.get(token);
}
// If input was from W3C DOM, use DOM's getElementById to do
// the look-up.
if (nodes == null && _enhancedDOM != null
&& _enhancedDOM.hasDOMSource()) {
nodes = getDOMNodeById(token);
}
// Did we find the context node in the set of nodes?
if (nodes != null && nodes.indexOf(node) >= 0) {
return 1;
}
}
// Didn't find the context node in the set of nodes returned by id
return 0;
|
public int | containsKey(int node, java.lang.Object value)Given a context node and the second argument to the XSLT
key function, checks whether the context node is in the
set of nodes that results from that reference to the key
function. This is used in the implementation of key patterns.
This particular {@link KeyIndex} object is the result evaluating the
first argument to the key function, so it's not taken into
any further account.
int rootHandle = _dom.getAxisIterator(Axis.ROOT)
.setStartNode(node).next();
// Get the mapping table for the document containing the context node
Hashtable index =
(Hashtable) _rootToIndexMap.get(new Integer(rootHandle));
// Check whether the context node is present in the set of nodes
// returned by the key function
if (index != null) {
final IntegerArray nodes = (IntegerArray) index.get(value);
return (nodes != null && nodes.indexOf(node) >= 0) ? 1 : 0;
}
// The particular key name identifies no nodes in this document
return 0;
|
public com.sun.org.apache.xalan.internal.xsltc.util.IntegerArray | getDOMNodeById(java.lang.String id)Return an IntegerArray for the DOM Node which has the given id.
IntegerArray nodes = null;
if (_enhancedDOM != null) {
int ident = _enhancedDOM.getElementById(id);
if (ident != DTM.NULL) {
Integer root = new Integer(_enhancedDOM.getDocument());
Hashtable index = (Hashtable) _rootToIndexMap.get(root);
if (index == null) {
index = new Hashtable();
_rootToIndexMap.put(root, index);
} else {
nodes = (IntegerArray) index.get(id);
}
if (nodes == null) {
nodes = new IntegerArray();
index.put(id, nodes);
}
nodes.add(_enhancedDOM.getNodeHandle(ident));
}
}
return nodes;
|
public com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex$KeyIndexIterator | getKeyIndexIterator(java.lang.Object keyValue, boolean isKeyCall)Create a {@link KeyIndexIterator} that iterates over the nodes that
result from a reference to the XSLT key function or
XPath id function.
if (keyValue instanceof DTMAxisIterator) {
return getKeyIndexIterator((DTMAxisIterator) keyValue, isKeyCall);
} else {
return getKeyIndexIterator(BasisLibrary.stringF(keyValue, _dom),
isKeyCall);
}
|
public com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex$KeyIndexIterator | getKeyIndexIterator(java.lang.String keyValue, boolean isKeyCall)Create a {@link KeyIndexIterator} that iterates over the nodes that
result from a reference to the XSLT key function or
XPath id function.
return new KeyIndexIterator(keyValue, isKeyCall);
|
public com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex$KeyIndexIterator | getKeyIndexIterator(com.sun.org.apache.xml.internal.dtm.DTMAxisIterator keyValue, boolean isKeyCall)Create a {@link KeyIndexIterator} that iterates over the nodes that
result from a reference to the XSLT key function or
XPath id function.
return new KeyIndexIterator(keyValue, isKeyCall);
|
public int | getLast()Returns the number of elements in this iterator.
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
return (_nodes == null) ? 0 : _nodes.cardinality();
|
public int | getPosition()Returns the position of the current node in the set.
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
return _position;
|
public int | getStartNode()Get start to END should 'close' the iterator,
i.e. subsequent call to next() should return END.
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
return 0;
|
public void | gotoMark()Restores the current node remembered by setMark().
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
_position = _markedPosition;
|
public boolean | isReverse()True if this iterator has a reversed axis.
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
return(false);
|
public void | lookupId(java.lang.Object value)This method must be called by the code generated by the id() function
prior to returning the node iterator. The lookup code for key() and
id() differ in the way the lookup value can be whitespace separated
list of tokens for the id() function, but a single string for the
key() function.
// Clear _nodes array
_nodes = null;
final StringTokenizer values = new StringTokenizer((String) value,
" \n\t");
while (values.hasMoreElements()) {
final String token = (String) values.nextElement();
IntegerArray nodes = (IntegerArray) _index.get(token);
if (nodes == null && _enhancedDOM != null
&& _enhancedDOM.hasDOMSource()) {
nodes = getDOMNodeById(token);
}
if (nodes == null) continue;
if (_nodes == null) {
nodes = (IntegerArray)nodes.clone();
_nodes = nodes;
}
else {
_nodes.merge(nodes);
}
}
|
public void | lookupKey(java.lang.Object value)This method must be called by the code generated by the key() function
prior to returning the node iterator.
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
IntegerArray nodes = (IntegerArray) _index.get(value);
_nodes = (nodes != null) ? (IntegerArray) nodes.clone() : null;
_position = 0;
|
public void | merge(com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex other)Merge the current value's nodeset set by lookupKey() with _nodes.
if (other == null) return;
if (other._nodes != null) {
if (_nodes == null) {
_nodes = (IntegerArray)other._nodes.clone();
}
else {
_nodes.merge(other._nodes);
}
}
|
public int | next()Callers should not call next() after it returns END.
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
if (_nodes == null) return DTMAxisIterator.END;
return (_position < _nodes.cardinality()) ?
_dom.getNodeHandle(_nodes.at(_position++)) : DTMAxisIterator.END;
|
public com.sun.org.apache.xml.internal.dtm.DTMAxisIterator | reset()Resets the iterator to the last start node.
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
_position = 0;
return this;
|
public void | setDom(com.sun.org.apache.xalan.internal.xsltc.DOM dom, int node)
// If a multi DOM, then select the appropriate dom
if (dom instanceof MultiDOM) {
dom = ((MultiDOM) dom).getDTM(node);
}
_dom = dom;
_enhancedDOM = null; // reset
if (dom instanceof DOMEnhancedForDTM) {
_enhancedDOM = (DOMEnhancedForDTM)dom;
}
else if (dom instanceof DOMAdapter) {
DOM idom = ((DOMAdapter)dom).getDOMImpl();
if (idom instanceof DOMEnhancedForDTM) {
_enhancedDOM = (DOMEnhancedForDTM)idom;
}
}
|
public void | setMark()Remembers the current node for the next call to gotoMark().
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
_markedPosition = _position;
|
public void | setRestartable(boolean flag)
|
public com.sun.org.apache.xml.internal.dtm.DTMAxisIterator | setStartNode(int start)Set start to END should 'close' the iterator,
i.e. subsequent call to next() should return END.
Use of an instance of this class as a {@link DTMAxisIterator} is
deprecated.
if (start == DTMAxisIterator.END) {
_nodes = null;
}
else if (_nodes != null) {
_position = 0;
}
return (DTMAxisIterator) this;
|