adding a test case
[IRC.git] / Robust / src / Analysis / SSJava / HNode.java
1 package Analysis.SSJava;
2
3 import IR.Descriptor;
4
5 public class HNode {
6
7   private String name;
8   private Descriptor desc;
9
10   private boolean isSkeleton;
11   private boolean isCombinationNode;
12   private boolean isSharedNode;
13   private boolean isMergeNode;
14
15   // set true if hnode is the first node of the combination chain
16   private boolean isDirectCombinationNode;
17
18   public HNode() {
19     this.isSkeleton = false;
20     this.isCombinationNode = false;
21     this.isSharedNode = false;
22     this.isMergeNode = false;
23     this.isDirectCombinationNode = false;
24   }
25
26   public boolean isMergeNode() {
27     return isMergeNode;
28   }
29
30   public void setMergeNode(boolean isMergeNode) {
31     this.isMergeNode = isMergeNode;
32   }
33
34   public HNode(String name) {
35     this();
36     this.name = name;
37   }
38
39   public HNode(Descriptor d) {
40     this();
41     this.desc = d;
42     this.name = d.getSymbol();
43   }
44
45   public boolean isSharedNode() {
46     return isSharedNode;
47   }
48
49   public void setSharedNode(boolean b) {
50     this.isSharedNode = b;
51   }
52
53   public boolean isSkeleton() {
54     return isSkeleton;
55   }
56
57   public void setSkeleton(boolean isSkeleton) {
58     this.isSkeleton = isSkeleton;
59   }
60
61   public boolean isCombinationNode() {
62     return isCombinationNode;
63   }
64
65   public void setCombinationNode(boolean b) {
66     isCombinationNode = b;
67   }
68
69   public String getName() {
70     return name;
71   }
72
73   public boolean isDirectCombinationNode() {
74     return isDirectCombinationNode;
75   }
76
77   public void setDirectCombinationNode(boolean isDirectCombinationNode) {
78     this.isDirectCombinationNode = isDirectCombinationNode;
79   }
80
81   public boolean equals(Object o) {
82     if (o instanceof HNode) {
83       HNode in = (HNode) o;
84       if (getName().equals(in.getName())) {
85         return true;
86       }
87     }
88     return false;
89   }
90
91   public String getNamePropertyString() {
92     return toString().substring(1, toString().length() - 1);
93   }
94
95   public String toString() {
96
97     String properties = "";
98
99     if (isSharedNode()) {
100       properties += "*";
101     }
102
103     if (isCombinationNode()) {
104       properties += "C";
105     }
106
107     if (isSkeleton()) {
108       properties += "S";
109     }
110
111     if (properties.length() > 0) {
112       properties = "(" + properties + ")";
113     }
114
115     return "[" + name + properties + "]";
116   }
117
118   public Descriptor getDescriptor() {
119     return desc;
120   }
121
122   public int hashCode() {
123     return 7 + name.hashCode();
124   }
125
126 }