edu.umd.cs.findbugs

Class FieldAnnotation

public class FieldAnnotation extends PackageMemberAnnotation

A BugAnnotation specifying a particular field in particular class.

Author: David Hovemeyer

See Also: BugAnnotation

Constructor Summary
FieldAnnotation(String className, String fieldName, String fieldSig, boolean isStatic)
Constructor.
FieldAnnotation(String className, String fieldName, String fieldSig, int accessFlags)
Constructor.
Method Summary
voidaccept(BugAnnotationVisitor visitor)
intcompareTo(BugAnnotation o)
static FieldAnnotationfromBCELField(String className, Field field)
Factory method.
static FieldAnnotationfromFieldDescriptor(FieldDescriptor fieldDescriptor)
Factory method.
static FieldAnnotationfromReferencedField(DismantleBytecode visitor)
Factory method.
static FieldAnnotationfromVisitedField(PreorderVisitor visitor)
Factory method.
static FieldAnnotationfromXField(XField fieldDescriptor)
StringgetFieldName()
Get the field name.
StringgetFieldSignature()
Get the type signature of the field.
static FieldAnnotationisRead(Instruction ins, ConstantPoolGen cpg)
Is the given instruction a read of a field?
booleanisStatic()
Return whether or not the field is static.
static FieldAnnotationisWrite(Instruction ins, ConstantPoolGen cpg)
Is the instruction a write of a field?
voidwriteXML(XMLOutput xmlOutput)
voidwriteXML(XMLOutput xmlOutput, boolean addMessages)

Constructor Detail

FieldAnnotation

public FieldAnnotation(String className, String fieldName, String fieldSig, boolean isStatic)
Constructor.

Parameters: className the name of the class containing the field fieldName the name of the field fieldSig the type signature of the field

FieldAnnotation

public FieldAnnotation(String className, String fieldName, String fieldSig, int accessFlags)
Constructor.

Parameters: className the name of the class containing the field fieldName the name of the field fieldSig the type signature of the field accessFlags accessFlags for the field

Method Detail

accept

public void accept(BugAnnotationVisitor visitor)

compareTo

public int compareTo(BugAnnotation o)

fromBCELField

public static FieldAnnotation fromBCELField(String className, Field field)
Factory method. Construct from class name and BCEL Field object.

Parameters: className the name of the class which defines the field field the BCEL Field object

Returns: the FieldAnnotation

fromFieldDescriptor

public static FieldAnnotation fromFieldDescriptor(FieldDescriptor fieldDescriptor)
Factory method. Construct from a FieldDescriptor.

Parameters: fieldDescriptor the FieldDescriptor

Returns: the FieldAnnotation

fromReferencedField

public static FieldAnnotation fromReferencedField(DismantleBytecode visitor)
Factory method. Class name, field name, and field signatures are taken from the given visitor, which is visiting a reference to the field (i.e., a getfield or getstatic instruction).

Parameters: visitor the visitor which is visiting the field reference

Returns: the FieldAnnotation object

fromVisitedField

public static FieldAnnotation fromVisitedField(PreorderVisitor visitor)
Factory method. Class name, field name, and field signatures are taken from the given visitor, which is visiting the field.

Parameters: visitor the visitor which is visiting the field

Returns: the FieldAnnotation object

fromXField

public static FieldAnnotation fromXField(XField fieldDescriptor)

getFieldName

public String getFieldName()
Get the field name.

getFieldSignature

public String getFieldSignature()
Get the type signature of the field.

isRead

public static FieldAnnotation isRead(Instruction ins, ConstantPoolGen cpg)
Is the given instruction a read of a field?

Parameters: ins the Instruction to check cpg ConstantPoolGen of the method containing the instruction

Returns: the Field if the instruction is a read of a field, null otherwise

isStatic

public boolean isStatic()
Return whether or not the field is static.

isWrite

public static FieldAnnotation isWrite(Instruction ins, ConstantPoolGen cpg)
Is the instruction a write of a field?

Parameters: ins the Instruction to check cpg ConstantPoolGen of the method containing the instruction

Returns: the Field if instruction is a write of a field, null otherwise

writeXML

public void writeXML(XMLOutput xmlOutput)

writeXML

public void writeXML(XMLOutput xmlOutput, boolean addMessages)
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.