1 package Analysis.SSJava;
3 import IR.TypeExtension;
5 public class CompositeLocation implements TypeExtension {
7 protected NTuple<Location> locTuple;
9 public CompositeLocation() {
10 locTuple = new NTuple<Location>();
13 public CompositeLocation(NTuple<Location> locTuple) {
14 this.locTuple = locTuple.clone();
17 public CompositeLocation(Location loc) {
18 locTuple = new NTuple<Location>();
22 public NTuple<Location> getTuple() {
26 public int getSize() {
27 return locTuple.size();
30 public void addLocation(Location loc) {
34 public Location get(int idx) {
35 return locTuple.get(idx);
38 public boolean isEmpty() {
39 return locTuple.size() == 0;
42 public boolean startsWith(CompositeLocation prefix) {
43 // tests if this composite location starts with the prefix
45 for (int i = 0; i < prefix.getSize(); i++) {
46 if (!prefix.get(i).equals(get(i))) {
54 public String toString() {
56 String rtr = "CompLoc[";
58 int tupleSize = locTuple.size();
59 for (int i = 0; i < tupleSize; i++) {
60 Location locElement = locTuple.get(i);
71 public boolean equals(Object o) {
73 if (!(o instanceof CompositeLocation)) {
77 CompositeLocation compLoc = (CompositeLocation) o;
79 if (compLoc.getTuple().equals(getTuple())) {
87 public int hashCode() {
89 return locTuple.hashCode();
93 public CompositeLocation clone() {
94 CompositeLocation clone = new CompositeLocation();
95 clone.getTuple().addAll(locTuple);