KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > webFlow > model > WebFlowNode


1 package com.opensymphony.webwork.webFlow.model;
2
3 import java.io.IOException JavaDoc;
4
5 /**
6  * User: plightbo
7  * Date: Jun 26, 2005
8  * Time: 4:49:14 PM
9  */

10 public abstract class WebFlowNode implements Render, Comparable JavaDoc {
11     private String JavaDoc name;
12     private SubGraph parent;
13
14     public WebFlowNode(String JavaDoc name) {
15         this.name = name;
16     }
17
18     public SubGraph getParent() {
19         return parent;
20     }
21
22     public void setParent(SubGraph parent) {
23         this.parent = parent;
24     }
25
26     public void render(IndentWriter writer) throws IOException JavaDoc {
27         writer.write(getFullName() + " [label=\"" + name + "\",color=\"" + getColor() + "\"];");
28     }
29
30     public String JavaDoc getFullName() {
31         String JavaDoc prefix = "";
32         if (parent != null) {
33             String JavaDoc parentPrefix = parent.getPrefix();
34             if (!parentPrefix.equals("")) {
35                 prefix = parentPrefix + "_";
36             }
37         }
38         return prefix + cleanName();
39     }
40
41     private String JavaDoc cleanName() {
42         return name.replaceAll("[\\.\\/\\-\\$\\{\\}]", "_");
43     }
44
45     public abstract String JavaDoc getColor();
46
47     public int compareTo(Object JavaDoc o) {
48         return name.compareTo(((WebFlowNode) o).name);
49     }
50 }
51
Popular Tags