01: package edu.umd.cs.findbugs.ba.npe;
02:
03: import java.util.HashSet;
04: import java.util.Set;
05:
06: import edu.umd.cs.findbugs.ba.Location;
07:
08: /**
09: * Collected information about a single value number
10: * observed at one or more locations to be both
11: * definitely-null and unconditionally dereferenced.
12: */
13: public class NullValueUnconditionalDeref {
14: private boolean alwaysOnExceptionPath;
15: private boolean alwaysFieldValue;
16: private boolean alwaysMethodReturnValue;
17: private Set<Location> derefLocationSet;
18: private Set<IsNullValue> values = new HashSet<IsNullValue>();
19:
20: public NullValueUnconditionalDeref() {
21: this .alwaysOnExceptionPath = true;
22: this .alwaysMethodReturnValue = true;
23: this .alwaysFieldValue = true;
24: this .derefLocationSet = new HashSet<Location>();
25: }
26:
27: /**
28: * @param isNullValue
29: * @param unconditionalDerefLocationSet
30: */
31: public void add(IsNullValue isNullValue,
32: Set<Location> unconditionalDerefLocationSet) {
33: if (!isNullValue.isException()) {
34: alwaysOnExceptionPath = false;
35: }
36: if (!isNullValue.isFieldValue())
37: alwaysFieldValue = false;
38: if (!isNullValue.isReturnValue()) {
39: alwaysMethodReturnValue = false;
40: }
41: values.add(isNullValue);
42: derefLocationSet.addAll(unconditionalDerefLocationSet);
43: }
44:
45: /**
46: * @return Returns the derefLocationSet.
47: */
48: public Set<Location> getDerefLocationSet() {
49: return derefLocationSet;
50: }
51:
52: /**
53: * @return Returns the alwaysOnExceptionPath.
54: */
55: public boolean isAlwaysOnExceptionPath() {
56: return alwaysOnExceptionPath;
57: }
58:
59: /**
60: * @return Returns the alwaysMethodReturnValue.
61: */
62: public boolean isMethodReturnValue() {
63: return alwaysMethodReturnValue;
64: }
65:
66: /**
67: * @return Returns the alwaysFieldValue.
68: */
69: public boolean isFieldValue() {
70: return alwaysFieldValue;
71: }
72: }
|