switch to spaces only..
[IRC.git] / Robust / src / Analysis / SSJava / DeltaLocation.java
1 package Analysis.SSJava;
2
3 import java.util.Set;
4
5 import IR.ClassDescriptor;
6 import IR.Descriptor;
7 import IR.TypeDescriptor;
8
9 public class DeltaLocation extends CompositeLocation {
10
11   private Descriptor refOperand = null;
12
13   public DeltaLocation(ClassDescriptor cd) {
14     super(cd);
15   }
16
17   public DeltaLocation(ClassDescriptor cd, Set<Location> set) {
18     super(cd);
19     locTuple.addAll(set);
20   }
21
22   public DeltaLocation(ClassDescriptor cd, Descriptor refOperand) {
23     super(cd);
24     this.refOperand = refOperand;
25   }
26
27   public Descriptor getRefLocationId() {
28     return this.refOperand;
29   }
30
31   public void addDeltaOperand(Location op) {
32     locTuple.addElement(op);
33   }
34
35   public NTuple<Location> getDeltaOperandLocationVec() {
36     return locTuple;
37   }
38
39   // public Set<Location> getBaseLocationSet() {
40   //
41   // if (operandVec.size() == 1 && (operandVec.get(0) instanceof DeltaLocation))
42   // {
43   // // nested delta definition
44   // DeltaLocation deltaLoc = (DeltaLocation) operandVec.get(0);
45   // return deltaLoc.getBaseLocationSet();
46   // } else {
47   // Set<Location> set = new HashSet<Location>();
48   // set.addAll(operandVec);
49   // return set;
50   // }
51   //
52   // }
53
54   public boolean equals(Object o) {
55
56     if (!(o instanceof DeltaLocation)) {
57       return false;
58     }
59
60     DeltaLocation deltaLoc = (DeltaLocation) o;
61
62     if (deltaLoc.getDeltaOperandLocationVec().equals(getDeltaOperandLocationVec())) {
63       return true;
64     }
65     return false;
66   }
67
68   public int hashCode() {
69     int hash = cd.hashCode();
70     hash += locTuple.hashCode();
71     if (refOperand != null) {
72       hash += refOperand.hashCode();
73     }
74     return hash;
75   }
76
77   public String toString() {
78     String rtr = "delta(";
79
80     if (locTuple.size() != 0) {
81       int tupleSize = locTuple.size();
82       for (int i = 0; i < tupleSize; i++) {
83         Location locElement = locTuple.at(i);
84         if (i != 0) {
85           rtr += ",";
86         }
87         rtr += locElement;
88       }
89     } else {
90       rtr += "LOC_REF";
91     }
92
93     rtr += ")";
94
95     return rtr;
96   }
97
98 }