Change tabbing for everything....
[IRC.git] / Robust / src / Analysis / Scheduling / ClassNode.java
1 package Analysis.Scheduling;
2
3 import Analysis.TaskStateAnalysis.*;
4 import IR.*;
5 import java.util.*;
6
7 import Util.GraphNode;
8
9 /** This class holds a flag diagram for one class.
10  */
11 public class ClassNode extends GraphNode implements Cloneable {
12
13   private int uid;
14   private static int nodeID=0;
15
16   private final ClassDescriptor cd;
17   private ScheduleNode sn;
18   private Vector<FlagState> flagStates;
19   private boolean sorted = false;
20   private boolean clone = false;
21
22   private int transTime;
23
24   /** Class constructor
25    *    @param cd ClassDescriptor
26    *  @param fStates
27    */
28   public ClassNode(ClassDescriptor cd, Vector<FlagState> fStates) {
29     this.cd=cd;
30     this.flagStates = fStates;
31     this.sn = null;
32     this.uid=ClassNode.nodeID++;
33     this.transTime = 0;
34   }
35
36   public int getTransTime() {
37     return this.transTime;
38   }
39
40   public void setTransTime(int transTime) {
41     this.transTime = transTime;
42   }
43
44   public int getuid() {
45     return uid;
46   }
47
48   public ScheduleNode getScheduleNode() {
49     return this.sn;
50   }
51
52   public void setScheduleNode(ScheduleNode sn) {
53     this.sn = sn;
54   }
55
56   public boolean isSorted() {
57     return sorted;
58   }
59
60   public void setSorted(boolean sorted) {
61     this.sorted = sorted;
62   }
63
64   public Vector<FlagState> getFlagStates() {
65     return flagStates;
66   }
67
68   public boolean isclone() {
69     return clone;
70   }
71
72   public String toString() {
73     return cd.toString()+getTextLabel();
74   }
75
76   /** @return Iterator over the flags in the flagstate.
77    */
78
79   public Iterator getFlags() {
80     return flagStates.iterator();
81   }
82
83   public int numFlags() {
84     return flagStates.size();
85   }
86
87   /** Accessor method
88    *  @return returns the classdescriptor of the flagstate.
89    */
90
91   public ClassDescriptor getClassDescriptor() {
92     return cd;
93   }
94
95   /** Tests for equality of two flagstate objects.
96    */
97
98   public boolean equals(Object o) {
99     if (o instanceof ClassNode) {
100       ClassNode fs=(ClassNode)o;
101       if ((fs.getClassDescriptor()!= cd) ||
102           (fs.isSorted() != sorted) ||
103           (fs.clone != this.clone) ||
104           (fs.transTime != this.transTime)) {
105         return false;
106       }
107       return (fs.getFlagStates().equals(flagStates));
108     }
109     return false;
110   }
111
112   public int hashCode() {
113     return cd.hashCode()^Boolean.toString(sorted).hashCode()^Boolean.toString(clone).hashCode()^
114            transTime^flagStates.hashCode();
115   }
116
117   public String getLabel() {
118     return "N_"+uid;
119   }
120
121   public String getClusterLabel() {
122     return "cluster_"+uid;
123   }
124
125   public String getTextLabel() {
126     String label=null;
127     label = "Class " + this.cd.getSymbol();
128
129     if (label==null)
130       return " ";
131     return label;
132   }
133
134   public Object clone() {
135     ClassNode o = null;
136     try {
137       o = (ClassNode) super.clone();
138     } catch(CloneNotSupportedException e){
139       e.printStackTrace();
140     }
141     o.uid = ClassNode.nodeID++;
142     o.clone = true;
143     return o;
144   }
145
146   public void calExeTime() {
147     for(int i = 0; i <  this.flagStates.size(); i++) {
148       this.flagStates.elementAt(i).getExeTime();
149     }
150   }
151 }