KickJava   Java API By Example, From Geeks To Geeks.

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


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

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