java ge_Java IFGE类代码示例

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());

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值