org.cojen.classfile
Class FieldInfo

java.lang.Object
  extended by org.cojen.classfile.FieldInfo

public class FieldInfo
extends Object

This class corresponds to the field_info structure as defined in section 4.5 of The Java Virtual Machine Specification.

Author:
Brian S O'Neill
See Also:
ClassFile

Method Summary
 void addAttribute(Attribute attr)
           
 Annotation addRuntimeInvisibleAnnotation(TypeDesc type)
          Add a runtime invisible annotation.
 Annotation addRuntimeVisibleAnnotation(TypeDesc type)
          Add a runtime visible annotation.
 Attribute[] getAttributes()
           
 ClassFile getClassFile()
          Returns the parent ClassFile for this FieldInfo.
 ConstantInfo getConstantValue()
          Returns the constant value for this field or null if no constant set.
 ConstantUTFInfo getDescriptorConstant()
          Returns a constant from the constant pool with this field's type descriptor string.
 int getLength()
          Returns the length (in bytes) of this object in the class file.
 Modifiers getModifiers()
          Returns this field's modifiers.
 String getName()
          Returns the name of this field.
 ConstantUTFInfo getNameConstant()
          Returns a constant from the constant pool with this field's name.
 Annotation[] getRuntimeInvisibleAnnotations()
          Returns all the runtime invisible annotations defined for this class file, or an empty array if none.
 Annotation[] getRuntimeVisibleAnnotations()
          Returns all the runtime visible annotations defined for this class file, or an empty array if none.
 SignatureAttr getSignatureAttr()
          Returns the signature attribute of this field, or null if none is defined.
 TypeDesc getType()
          Returns the type of this field.
 boolean isDeprecated()
           
 boolean isSynthetic()
           
 void markDeprecated()
          Mark this field as being deprecated by adding a special attribute.
 void markSynthetic()
          Mark this field as being synthetic by adding a special attribute.
 void setConstantValue(double value)
          Set the constant value for this field as a double.
 void setConstantValue(float value)
          Set the constant value for this field as a float.
 void setConstantValue(int value)
          Set the constant value for this field as an int.
 void setConstantValue(long value)
          Set the constant value for this field as a long.
 void setConstantValue(String value)
          Set the constant value for this field as a string.
 void setModifiers(Modifiers modifiers)
           
 String toString()
           
 void writeTo(DataOutput dout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getClassFile

public ClassFile getClassFile()
Returns the parent ClassFile for this FieldInfo.


getName

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


getType

public TypeDesc getType()
Returns the type of this field.


getModifiers

public Modifiers getModifiers()
Returns this field's modifiers.


setModifiers

public void setModifiers(Modifiers modifiers)

getNameConstant

public ConstantUTFInfo getNameConstant()
Returns a constant from the constant pool with this field's name.


getDescriptorConstant

public ConstantUTFInfo getDescriptorConstant()
Returns a constant from the constant pool with this field's type descriptor string.

See Also:
TypeDesc

getConstantValue

public ConstantInfo getConstantValue()
Returns the constant value for this field or null if no constant set.


isSynthetic

public boolean isSynthetic()

isDeprecated

public boolean isDeprecated()

getRuntimeInvisibleAnnotations

public Annotation[] getRuntimeInvisibleAnnotations()
Returns all the runtime invisible annotations defined for this class file, or an empty array if none.


getRuntimeVisibleAnnotations

public Annotation[] getRuntimeVisibleAnnotations()
Returns all the runtime visible annotations defined for this class file, or an empty array if none.


addRuntimeInvisibleAnnotation

public Annotation addRuntimeInvisibleAnnotation(TypeDesc type)
Add a runtime invisible annotation.


addRuntimeVisibleAnnotation

public Annotation addRuntimeVisibleAnnotation(TypeDesc type)
Add a runtime visible annotation.


getSignatureAttr

public SignatureAttr getSignatureAttr()
Returns the signature attribute of this field, or null if none is defined.


setConstantValue

public void setConstantValue(int value)
Set the constant value for this field as an int.


setConstantValue

public void setConstantValue(float value)
Set the constant value for this field as a float.


setConstantValue

public void setConstantValue(long value)
Set the constant value for this field as a long.


setConstantValue

public void setConstantValue(double value)
Set the constant value for this field as a double.


setConstantValue

public void setConstantValue(String value)
Set the constant value for this field as a string.


markSynthetic

public void markSynthetic()
Mark this field as being synthetic by adding a special attribute.


markDeprecated

public void markDeprecated()
Mark this field as being deprecated by adding a special attribute.


addAttribute

public void addAttribute(Attribute attr)

getAttributes

public Attribute[] getAttributes()

getLength

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


writeTo

public void writeTo(DataOutput dout)
             throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


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