org.cojen.classfile
Class Attribute

java.lang.Object
  extended by org.cojen.classfile.Attribute
Direct Known Subclasses:
AnnotationsAttr, CodeAttr, ConstantValueAttr, DeprecatedAttr, EnclosingMethodAttr, ExceptionsAttr, InnerClassesAttr, LineNumberTableAttr, LocalVariableTableAttr, ParameterAnnotationsAttr, SignatureAttr, SourceFileAttr, SyntheticAttr, UnknownAttr

public abstract class Attribute
extends Object

This class corresponds to the attribute_info structure defined in section 4.7 of The Java Virtual Machine Specification.

Author:
Brian S O'Neill
See Also:
ClassFile

Field Summary
static String CODE
           
static String CONSTANT_VALUE
           
static String DEPRECATED
           
static String ENCLOSING_METHOD
           
static String EXCEPTIONS
           
static String INNER_CLASSES
           
static String LINE_NUMBER_TABLE
           
static String LOCAL_VARIABLE_TABLE
           
static String RUNTIME_INVISIBLE_ANNOTATIONS
           
static String RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS
           
static String RUNTIME_VISIBLE_ANNOTATIONS
           
static String RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS
           
static String SIGNATURE
           
static String SOURCE_FILE
           
static String SYNTHETIC
           
 
Constructor Summary
protected Attribute(ConstantPool cp, String name)
           
 
Method Summary
 Attribute[] getAttributes()
          Some attributes have sub-attributes.
 ConstantPool getConstantPool()
          Returns the ConstantPool that this attribute is defined against.
abstract  int getLength()
          Returns the length (in bytes) of this attribute in the class file.
 String getName()
          Returns the name of this attribute.
 ConstantUTFInfo getNameConstant()
           
static Attribute readFrom(ConstantPool cp, DataInput din, AttributeFactory attrFactory)
           
 void writeDataTo(DataOutput dout)
          Write just the attribute specific data.
 void writeTo(DataOutput dout)
          This method writes the 16 bit name constant index followed by the 32 bit attribute length, followed by the attribute specific data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CODE

public static final String CODE
See Also:
Constant Field Values

CONSTANT_VALUE

public static final String CONSTANT_VALUE
See Also:
Constant Field Values

DEPRECATED

public static final String DEPRECATED
See Also:
Constant Field Values

EXCEPTIONS

public static final String EXCEPTIONS
See Also:
Constant Field Values

INNER_CLASSES

public static final String INNER_CLASSES
See Also:
Constant Field Values

LINE_NUMBER_TABLE

public static final String LINE_NUMBER_TABLE
See Also:
Constant Field Values

LOCAL_VARIABLE_TABLE

public static final String LOCAL_VARIABLE_TABLE
See Also:
Constant Field Values

SOURCE_FILE

public static final String SOURCE_FILE
See Also:
Constant Field Values

SYNTHETIC

public static final String SYNTHETIC
See Also:
Constant Field Values

SIGNATURE

public static final String SIGNATURE
See Also:
Constant Field Values

ENCLOSING_METHOD

public static final String ENCLOSING_METHOD
See Also:
Constant Field Values

RUNTIME_VISIBLE_ANNOTATIONS

public static final String RUNTIME_VISIBLE_ANNOTATIONS
See Also:
Constant Field Values

RUNTIME_INVISIBLE_ANNOTATIONS

public static final String RUNTIME_INVISIBLE_ANNOTATIONS
See Also:
Constant Field Values

RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS

public static final String RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS
See Also:
Constant Field Values

RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS

public static final String RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS
See Also:
Constant Field Values
Constructor Detail

Attribute

protected Attribute(ConstantPool cp,
                    String name)
Method Detail

getConstantPool

public ConstantPool getConstantPool()
Returns the ConstantPool that this attribute is defined against.


getName

public String getName()
Returns the name of this attribute.


getNameConstant

public ConstantUTFInfo getNameConstant()

getAttributes

public Attribute[] getAttributes()
Some attributes have sub-attributes. Default implementation returns an empty array.


getLength

public abstract int getLength()
Returns the length (in bytes) of this attribute in the class file.


writeTo

public final void writeTo(DataOutput dout)
                   throws IOException
This method writes the 16 bit name constant index followed by the 32 bit attribute length, followed by the attribute specific data.

Throws:
IOException

writeDataTo

public void writeDataTo(DataOutput dout)
                 throws IOException
Write just the attribute specific data. The default implementation writes nothing.

Throws:
IOException

readFrom

public static Attribute readFrom(ConstantPool cp,
                                 DataInput din,
                                 AttributeFactory attrFactory)
                          throws IOException
Parameters:
attrFactory - optional factory for reading custom attributes
Throws:
IOException


Copyright © 2004-2011 Brian S O'Neill. All Rights Reserved.