本文整理汇总了Java中com.sun.org.apache.bcel.internal.Constants.CONSTANT_Long方法的典型用法代码示例。如果您正苦于以下问题:Java Constants.CONSTANT_Long方法的具体用法?Java Constants.CONSTANT_Long怎么用?Java Constants.CONSTANT_Long使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.bcel.internal.Constants
的用法示例。
在下文中一共展示了Constants.CONSTANT_Long方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import com.sun.org.apache.bcel.internal.Constants; //导入方法依赖的package包/类
/**
* @return String representation of constant value.
*/
public final String toString() {
Constant c = constant_pool.getConstant(constantvalue_index);
String buf;
int i;
// Print constant to string depending on its type
switch(c.getTag()) {
case Constants.CONSTANT_Long: buf = "" + ((ConstantLong)c).getBytes(); break;
case Constants.CONSTANT_Float: buf = "" + ((ConstantFloat)c).getBytes(); break;
case Constants.CONSTANT_Double: buf = "" + ((ConstantDouble)c).getBytes(); break;
case Constants.CONSTANT_Integer: buf = "" + ((ConstantInteger)c).getBytes(); break;
case Constants.CONSTANT_String:
i = ((ConstantString)c).getStringIndex();
c = constant_pool.getConstant(i, Constants.CONSTANT_Utf8);
buf = "\"" + Utility.convertString(((ConstantUtf8)c).getBytes()) + "\"";
break;
default:
throw new IllegalStateException("Type of ConstValue invalid: " + c);
}
return buf;
}
示例2: ConstantPool
import com.sun.org.apache.bcel.internal.Constants; //导入方法依赖的package包/类
/**
* Read constants from given file stream.
*
* @param file Input stream
* @throws IOException
* @throws ClassFormatException
*/
ConstantPool(DataInputStream file) throws IOException, ClassFormatException
{
byte tag;
constant_pool_count = file.readUnsignedShort();
constant_pool = new Constant[constant_pool_count];
/* constant_pool[0] is unused by the compiler and may be used freely
* by the implementation.
*/
for(int i=1; i < constant_pool_count; i++) {
constant_pool[i] = Constant.readConstant(file);
/* Quote from the JVM specification:
* "All eight byte constants take up two spots in the constant pool.
* If this is the n'th byte in the constant pool, then the next item
* will be numbered n+2"
*
* Thus we have to increment the index counter.
*/
tag = constant_pool[i].getTag();
if((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long))
i++;
}
}
示例3: readConstant
import com.sun.org.apache.bcel.internal.Constants; //导入方法依赖的package包/类
/**
* Read one constant from the given file, the type depends on a tag byte.
*
* @param file Input stream
* @return Constant object
*/
static final Constant readConstant(DataInputStream file)
throws IOException, ClassFormatException
{
byte b = file.readByte(); // Read tag byte
switch(b) {
case Constants.CONSTANT_Class: return new ConstantClass(file);
case Constants.CONSTANT_Fieldref: return new ConstantFieldref(file);
case Constants.CONSTANT_Methodref: return new ConstantMethodref(file);
case Constants.CONSTANT_InterfaceMethodref: return new
ConstantInterfaceMethodref(file);
case Constants.CONSTANT_String: return new ConstantString(file);
case Constants.CONSTANT_Integer: return new ConstantInteger(file);
case Constants.CONSTANT_Float: return new ConstantFloat(file);
case Constants.CONSTANT_Long: return new ConstantLong(file);
case Constants.CONSTANT_Double: return new ConstantDouble(file);
case Constants.CONSTANT_NameAndType: return new ConstantNameAndType(file);
case Constants.CONSTANT_Utf8: return new ConstantUtf8(file);
default:
throw new ClassFormatException("Invalid byte tag in constant pool: " + b);
}
}
示例4: ConstantLong
import com.sun.org.apache.bcel.internal.Constants; //导入方法依赖的package包/类
/**
* @param bytes Data
*/
public ConstantLong(long bytes)
{
super(Constants.CONSTANT_Long);
this.bytes = bytes;
}
示例5: constantToString
import com.sun.org.apache.bcel.internal.Constants; //导入方法依赖的package包/类
/**
* Resolve constant to a string representation.
*
* @param constant Constant to be printed
* @return String representation
*/
public String constantToString(Constant c)
throws ClassFormatException
{
String str;
int i;
byte tag = c.getTag();
switch(tag) {
case Constants.CONSTANT_Class:
i = ((ConstantClass)c).getNameIndex();
c = getConstant(i, Constants.CONSTANT_Utf8);
str = Utility.compactClassName(((ConstantUtf8)c).getBytes(), false);
break;
case Constants.CONSTANT_String:
i = ((ConstantString)c).getStringIndex();
c = getConstant(i, Constants.CONSTANT_Utf8);
str = "\"" + escape(((ConstantUtf8)c).getBytes()) + "\"";
break;
case Constants.CONSTANT_Utf8: str = ((ConstantUtf8)c).getBytes(); break;
case Constants.CONSTANT_Double: str = "" + ((ConstantDouble)c).getBytes(); break;
case Constants.CONSTANT_Float: str = "" + ((ConstantFloat)c).getBytes(); break;
case Constants.CONSTANT_Long: str = "" + ((ConstantLong)c).getBytes(); break;
case Constants.CONSTANT_Integer: str = "" + ((ConstantInteger)c).getBytes(); break;
case Constants.CONSTANT_NameAndType:
str = (constantToString(((ConstantNameAndType)c).getNameIndex(),
Constants.CONSTANT_Utf8) + " " +
constantToString(((ConstantNameAndType)c).getSignatureIndex(),
Constants.CONSTANT_Utf8));
break;
case Constants.CONSTANT_InterfaceMethodref: case Constants.CONSTANT_Methodref:
case Constants.CONSTANT_Fieldref:
str = (constantToString(((ConstantCP)c).getClassIndex(),
Constants.CONSTANT_Class) + "." +
constantToString(((ConstantCP)c).getNameAndTypeIndex(),
Constants.CONSTANT_NameAndType));
break;
default: // Never reached
throw new RuntimeException("Unknown constant type " + tag);
}
return str;
}