FileDocCategorySizeDatePackage
ConstantValueAttribute_info.javaAPI DocAndroid 1.5 API4597Wed May 06 22:41:16 BST 2009com.vladium.jcd.cls.attribute

ConstantValueAttribute_info

public final class ConstantValueAttribute_info extends Attribute_info
The ConstantValue attribute is a fixed-length attribute used in the attributes table of the {@link com.vladium.jcd.cls.Field_info} structures. A ConstantValue attribute represents the value of a constant field that must be (explicitly or implicitly) static; that is, the ACC_STATIC bit in the flags item of the Field_info structure must be set. The field is not required to be final. There can be no more than one ConstantValue attribute in the attributes table of a given Field_info structure. The constant field represented by the Field_info structure is assigned the value referenced by its ConstantValue attribute as part of its initialization.

The ConstantValue attribute has the format

ConstantValue_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 constantvalue_index;
}
The value of the constantvalue_index item must be a valid index into the constant pool table. The constant pool entry at that index must give the constant value represented by this attribute.

The constant pool entry must be of a type appropriate to the field, as shown below:
Field Type Entry Type
long CONSTANT_Long
float CONSTANT_Float
double CONSTANT_Double
int, short, char, byte, boolean CONSTANT_Integer
java.lang.String CONSTANT_String

author
(C) 2001, Vlad Roubtsov

Fields Summary
public int
m_value_index
private static final boolean
DEBUG
Constructors Summary
public ConstantValueAttribute_info(int attribute_name_index, int value_index)

        super (attribute_name_index, 2);
        
        m_value_index = value_index;
    
ConstantValueAttribute_info(int attribute_name_index, long attribute_length, com.vladium.jcd.lib.UDataInputStream bytes)

        super (attribute_name_index, attribute_length);
        
        m_value_index = bytes.readU2 ();
        if (DEBUG) System.out.println ("\tconstantvalue_index: " + m_value_index);
    
Methods Summary
public voidaccept(IAttributeVisitor visitor, java.lang.Object ctx)

        visitor.visit (this, ctx);
    
public java.lang.Objectclone()
Performs a deep copy.

        
        return super.clone ();    
    
public com.vladium.jcd.cls.constant.CONSTANT_literal_infogetValue(com.vladium.jcd.cls.ClassDef cls)

        return (CONSTANT_literal_info) cls.getConstants ().get (m_value_index);
    
public longlength()

        return 8;
    
public java.lang.StringtoString()

        // TODO: return more data here
        return "ConstantValueAttribute_info: [attribute_name_index = " + m_name_index + ", attribute_length = " + m_attribute_length + ']";
    
    
public voidwriteInClassFormat(com.vladium.jcd.lib.UDataOutputStream out)

        super.writeInClassFormat (out);
        
        out.writeU2 (m_value_index);