/** * Merge the current value's nodeset set by lookupKey() with _nodes. * * @deprecated */ public void merge(KeyIndex other) { if (other == null) return; if (other._nodes != null) { if (_nodes == null) { _nodes = (IntegerArray) other._nodes.clone(); } else { _nodes.merge(other._nodes); } } }
/** * Retrieve nodes for a particular key value or a particular id argument value. * * @param root The root node of the document containing the context node * @param keyValue The key value of id string argument value * @return an {@link IntegerArray} of the resulting nodes */ protected IntegerArray lookupNodes(int root, String keyValue) { IntegerArray result = null; // Get mapping from key values/IDs to DTM nodes for this document Hashtable index = (Hashtable) _rootToIndexMap.get(new Integer(root)); if (!_isKeyIterator) { // For id function, tokenize argument as whitespace separated // list of values and look up nodes identified by each ID. final StringTokenizer values = new StringTokenizer(keyValue, " \n\t"); while (values.hasMoreElements()) { final String token = (String) values.nextElement(); IntegerArray nodes = null; // Does the ID map to any node in the document? 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); } // If we found any nodes, merge them into the cumulative // result if (nodes != null) { if (result == null) { result = (IntegerArray) nodes.clone(); } else { result.merge(nodes); } } } } else if (index != null) { // For key function, map key value to nodes result = (IntegerArray) index.get(keyValue); } return result; }
/** * 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. * * @deprecated */ public void lookupId(Object value) { // 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); } } }