KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > loader > ConfigConditionDescriptor


1 package com.opensymphony.workflow.loader;
2
3 import java.io.PrintWriter JavaDoc;
4 import java.util.ArrayList JavaDoc;
5 import java.util.List JavaDoc;
6
7 import org.w3c.dom.Element JavaDoc;
8 import org.w3c.dom.NodeList JavaDoc;
9
10 /**
11  * @author baab
12  */

13 public class ConfigConditionDescriptor extends ConditionDescriptor implements ArgsAware
14 {
15   protected String JavaDoc plugin;
16   protected String JavaDoc description;
17     protected String JavaDoc displayName;
18   protected List JavaDoc modifiableArgs = new ArrayList JavaDoc();
19     private PaletteDescriptor palette;
20
21     public ConfigConditionDescriptor(PaletteDescriptor palette)
22   {
23         this.palette = palette;
24   }
25
26   public ConfigConditionDescriptor(PaletteDescriptor palette, Element JavaDoc condition)
27   {
28       this.palette = palette;
29     init(condition);
30   }
31
32   public ConfigConditionDescriptor(ConfigConditionDescriptor other)
33   {
34     this.setPlugin(other.getPlugin());
35     this.setName(other.getName());
36     this.setNegate(other.isNegate());
37     this.setType(other.getType());
38     this.getArgs().putAll(other.getArgs());
39       displayName = other.displayName;
40       description = other.description;
41     modifiableArgs = other.modifiableArgs;
42       palette = other.palette;
43   }
44
45     public PaletteDescriptor getPalette()
46     {
47         return palette;
48     }
49
50     public void setPalette(PaletteDescriptor palette)
51     {
52         this.palette = palette;
53     }
54
55   protected void init(Element JavaDoc condition)
56   {
57     type = condition.getAttribute("type");
58
59     String JavaDoc n = condition.getAttribute("negate");
60     if("true".equalsIgnoreCase(n) || "yes".equalsIgnoreCase(n))
61     {
62       negate = true;
63     }
64     else
65     {
66       negate = false;
67     }
68
69     List JavaDoc args = XMLUtil.getChildElements(condition, "arg");
70     for(int l = 0; l < args.size(); l++)
71     {
72       Element JavaDoc arg = (Element JavaDoc)args.get(l);
73       this.args.put(arg.getAttribute("name"), XMLUtil.getText(arg));
74       if("true".equals(arg.getAttribute("modifiable")))
75       {
76         modifiableArgs.add(arg.getAttribute("name"));
77       }
78     }
79     plugin = XMLUtil.getChildText(condition, "plugin");
80     name = XMLUtil.getChildText(condition, "name");
81   }
82
83   public boolean isArgModifiable(String JavaDoc name)
84   {
85     return modifiableArgs.contains(name);
86   }
87
88   public void writeXML(PrintWriter JavaDoc writer, int indent)
89   {
90     throw new UnsupportedOperationException JavaDoc();
91   }
92
93   public String JavaDoc getDescription()
94   {
95     return description;
96   }
97
98     public String JavaDoc getDisplayName()
99     {
100         return displayName;
101     }
102
103     public void setDisplayName(String JavaDoc displayName)
104     {
105         this.displayName = displayName;
106     }
107
108   public String JavaDoc getPlugin()
109   {
110     return plugin;
111   }
112
113   public void setDescription(String JavaDoc string)
114   {
115     description = string;
116   }
117
118   public void setPlugin(String JavaDoc string)
119   {
120     plugin = string;
121   }
122
123     public String JavaDoc toString()
124     {
125         return displayName!=null ? displayName : name;
126     }
127 }
128
Popular Tags