Java Code Examples for org.apache.bcel.Const#ATTR_CONSTANT_VALUE

The following examples show how to use org.apache.bcel.Const#ATTR_CONSTANT_VALUE . 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: Field.java    From commons-bcel with Apache License 2.0 5 votes vote down vote up
/**
 * @return constant value associated with this field (may be null)
 */
public ConstantValue getConstantValue() {
    for (final Attribute attribute : super.getAttributes()) {
        if (attribute.getTag() == Const.ATTR_CONSTANT_VALUE) {
            return (ConstantValue) attribute;
        }
    }
    return null;
}
 
Example 3
Source File: ConstantValue.java    From commons-bcel with Apache License 2.0 2 votes vote down vote up
/**
 * @param name_index Name index in constant pool
 * @param length Content length in bytes
 * @param constantValueIndex Index in constant pool
 * @param constant_pool Array of constants
 */
public ConstantValue(final int name_index, final int length, final int constantValueIndex,
        final ConstantPool constant_pool) {
    super(Const.ATTR_CONSTANT_VALUE, name_index, length, constant_pool);
    this.constantValueIndex = constantValueIndex;
}