本文整理汇总了Java中com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType.distanceTo方法的典型用法代码示例。如果您正苦于以下问题:Java MethodType.distanceTo方法的具体用法?Java MethodType.distanceTo怎么用?Java MethodType.distanceTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType
的用法示例。
在下文中一共展示了MethodType.distanceTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookupPrimop
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType; //导入方法依赖的package包/类
/**
* Search for a primop in the symbol table that matches the method type
* <code>ctype</code>. Two methods match if they have the same arity.
* If a primop is overloaded then the "closest match" is returned. The
* first entry in the vector of primops that has the right arity is
* considered to be the default one.
*/
public MethodType lookupPrimop(SymbolTable stable, String op,
MethodType ctype) {
MethodType result = null;
final Vector primop = stable.lookupPrimop(op);
if (primop != null) {
final int n = primop.size();
int minDistance = Integer.MAX_VALUE;
for (int i = 0; i < n; i++) {
final MethodType ptype = (MethodType) primop.elementAt(i);
// Skip if different arity
if (ptype.argsCount() != ctype.argsCount()) {
continue;
}
// The first method with the right arity is the default
if (result == null) {
result = ptype; // default method
}
// Check if better than last one found
final int distance = ctype.distanceTo(ptype);
if (distance < minDistance) {
minDistance = distance;
result = ptype;
}
}
}
return result;
}