Java Code Examples for com.sun.org.apache.bcel.internal.classfile.ConstantUtf8#getBytes()

The following examples show how to use com.sun.org.apache.bcel.internal.classfile.ConstantUtf8#getBytes() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Bytecoder   File: ClassElementValueGen.java    License: Apache License 2.0 5 votes vote down vote up
public String getClassString()
{
    final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx);
    return cu8.getBytes();
    // ConstantClass c = (ConstantClass)getConstantPool().getConstant(idx);
    // ConstantUtf8 utf8 =
    // (ConstantUtf8)getConstantPool().getConstant(c.getNameIndex());
    // return utf8.getBytes();
}
 
Example 2
Source Project: Bytecoder   File: SimpleElementValueGen.java    License: Apache License 2.0 5 votes vote down vote up
public String getValueString()
{
    if (super.getElementValueType() != STRING) {
        throw new RuntimeException(
                "Dont call getValueString() on a non STRING ElementValue");
    }
    final ConstantUtf8 c = (ConstantUtf8) getConstantPool().getConstant(idx);
    return c.getBytes();
}
 
Example 3
Source Project: Bytecoder   File: SimpleElementValueGen.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String stringifyValue()
{
    switch (super.getElementValueType())
    {
    case PRIMITIVE_INT:
        final ConstantInteger c = (ConstantInteger) getConstantPool().getConstant(idx);
        return Integer.toString(c.getBytes());
    case PRIMITIVE_LONG:
        final ConstantLong j = (ConstantLong) getConstantPool().getConstant(idx);
        return Long.toString(j.getBytes());
    case PRIMITIVE_DOUBLE:
        final ConstantDouble d = (ConstantDouble) getConstantPool().getConstant(idx);
        return Double.toString(d.getBytes());
    case PRIMITIVE_FLOAT:
        final ConstantFloat f = (ConstantFloat) getConstantPool().getConstant(idx);
        return Float.toString(f.getBytes());
    case PRIMITIVE_SHORT:
        final ConstantInteger s = (ConstantInteger) getConstantPool().getConstant(idx);
        return Integer.toString(s.getBytes());
    case PRIMITIVE_BYTE:
        final ConstantInteger b = (ConstantInteger) getConstantPool().getConstant(idx);
        return Integer.toString(b.getBytes());
    case PRIMITIVE_CHAR:
        final ConstantInteger ch = (ConstantInteger) getConstantPool().getConstant(idx);
        return Integer.toString(ch.getBytes());
    case PRIMITIVE_BOOLEAN:
        final ConstantInteger bo = (ConstantInteger) getConstantPool().getConstant(idx);
        if (bo.getBytes() == 0) {
            return "false";
        }
        return "true";
    case STRING:
        final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(idx);
        return cu8.getBytes();
    default:
        throw new RuntimeException(
            "SimpleElementValueGen class does not know how to stringify type " + super.getElementValueType());
    }
}
 
Example 4
Source Project: Bytecoder   File: EnumElementValueGen.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String stringifyValue()
{
    final ConstantUtf8 cu8 = (ConstantUtf8) getConstantPool().getConstant(valueIdx);
    return cu8.getBytes();
    // ConstantString cu8 =
    // (ConstantString)getConstantPool().getConstant(valueIdx);
    // return
    // ((ConstantUtf8)getConstantPool().getConstant(cu8.getStringIndex())).getBytes();
}
 
Example 5
Source Project: Bytecoder   File: AnnotationEntryGen.java    License: Apache License 2.0 4 votes vote down vote up
public final String getTypeSignature() {
    // ConstantClass c = (ConstantClass)cpool.getConstant(typeIndex);
    final ConstantUtf8 utf8 = (ConstantUtf8) cpool
            .getConstant(typeIndex/* c.getNameIndex() */);
    return utf8.getBytes();
}