Class FieldInfo

java.lang.Object
org.fife.rsta.ac.java.classreader.MemberInfo
org.fife.rsta.ac.java.classreader.FieldInfo

public class FieldInfo extends MemberInfo
Represents a "field_info" structure as defined by the Java VM spec.
Version:
1.0
  • Field Details

    • nameIndex

      private int nameIndex
      Index into the constant pool of a ConstantUtf8Info structure representing the field name, as a simple name.
    • descriptorIndex

      private int descriptorIndex
      Index into the constant pool of a ConstantUtf8Info structure representing a valid field descriptor.
    • attributes

      private List<AttributeInfo> attributes
      An array of attributes of this field.
    • CONSTANT_VALUE

      public static final String CONSTANT_VALUE
      See Also:
  • Constructor Details

    • FieldInfo

      public FieldInfo(ClassFile cf, int accessFlags, int nameIndex, int descriptorIndex)
      Constructor.
      Parameters:
      cf - The class file being parsed.
      accessFlags - The access flags.
      nameIndex - The name index.
      descriptorIndex - The descriptor index.
      See Also:
  • Method Details

    • addAttribute

      public void addAttribute(AttributeInfo info)
      Adds the specified attribute to this field.
      Parameters:
      info - Information about the attribute.
    • getAttribute

      public AttributeInfo getAttribute(int index)
      Returns the specified attribute.
      Parameters:
      index - The index of the attribute.
      Returns:
      The attribute.
    • getAttributeCount

      public int getAttributeCount()
      Returns the number of attributes of this field.
      Returns:
      The number of attributes.
    • getConstantValueAsString

      public String getConstantValueAsString()
      Returns this constant value as a string.
      Returns:
      A string representation of this constant value, or null if it isn't one.
    • getConstantValueAttributeInfo

      private ConstantValue getConstantValueAttributeInfo()
      Returns the ConstantValue attribute info for this field, if any.
      Returns:
      The ConstantValue attribute, or null if there isn't one.
    • getDescriptor

      public String getDescriptor()
      Returns the field descriptor of this field.
      Specified by:
      getDescriptor in class MemberInfo
      Returns:
      The field descriptor of this field.
    • getName

      public String getName()
      Description copied from class: MemberInfo
      Returns the name of this member.
      Specified by:
      getName in class MemberInfo
      Returns:
      The name of this member.
    • getNameIndex

      public int getNameIndex()
      Returns the index into the constant pool of a ConstantUtf8Info structure representing the field name, as a simple name.
      Returns:
      The index into the constant pool.
    • getTypeString

      public String getTypeString(boolean qualified)
      Returns the type of this field, as determined from its field descriptor.
      Parameters:
      qualified - Whether the returned value should be fully-qualified.
      Returns:
      The type of this field.
    • isConstant

      public boolean isConstant()
      Returns whether this field is a constant.
      Returns:
      Whether this field is a constant.
    • read

      public static FieldInfo read(ClassFile cf, DataInputStream in) throws IOException
      Reads a FieldInfo structure from the specified input stream.
      Parameters:
      cf - The class file containing this field.
      in - The input stream to read from.
      Returns:
      The field information read.
      Throws:
      IOException - If an IO error occurs.
    • readAttribute

      private AttributeInfo readAttribute(DataInputStream in) throws IOException
      Reads an attribute for this field from an input stream.
      Parameters:
      in - The input stream to read from.
      Returns:
      The attribute read, possibly null if it was known to be unimportant for our purposes.
      Throws:
      IOException - If an IO error occurs.