本文整理汇总了Java中scouter.javassist.bytecode.ConstPool.getIntegerInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ConstPool.getIntegerInfo方法的具体用法?Java ConstPool.getIntegerInfo怎么用?Java ConstPool.getIntegerInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scouter.javassist.bytecode.ConstPool
的用法示例。
在下文中一共展示了ConstPool.getIntegerInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConstantValue
import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
/**
* Returns the value of this field if it is a constant field.
* This method works only if the field type is a primitive type
* or <code>String</code> type. Otherwise, it returns <code>null</code>.
* A constant field is <code>static</code> and <code>final</code>.
*
* @return a <code>Integer</code>, <code>Long</code>, <code>Float</code>,
* <code>Double</code>, <code>Boolean</code>,
* or <code>String</code> object
* representing the constant value.
* <code>null</code> if it is not a constant field
* or if the field type is not a primitive type
* or <code>String</code>.
*/
public Object getConstantValue() {
// When this method is modified,
// see also getConstantFieldValue() in TypeChecker.
int index = fieldInfo.getConstantValue();
if (index == 0)
return null;
ConstPool cp = fieldInfo.getConstPool();
switch (cp.getTag(index)) {
case ConstPool.CONST_Long :
return new Long(cp.getLongInfo(index));
case ConstPool.CONST_Float :
return new Float(cp.getFloatInfo(index));
case ConstPool.CONST_Double :
return new Double(cp.getDoubleInfo(index));
case ConstPool.CONST_Integer :
int value = cp.getIntegerInfo(index);
// "Z" means boolean type.
if ("Z".equals(fieldInfo.getDescriptor()))
return new Boolean(value != 0);
else
return new Integer(value);
case ConstPool.CONST_String :
return cp.getStringInfo(index);
default :
throw new RuntimeException("bad tag: " + cp.getTag(index)
+ " at " + index);
}
}