@Override
public String toString() {
StringBuilder s = new StringBuilder();
switch (type) {
case PRIMITIVE_INT:
ConstantInteger c = (ConstantInteger) cpool.getConstant(idx);
s.append("(int)").append(Integer.toString(c.getValue()));
break;
case PRIMITIVE_LONG:
ConstantLong j = (ConstantLong) cpool.getConstant(idx);
s.append("(long)").append(Long.toString(j.getValue()));
break;
case PRIMITIVE_DOUBLE:
ConstantDouble d = (ConstantDouble) cpool.getConstant(idx);
s.append("(double)").append(d.getValue().toString());
break;
case PRIMITIVE_FLOAT:
ConstantFloat f = (ConstantFloat) cpool.getConstant(idx);
s.append("(float)").append(Float.toString(f.getValue()));
break;
case PRIMITIVE_SHORT:
ConstantInteger ci = (ConstantInteger) cpool.getConstant(idx);
s.append("(short)").append(Integer.toString(ci.getValue()));
break;
case PRIMITIVE_BYTE:
ConstantInteger b = (ConstantInteger) cpool.getConstant(idx);
s.append("(byte)").append(Integer.toString(b.getValue()));
break;
case PRIMITIVE_CHAR:
ConstantInteger ch = (ConstantInteger) cpool.getConstant(idx);
s.append("(char)").append(new Character((char) ch.getIntValue()).toString());
break;
case PRIMITIVE_BOOLEAN:
ConstantInteger bo = (ConstantInteger) cpool.getConstant(idx);
s.append("(boolean)");
if (bo.getValue() == 0) {
s.append("false");
} else {
s.append("true");
}
break;