jellyj.classfile.javaclass
Class Field


public final class Field
implements Constants

This class represents the field info structure, i.e. the representation for a variable in the class. See JVM specification for details.

Author:
JellyJ Design Group

Constructor Summary
 Field()
          Empty constructor, all attributes have to be defined via `setXXX' methods.
 Field(Field c)
          Initialize from another object.
 (package private) Field(DataInputStream file, ConstantPool constant_pool)
          Construct object from file stream.
 Field(int access_flags, int name_index, int signature_index, Attribute[] attributes, ConstantPool constant_pool)
           

Method Summary
 voidaccept(Visitor v)
          Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
 final voiddump(DataOutputStream file)
          Dump field to file stream on binary format.
 final intgetAccessFlags()
           
 final Attribute[]getAttributes()
           
 final ConstantPoolgetConstantPool()
           
 final ConstantValuegetConstantValue()
           
 final StringgetName()
           
 final intgetNameIndex()
           
 final StringgetSignature()
           
 final intgetSignatureIndex()
           
 final voidsetAccessFlags(int access_flags)
           
 final voidsetAttributes(Attribute[] attributes)
           
 final voidsetConstantPool(ConstantPool constant_pool)
           
 final voidsetNameIndex(int name_index)
           
 final voidsetSignatureIndex(int signature_index)
           
 final StringtoString()
          Return string representation close to declaration format, `public static final short MAX = 100', e.g..

Constructor Detail

Field

public Field()
Empty constructor, all attributes have to be defined via `setXXX' methods. Use at your own risk.

Field

public Field(Field c)
Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical copy.

Field

Field(DataInputStream file, ConstantPool constant_pool)
throws java.io.IOException,
java.lang.ClassFormatError
Construct object from file stream.
Parameters:
file - Input stream
throw IOException, ClassFormatError

Field

public Field(int access_flags, int name_index, int signature_index, Attribute[] attributes, ConstantPool constant_pool)
Parameters:
access_flags - Access rights of field
name_index - Points to field name in constant pool
signature_index - Points to encoded signature
attributes - Collection of attributes
constant_pool - Array of constants
Method Detail

accept

public 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 final void dump(DataOutputStream file)
throws java.io.IOException
Dump field to file stream on binary format.
Parameters:
file - Output file stream
throw IOException

getAccessFlags

public final int getAccessFlags()
Returns: Access flags of the class field.

getAttributes

public final Attribute[] getAttributes()
Returns: Collection of field attributes.

getConstantPool

public final ConstantPool getConstantPool()
Returns: Constant pool used by this object.
See Also:
ConstantPool

getConstantValue

public final ConstantValue getConstantValue()
Returns: constant value associated with this field (may be null)

getName

public final String getName()
Returns: Name of field

getNameIndex

public final int getNameIndex()
Returns: Index in constant pool of field name.

getSignature

public final String getSignature()
Returns: String representation of field type signature (java style)

getSignatureIndex

public final int getSignatureIndex()
Returns: Index in constant pool of field signature.

setAccessFlags

public final void setAccessFlags(int access_flags)
Parameters:
access_flags.

setAttributes

public final void setAttributes(Attribute[] attributes)
Parameters:
attributes.

setConstantPool

public final void setConstantPool(ConstantPool constant_pool)
Parameters:
constant_pool - Constant pool to be used for this object.
See Also:
ConstantPool

setNameIndex

public final void setNameIndex(int name_index)
Parameters:
name_index.

setSignatureIndex

public final void setSignatureIndex(int signature_index)
Parameters:
signature_index.

toString

public final String toString()
Return string representation close to declaration format, `public static final short MAX = 100', e.g..
Returns: String representation of field, including the signature.
throw InternalError

Association Links

to Class jellyj.classfile.javaclass.Attribute

to Class jellyj.classfile.javaclass.ConstantPool