Java Code Examples for org.apache.bcel.classfile.Utility#signatureToString()

The following examples show how to use org.apache.bcel.classfile.Utility#signatureToString() . 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 File: MethodHTML.java    From commons-bcel with Apache License 2.0 6 votes vote down vote up
/**
 * Print field of class.
 *
 * @param field field to print
 * @throws java.io.IOException
 */
private void writeField( final Field field ) throws IOException {
    final String type = Utility.signatureToString(field.getSignature());
    final String name = field.getName();
    String access = Utility.accessToString(field.getAccessFlags());
    Attribute[] attributes;
    access = Utility.replace(access, " ", " ");
    file.print("<TR><TD><FONT COLOR=\"#FF0000\">" + access + "</FONT></TD>\n<TD>"
            + Class2HTML.referenceType(type) + "</TD><TD><A NAME=\"field" + name + "\">" + name
            + "</A></TD>");
    attributes = field.getAttributes();
    // Write them to the Attributes.html file with anchor "<name>[<i>]"
    for (int i = 0; i < attributes.length; i++) {
        attribute_html.writeAttribute(attributes[i], name + "@" + i);
    }
    for (int i = 0; i < attributes.length; i++) {
        if (attributes[i].getTag() == Const.ATTR_CONSTANT_VALUE) { // Default value
            final String str = ((ConstantValue) attributes[i]).toString();
            // Reference attribute in _attributes.html
            file.print("<TD>= <A HREF=\"" + className + "_attributes.html#" + name + "@" + i
                    + "\" TARGET=\"Attributes\">" + str + "</TD>\n");
            break;
        }
    }
    file.println("</TR>");
}
 
Example 2
Source File: BCELifier.java    From commons-bcel with Apache License 2.0 6 votes vote down vote up
static String printType( final String signature ) {
    final Type type = Type.getType(signature);
    final byte t = type.getType();
    if (t <= Const.T_VOID) {
        return "Type." + Const.getTypeName(t).toUpperCase(Locale.ENGLISH);
    } else if (type.toString().equals("java.lang.String")) {
        return "Type.STRING";
    } else if (type.toString().equals("java.lang.Object")) {
        return "Type.OBJECT";
    } else if (type.toString().equals("java.lang.StringBuffer")) {
        return "Type.STRINGBUFFER";
    } else if (type instanceof ArrayType) {
        final ArrayType at = (ArrayType) type;
        return "new ArrayType(" + printType(at.getBasicType()) + ", " + at.getDimensions()
                + ")";
    } else {
        return "new ObjectType(\"" + Utility.signatureToString(signature, false) + "\")";
    }
}
 
Example 3
Source File: Type.java    From commons-bcel with Apache License 2.0 4 votes vote down vote up
/**
 * @return Type string, e.g. `int[]'
 */
@Override
public String toString() {
    return ((this.equals(Type.NULL) || (type >= Const.T_UNKNOWN))) ? signature : Utility
            .signatureToString(signature, false);
}