1 package Analysis.SSJava;
3 import java.util.HashSet;
4 import java.util.Iterator;
9 public class FlowNode {
11 // descriptor tuple is a unique identifier of the flow node
12 private NTuple<Descriptor> descTuple;
14 // if the infer node represents the base type of field access,
15 // this set contains fields of the base type
16 private Set<FlowNode> fieldNodeSet;
18 // set true if this node is driven from a paramter
19 private boolean isParameter;
21 // set true if this node stores a return value
22 private boolean isReturn;
24 public Set<FlowNode> getFieldNodeSet() {
28 private Set<FlowEdge> outEdgeSet;
30 public FlowNode(NTuple<Descriptor> tuple, boolean isParam) {
32 this.isParameter = isParam;
34 NTuple<Descriptor> base = null;
35 Descriptor desc = null;
36 if (tuple.size() > 1) {
37 base = tuple.subList(0, tuple.size() - 1);
38 desc = tuple.get(tuple.size() - 1);
42 fieldNodeSet = new HashSet<FlowNode>();
43 descTuple = new NTuple<Descriptor>();
45 descTuple.addAll(base);
50 outEdgeSet = new HashSet<FlowEdge>();
53 public void addFieldNode(FlowNode node) {
54 fieldNodeSet.add(node);
57 public boolean isParameter() {
61 public NTuple<Descriptor> getDescTuple() {
65 public Descriptor getOwnDescriptor() {
66 return descTuple.get(descTuple.size() - 1);
69 public boolean isReturn() {
73 public void setReturn(boolean isReturn) {
74 this.isReturn = isReturn;
77 public String toString() {
78 String rtr = "[FlowNode]:";
82 rtr += ":" + descTuple;
86 public Iterator<FlowEdge> iteratorOfOutEdges() {
87 return outEdgeSet.iterator();
90 public void addOutEdge(FlowEdge out) {
94 public Set<FlowEdge> getOutEdgeSet() {
98 public int hashCode() {
99 return 7 + descTuple.hashCode();
102 public boolean equals(Object obj) {
104 if (obj instanceof FlowNode) {
105 FlowNode in = (FlowNode) obj;
106 if (descTuple.equals(in.getDescTuple())) {
115 public String getID() {
117 for (int i = 0; i < descTuple.size(); i++) {
118 id += descTuple.get(i).getSymbol();
123 public String getPrettyID() {
125 for (int i = 0; i < descTuple.size(); i++) {
129 id += descTuple.get(i).getSymbol();