1 19 20 package edu.umd.cs.findbugs.ba.bcp; 21 22 import edu.umd.cs.findbugs.annotations.Nullable; 23 import edu.umd.cs.findbugs.ba.vna.ValueNumber; 24 25 public class FieldVariable implements Variable { 26 private final ValueNumber ref; 27 private final String className; 28 private final String fieldName; 29 private final String fieldSig; 30 31 38 public FieldVariable(String className, String fieldName, String fieldSig) { 39 this(null, className, fieldName, fieldSig); 40 } 41 42 50 public FieldVariable(@Nullable ValueNumber ref, String className, String fieldName, String fieldSig) { 51 this.ref = ref; 52 this.className = className; 53 this.fieldName = fieldName; 54 this.fieldSig = fieldSig; 55 } 56 57 60 public boolean isStatic() { 61 return ref == null; 62 } 63 64 67 public String getClassName() { 68 return className; 69 } 70 71 74 public String getFieldName() { 75 return fieldName; 76 } 77 78 81 public String getFieldSig() { 82 return fieldSig; 83 } 84 85 public boolean sameAs(Variable other) { 86 if (!(other instanceof FieldVariable)) 87 return false; 88 FieldVariable otherField = (FieldVariable) other; 89 if (isStatic() != otherField.isStatic()) 90 return false; 91 return (ref == null || ref.equals(otherField.ref)) 92 && className.equals(otherField.className) 93 && fieldName.equals(otherField.fieldName) 94 && fieldSig.equals(otherField.fieldSig); 95 } 96 97 @Override 98 public String toString() { 99 StringBuffer buf = new StringBuffer (); 100 buf.append(className); 101 buf.append('.'); 102 buf.append(fieldName); 103 return buf.toString(); 104 } 105 } 106 107 | Popular Tags |