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(Location loc) {
14 locTuple = new NTuple<Location>();
18 public NTuple<Location> getTuple() {
22 public int getSize() {
23 return locTuple.size();
26 public void addLocation(Location loc) {
30 public Location get(int idx) {
31 return locTuple.get(idx);
34 public boolean isEmpty() {
35 return locTuple.size() == 0;
38 public boolean startsWith(CompositeLocation prefix) {
39 // tests if this composite location starts with the prefix
41 for (int i = 0; i < prefix.getSize(); i++) {
42 if (!prefix.get(i).equals(get(i))) {
50 public String toString() {
52 String rtr = "CompLoc[";
54 int tupleSize = locTuple.size();
55 for (int i = 0; i < tupleSize; i++) {
56 Location locElement = locTuple.get(i);
67 public boolean equals(Object o) {
69 if (!(o instanceof CompositeLocation)) {
73 CompositeLocation compLoc = (CompositeLocation) o;
75 if (compLoc.getTuple().equals(getTuple())) {
83 public int hashCode() {
85 return locTuple.hashCode();
89 public CompositeLocation clone() {
90 CompositeLocation clone = new CompositeLocation();
91 clone.getTuple().addAll(locTuple);