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 Summary
Fields Modifier and Type Field Description private java.util.List<AttributeInfo>attributesAn array of attributes of this field.static java.lang.StringCONSTANT_VALUEprivate intdescriptorIndexIndex into the constant pool of aConstantUtf8Infostructure representing a valid field descriptor.private intnameIndexIndex into the constant pool of aConstantUtf8Infostructure representing the field name, as a simple name.-
Fields inherited from class org.fife.rsta.ac.java.classreader.MemberInfo
cf, DEPRECATED, RUNTIME_VISIBLE_ANNOTATIONS, SIGNATURE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(AttributeInfo info)Adds the specified attribute to this field.AttributeInfogetAttribute(int index)Returns the specified attribute.intgetAttributeCount()Returns the number of attributes of this field.java.lang.StringgetConstantValueAsString()Returns this constant value as a string.private ConstantValuegetConstantValueAttributeInfo()Returns theConstantValueattribute info for this field, if any.java.lang.StringgetDescriptor()Returns the field descriptor of this field.java.lang.StringgetName()Returns the name of this member.intgetNameIndex()Returns the index into the constant pool of aConstantUtf8Infostructure representing the field name, as a simple name.java.lang.StringgetTypeString(boolean qualified)Returns the type of this field, as determined from its field descriptor.booleanisConstant()Returns whether this field is a constant.static FieldInforead(ClassFile cf, java.io.DataInputStream in)Reads aFieldInfostructure from the specified input stream.private AttributeInforeadAttribute(java.io.DataInputStream in)Reads an attribute for this field from an input stream.-
Methods inherited from class org.fife.rsta.ac.java.classreader.MemberInfo
getAccessFlags, getClassFile, isDeprecated, isFinal, isStatic, readAttribute
-
-
-
-
Field Detail
-
nameIndex
private int nameIndex
Index into the constant pool of aConstantUtf8Infostructure representing the field name, as a simple name.
-
descriptorIndex
private int descriptorIndex
Index into the constant pool of aConstantUtf8Infostructure representing a valid field descriptor.
-
attributes
private java.util.List<AttributeInfo> attributes
An array of attributes of this field.
-
CONSTANT_VALUE
public static final java.lang.String CONSTANT_VALUE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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:
AccessFlags
-
-
Method Detail
-
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 java.lang.String getConstantValueAsString()
Returns this constant value as a string.- Returns:
- A string representation of this constant value, or
nullif it isn't one.
-
getConstantValueAttributeInfo
private ConstantValue getConstantValueAttributeInfo()
Returns theConstantValueattribute info for this field, if any.- Returns:
- The
ConstantValueattribute, ornullif there isn't one.
-
getDescriptor
public java.lang.String getDescriptor()
Returns the field descriptor of this field.- Specified by:
getDescriptorin classMemberInfo- Returns:
- The field descriptor of this field.
-
getName
public java.lang.String getName()
Description copied from class:MemberInfoReturns the name of this member.- Specified by:
getNamein classMemberInfo- Returns:
- The name of this member.
-
getNameIndex
public int getNameIndex()
Returns the index into the constant pool of aConstantUtf8Infostructure representing the field name, as a simple name.- Returns:
- The index into the constant pool.
-
getTypeString
public java.lang.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, java.io.DataInputStream in) throws java.io.IOException
Reads aFieldInfostructure 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:
java.io.IOException- If an IO error occurs.
-
readAttribute
private AttributeInfo readAttribute(java.io.DataInputStream in) throws java.io.IOException
Reads an attribute for this field from an input stream.- Parameters:
in- The input stream to read from.- Returns:
- The attribute read, possibly
nullif it was known to be unimportant for our purposes. - Throws:
java.io.IOException- If an IO error occurs.
-
-