📄 keyindex.java
字号:
} // The particular key name identifies no nodes in this document return 0; } /** * <p>Resets the iterator to the last start node.</p> * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is * <b>deprecated.</b></em></p> * @deprecated */ public DTMAxisIterator reset() { _position = 0; return this; } /** * <p>Returns the number of elements in this iterator.</p> * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is * <b>deprecated.</b></em></p> * @deprecated */ public int getLast() { return (_nodes == null) ? 0 : _nodes.cardinality(); } /** * <p>Returns the position of the current node in the set.</p> * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is * <b>deprecated.</b></em></p> * @deprecated */ public int getPosition() { return _position; } /** * <p>Remembers the current node for the next call to gotoMark().</p> * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is * <b>deprecated.</b></em></p> * @deprecated */ public void setMark() { _markedPosition = _position; } /** * <p>Restores the current node remembered by setMark().</p> * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is * <b>deprecated.</b></em></p> * @deprecated */ public void gotoMark() { _position = _markedPosition; } /** * <p>Set start to END should 'close' the iterator, * i.e. subsequent call to next() should return END.</p> * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is * <b>deprecated.</b></em></p> * @deprecated */ public DTMAxisIterator setStartNode(int start) { if (start == DTMAxisIterator.END) { _nodes = null; } else if (_nodes != null) { _position = 0; } return (DTMAxisIterator) this; } /** * <p>Get start to END should 'close' the iterator, * i.e. subsequent call to next() should return END.</p> * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is * <b>deprecated.</b></em></p> * @deprecated */ public int getStartNode() { return 0; } /** * <p>True if this iterator has a reversed axis.</p> * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is * <b>deprecated.</b></em></p> * @deprecated */ public boolean isReverse() { return(false); } /** * <p>Returns a deep copy of this iterator.</p> * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is * <b>deprecated.</b></em></p> * @deprecated */ public DTMAxisIterator cloneIterator() { KeyIndex other = new KeyIndex(0); other._index = _index; other._rootToIndexMap = _rootToIndexMap; other._nodes = _nodes; other._position = _position; return (DTMAxisIterator) other; } public void setDom(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; } } } /** * Create a {@link KeyIndexIterator} that iterates over the nodes that * result from a reference to the XSLT <code>key</code> function or * XPath <code>id</code> function. * * @param keyValue A string or iterator representing the key values or id * references * @param isKeyCall A <code>boolean</code> indicating whether the iterator * is being created for a reference <code>key</code> or * <code>id</code> */ public KeyIndexIterator getKeyIndexIterator(Object keyValue, boolean isKeyCall) { if (keyValue instanceof DTMAxisIterator) { return getKeyIndexIterator((DTMAxisIterator) keyValue, isKeyCall); } else { return getKeyIndexIterator(BasisLibrary.stringF(keyValue, _dom), isKeyCall); } } /** * Create a {@link KeyIndexIterator} that iterates over the nodes that * result from a reference to the XSLT <code>key</code> function or * XPath <code>id</code> function. * * @param keyValue A string representing the key values or id * references * @param isKeyCall A <code>boolean</code> indicating whether the iterator * is being created for a reference <code>key</code> or * <code>id</code> */ public KeyIndexIterator getKeyIndexIterator(String keyValue, boolean isKeyCall) { return new KeyIndexIterator(keyValue, isKeyCall); } /** * Create a {@link KeyIndexIterator} that iterates over the nodes that * result from a reference to the XSLT <code>key</code> function or * XPath <code>id</code> function. * * @param keyValue An iterator representing the key values or id * references * @param isKeyCall A <code>boolean</code> indicating whether the iterator * is being created for a reference <code>key</code> or * <code>id</code> */ public KeyIndexIterator getKeyIndexIterator(DTMAxisIterator keyValue, boolean isKeyCall) { return new KeyIndexIterator(keyValue, isKeyCall); } /** * Used to represent an empty node set. */ final private static IntegerArray EMPTY_NODES = new IntegerArray(0); /** * An iterator representing the result of a reference to either the * XSLT <code>key</code> function or the XPath <code>id</code> function. */ public class KeyIndexIterator extends MultiValuedNodeHeapIterator { /** * <p>A reference to the <code>key</code> function that only has one * key value or to the <code>id</code> function that has only one string * argument can be optimized to ignore the multi-valued heap. This * field will be <code>null</code> otherwise. */ private IntegerArray _nodes; /** * <p>This field contains the iterator representing a node set key value * argument to the <code>key</code> function or a node set argument * to the <code>id</code> function.</p> * * <p>Exactly one of this field and {@link #_keyValue} must be * <code>null</code>.</p> */ private DTMAxisIterator _keyValueIterator; /** * <p>This field contains the iterator representing a non-node-set key * value argument to the <code>key</code> function or a non-node-set * argument to the <code>id</code> function.</p> * * <p>Exactly one of this field and {@link #_keyValueIterator} must be * <code>null</code>.</p> */ private String _keyValue; /** * Indicates whether this object represents the result of a reference * to the <code>key</code> function (<code>true</code>) or the * <code>id</code> function (<code>false</code>). */ private boolean _isKeyIterator; /** * Represents the DTM nodes retrieved for one key value or one string * argument to <code>id</code> for use as one heap node in a * {@link MultiValuedNodeHeapIterator}. */ protected class KeyIndexHeapNode extends MultiValuedNodeHeapIterator.HeapNode { /** * {@link IntegerArray} of DTM nodes retrieved for one key value. * Must contain no duplicates and be stored in document order. */ private IntegerArray _nodes; /** * Position in {@link #_nodes} array of next node to return from * this heap node. */ private int _position = 0; /** * Marked position. Used by {@link #setMark()} and * {@link #gotoMark()} */ private int _markPosition = -1; /** * Create a heap node representing DTM nodes retrieved for one * key value in a reference to the <code>key</code> function * or string argument to the <code>id</code> function. */ KeyIndexHeapNode(IntegerArray nodes) { _nodes = nodes; } /** * Advance to the next node represented by this {@link HeapNode} * * @return the next DTM node. */ public int step() { if (_position < _nodes.cardinality()) { _node = _nodes.at(_position); _position++; } else { _node = DTMAxisIterator.END; } return _node; } /** * Creates a deep copy of this {@link HeapNode}. The clone is not * reset from the current position of the original. * * @return the cloned heap node */ public HeapNode cloneHeapNode() { KeyIndexHeapNode clone = (KeyIndexHeapNode) super.cloneHeapNode(); clone._nodes = _nodes; clone._position = _position; clone._markPosition = _markPosition; return clone; } /** * Remembers the current node for the next call to
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -