import com.sun.org.apache.bcel.internal.generic.IFGE; //导入依赖的package包/类
/**
* This method is called if the "use" attribute of the key contains a
* node set. In this case we must traverse all nodes in the set and
* create one entry in this key's index for each node in the set.
*/
public void traverseNodeSet(ClassGenerator classGen,
MethodGenerator methodGen,
int buildKeyIndex) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
// DOM.getStringValueX(nodeIndex) => String
final int getNodeValue = cpg.addInterfaceMethodref(DOM_INTF,
GET_NODE_VALUE,
"(I)"+STRING_SIG);
final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF,
"getNodeIdent",
"(I)"+NODE_SIG);
// AbstractTranslet.SetKeyIndexDom(name, Dom) => void
final int keyDom = cpg.addMethodref(TRANSLET_CLASS,
"setKeyIndexDom",
"("+STRING_SIG+DOM_INTF_SIG+")V");
// This variable holds the id of the node we found with the "match"
// attribute of xsl:key. This is the id we store, with the value we
// get from the nodes we find here, in the index for this key.
final LocalVariableGen parentNode =
methodGen.addLocalVariable("parentNode",
Util.getJCRefType("I"),
null, null);
// Get the 'parameter' from the stack and store it in a local var.
parentNode.setStart(il.append(new ISTORE(parentNode.getIndex())));
// Save current node and current iterator on the stack
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadIterator());
// Overwrite current iterator with one that gives us only what we want
_use.translate(classGen, methodGen);
_use.startIterator(classGen, methodGen);
il.append(methodGen.storeIterator());
final BranchHandle nextNode = il.append(new GOTO(null));
final InstructionHandle loop = il.append(NOP);
// Prepare to call buildKeyIndex(String name, int node, String value);
il.append(classGen.loadTranslet());
il.append(new PUSH(cpg, _name.toString()));
parentNode.setEnd(il.append(new ILOAD(parentNode.getIndex())));
// Now get the node value and push it on the parameter stack
il.append(methodGen.loadDOM());
il.append(methodGen.loadCurrentNode());
il.append(new INVOKEINTERFACE(getNodeValue, 2));
// Finally do the call to add an entry in the index for this key.
il.append(new INVOKEVIRTUAL(buildKeyIndex));
il.append(classGen.loadTranslet());
il.append(new PUSH(cpg, getName()));
il.append(methodGen.loadDOM());
il.append(new INVOKEVIRTUAL(keyDom));
nextNode.setTarget(il.append(methodGen.loadIterator()));
il.append(methodGen.nextNode());
il.append(DUP);
il.append(methodGen.storeCurrentNode());
il.append(new IFGE(loop)); // Go on to next matching node....
// Restore current node and current iterator from the stack
il.append(methodGen.storeIterator());
il.append(methodGen.storeCurrentNode());
}