jellyj.classfile.javaclass
Class Attribute

Direct Known Subclasses:
Code, ConstantValue, Deprecated, ExceptionTable, InnerClasses, LineNumberTable, LocalVariableTable, SourceFile, Synthetic, Unknown

public abstract class Attribute
implements Constants

Abstract super class for Attribute objects. Currently the ConstantValue, SourceFile, Code, Exceptiontable, LineNumberTable, LocalVariableTable, InnerClasses and Synthetic attributes are supported. The Unknown attribute stands for non-standard-attributes.

Author:
JellyJ Design Group
See Also: ConstantValue, SourceFile, Code, Unknown, ExceptionTable, LineNumberTable, LocalVariableTable, InnerClasses, Synthetic, Deprecated

Method Summary
 abstract voidaccept(Visitor v)
          Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
 voiddump(DataOutputStream file)
          Dump attribute to file stream in binary format.
 final intgetLength()
           
 final intgetNameIndex()
           
 final bytegetTag()
           
 (package private) final static AttributereadAttribute(DataInputStream file, ConstantPool constant_pool)
           
 final voidsetLength(int length)
           
 final voidsetNameIndex(int name_index)
           

Method Detail

accept

public abstract void accept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
Parameters:
v - Visitor object

dump

public void dump(DataOutputStream file)
throws java.io.IOException
Dump attribute to file stream in binary format.
Parameters:
file - Output file stream
throw IOException

getLength

public final int getLength()
Returns: Length of attribute field in bytes.

getNameIndex

public final int getNameIndex()
Returns: Name index in constant pool of attribute name.

getTag

public final byte getTag()
Returns: Tag of attribute, i.e. its type. Value may not be altered, thus there is no setTag() method.

readAttribute

final static Attribute readAttribute(DataInputStream file, ConstantPool constant_pool)
throws java.io.IOException,
java.lang.ClassFormatError,
java.lang.InternalError

setLength

public final void setLength(int length)
Parameters:
Attribute - length in bytes.

setNameIndex

public final void setNameIndex(int name_index)
Parameters:
name_index - of attribute.