1 package Analysis.Scheduling;
3 import Analysis.TaskStateAnalysis.*;
9 /** This class holds a flag diagram for one class.
11 public class ClassNode extends GraphNode implements Cloneable {
15 private static int nodeID=0;
16 private static int colorID = 1;
17 private static Hashtable<ClassDescriptor, Integer> cd2cid =
18 new Hashtable<ClassDescriptor, Integer>();
20 private final ClassDescriptor cd;
21 private ScheduleNode sn;
22 private Vector<FlagState> flagStates;
23 private boolean sorted = false;
24 private boolean clone = false;
26 private long transTime;
29 * @param cd ClassDescriptor
32 public ClassNode(ClassDescriptor cd,
33 Vector<FlagState> fStates) {
35 this.flagStates = fStates;
37 this.uid=ClassNode.nodeID++;
38 // TODO: potential bug here
39 // DO NOT consider splitting a class node here.
40 // need to fix: 1. when a class node is splitted, the pieces should have
42 // 2. when two pieces merged, it should have right cid as have
43 // never been splitted
44 // 3. NOTE: a piece could be splitted further
45 if(this.cd2cid.containsKey(cd)) {
46 this.cid = this.cd2cid.get(cd);
48 this.cid = ClassNode.colorID++;
49 this.cd2cid.put(this.cd, this.cid);
54 public long getTransTime() {
55 return this.transTime;
58 public void setTransTime(long transTime) {
59 this.transTime = transTime;
70 public ScheduleNode getScheduleNode() {
74 public void setScheduleNode(ScheduleNode sn) {
78 public boolean isSorted() {
82 public void setSorted(boolean sorted) {
86 public Vector<FlagState> getFlagStates() {
90 public boolean isclone() {
94 public String toString() {
95 return cd.toString()+getTextLabel();
98 /** @return Iterator over the flags in the flagstate.
101 public Iterator getFlags() {
102 return flagStates.iterator();
105 public int numFlags() {
106 return flagStates.size();
110 * @return returns the classdescriptor of the flagstate.
113 public ClassDescriptor getClassDescriptor() {
117 /** Tests for equality of two flagstate objects.
120 public boolean equals(Object o) {
121 if (o instanceof ClassNode) {
122 ClassNode fs=(ClassNode)o;
123 if ((fs.getClassDescriptor()!= cd) ||
124 (fs.getuid()!= uid) ||
125 (fs.getCid()!= cid) ||
126 (fs.isSorted() != sorted) ||
127 (fs.clone != this.clone) ||
128 (fs.transTime != this.transTime)) {
131 return (fs.getFlagStates().equals(flagStates));
136 public int hashCode() {
137 return cd.hashCode()^uid^cid^Boolean.toString(sorted).hashCode()^
138 Boolean.toString(clone).hashCode()^(int)transTime^flagStates.hashCode();
141 public String getLabel() {
145 public String getClusterLabel() {
146 return "cluster_"+uid;
149 public String getTextLabel() {
151 label = "Class " + this.cd.getSymbol();
158 public Object clone() {
161 o = (ClassNode) super.clone();
162 } catch(CloneNotSupportedException e) {
165 o.uid = ClassNode.nodeID++;
171 public void calExeTime() {
172 for(int i = 0; i < this.flagStates.size(); i++) {
173 this.flagStates.elementAt(i).getExeTime();