Class FieldAnnotation
java.lang.Object
edu.umd.cs.findbugs.BugAnnotationWithSourceLines
edu.umd.cs.findbugs.PackageMemberAnnotation
edu.umd.cs.findbugs.FieldAnnotation
- All Implemented Interfaces:
BugAnnotation, XMLWriteable, XMLWriteableWithMessages, Serializable, Cloneable, Comparable<BugAnnotation>
A BugAnnotation specifying a particular field in particular class.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringprivate static final Stringprivate final Stringprivate final Stringprivate Stringstatic final Stringprivate final booleanstatic final Stringprivate static final longstatic final Stringstatic final StringFields inherited from class PackageMemberAnnotation
className, descriptionFields inherited from class BugAnnotationWithSourceLines
sourceFileName, sourceLinesFields inherited from interface BugAnnotation
MESSAGE_TAG -
Constructor Summary
ConstructorsConstructorDescriptionFieldAnnotation(String className, String fieldName, String fieldSig, boolean isStatic) Constructor.FieldAnnotation(String className, String fieldName, String fieldSig, int accessFlags) Constructor.FieldAnnotation(String className, String fieldName, String fieldSig, String fieldSourceSig, boolean isStatic) -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(BugAnnotationVisitor visitor) Accept a BugAnnotationVisitor.intbooleanprotected StringformatPackageMember(String key, ClassAnnotation primaryClass) Do default and subclass-specific formatting.static FieldAnnotationfromBCELField(String className, org.apache.bcel.classfile.Field field) Factory method.static FieldAnnotationfromBCELField(org.apache.bcel.classfile.JavaClass jClass, org.apache.bcel.classfile.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) Get the field name.Get the type signature of the field.private StringgetNameInClass(ClassAnnotation primaryClass) Get the SourceLineAnnotation describing the source lines where the method is defined.inthashCode()static FieldAnnotationisRead(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) Is the given instruction a read of a field?booleanisStatic()Return whether or not the field is static.static FieldAnnotationisWrite(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) Is the instruction a write of a field?toXField()voidWrite this object to given XMLOutput.voidMethods inherited from class PackageMemberAnnotation
format, getClassDescriptor, getClassName, getDescription, getJavaAnnotationNames, getPackageName, getSimpleClassName, getSlashedClassName, isSignificant, removePackage, removePackageName, setDescription, setJavaAnnotationNames, shorten, toString, toStringMethods inherited from class BugAnnotationWithSourceLines
clone, getSourceFileName, setSourceLines
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
DEFAULT_ROLE
- See Also:
-
DID_YOU_MEAN_ROLE
- See Also:
-
VALUE_OF_ROLE
- See Also:
-
LOADED_FROM_ROLE
- See Also:
-
STORED_ROLE
- See Also:
-
INVOKED_ON_ROLE
- See Also:
-
ARGUMENT_ROLE
- See Also:
-
fieldName
-
fieldSig
-
fieldSourceSig
-
isStatic
private final boolean isStatic -
ELEMENT_NAME
- See Also:
-
-
Constructor Details
-
FieldAnnotation
public FieldAnnotation(@DottedClassName String className, String fieldName, String fieldSig, boolean isStatic) Constructor.- Parameters:
className- the name of the class containing the fieldfieldName- the name of the fieldfieldSig- the type signature of the field
-
FieldAnnotation
public FieldAnnotation(@DottedClassName String className, String fieldName, String fieldSig, String fieldSourceSig, boolean isStatic) -
FieldAnnotation
public FieldAnnotation(@DottedClassName String className, String fieldName, String fieldSig, int accessFlags) Constructor.- Parameters:
className- the name of the class containing the fieldfieldName- the name of the fieldfieldSig- the type signature of the fieldaccessFlags- accessFlags for the field
-
-
Method Details
-
fromVisitedField
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
-
fromReferencedField
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
-
fromBCELField
public static FieldAnnotation fromBCELField(@DottedClassName String className, org.apache.bcel.classfile.Field field) Factory method. Construct from class name and BCEL Field object.- Parameters:
className- the name of the class which defines the fieldfield- the BCEL Field object- Returns:
- the FieldAnnotation
-
fromBCELField
public static FieldAnnotation fromBCELField(org.apache.bcel.classfile.JavaClass jClass, org.apache.bcel.classfile.Field field) Factory method. Construct from class name and BCEL Field object.- Parameters:
jClass- the class which defines the fieldfield- the BCEL Field object- Returns:
- the FieldAnnotation
-
fromFieldDescriptor
Factory method. Construct from a FieldDescriptor.- Parameters:
fieldDescriptor- the FieldDescriptor- Returns:
- the FieldAnnotation
-
fromXField
-
toXField
-
toFieldDescriptor
-
getFieldName
Get the field name. -
getFieldSignature
Get the type signature of the field. -
isStatic
public boolean isStatic()Return whether or not the field is static. -
isRead
public static FieldAnnotation isRead(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) Is the given instruction a read of a field?- Parameters:
ins- the Instruction to checkcpg- ConstantPoolGen of the method containing the instruction- Returns:
- the Field if the instruction is a read of a field, null otherwise
-
isWrite
public static FieldAnnotation isWrite(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) Is the instruction a write of a field?- Parameters:
ins- the Instruction to checkcpg- ConstantPoolGen of the method containing the instruction- Returns:
- the Field if instruction is a write of a field, null otherwise
-
accept
Description copied from interface:BugAnnotationAccept a BugAnnotationVisitor.- Parameters:
visitor- the visitor to accept
-
formatPackageMember
Description copied from class:PackageMemberAnnotationDo default and subclass-specific formatting.- Specified by:
formatPackageMemberin classPackageMemberAnnotation- Parameters:
key- the key specifying how to do the formattingprimaryClass- TODO
-
getNameInClass
-
hashCode
-
equals
-
compareTo
-
getSourceLines
Description copied from class:BugAnnotationWithSourceLinesGet the SourceLineAnnotation describing the source lines where the method is defined.- Overrides:
getSourceLinesin classBugAnnotationWithSourceLines- Returns:
- the SourceLineAnnotation, or null if there is no source information for this package element
-
writeXML
Description copied from interface:XMLWriteableWrite this object to given XMLOutput.- Parameters:
xmlOutput- the XMLOutput for the document- Throws:
IOException
-
writeXML
public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException - Throws:
IOException
-