KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > elements > Implementation


1 /* Implementation.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe.xml.elements;
12
13 import org.enhydra.jawe.xml.*;
14 import org.enhydra.jawe.xml.panels.*;
15 import org.w3c.dom.*;
16
17 /**
18 * Represents a WfMC DTD element that has the similar name.
19 *
20 * @see XML
21 */

22 public class Implementation extends XMLComplexElement {
23    // we use tools instead of tool
24
private XMLComplexChoice refType;
25
26    /**
27    * Creates a new instance of the class.
28    *
29    * @param act The activity that holds this object.
30    */

31    public Implementation (Activity act) {
32       super();
33
34       /**
35       * NOTE: Here we use the helper class Tools, which does not have
36       * it's WfMC DTD equivalent, as one of possible types.
37       */

38       refType=new XMLComplexChoice("Type",new XMLElement[] {
39          new No(), new Tools(act), new SubFlow(act)},1,true);
40
41       fillStructure ();
42    }
43
44    /**
45    * Defines the super-class method. Read the explanation for
46    * this method within XMLComplexElement class.
47    */

48    protected void fillStructure () {
49    refType.setRequired(true);
50       complexStructure.add(refType);
51    }
52
53    /**
54    * Overrides super-class method to realize this class specific
55    * reading from XML file.
56    *
57    * @param node root node
58    */

59    public void fromXML (Node node) {
60       String JavaDoc nameSpacePrefix=node.getPrefix();
61       if (nameSpacePrefix!=null) {
62          nameSpacePrefix+=":";
63       } else {
64          nameSpacePrefix="";
65       }
66
67       Object JavaDoc[] choices=refType.getChoices();
68       String JavaDoc elContent;
69       String JavaDoc elName;
70       // Iterating through implementation types, and performing
71
// a parsing to retrieve the tag for type, if tag was
72
// found, setting it to be a choosen one for implementation
73
// and calling it's fromXML method
74
for (int i=0; i<choices.length; i++) {
75          XMLElement chc=(XMLElement)choices[i];
76          elName=chc.toName();
77          if (elName.equals("Tools")) {
78             elName="Tool";
79          }
80          // external parser
81
if (node!=null) {
82             Node child=XMLUtil.getChildByName(node,nameSpacePrefix+elName);
83             if (child != null) {
84                if (elName.equals("Tool")) {
85                   chc.fromXML(node);
86                } else {
87                   chc.fromXML(child);
88                }
89                refType.setValue(chc);
90                break;
91             }
92          }
93       }
94    }
95
96    /**
97    * Prepares the panel with a combo box to choose the one of
98    * types of implementation.
99    *
100    * @return XMLPanel to be shown.
101    */

102    public XMLPanel getPanel () {
103       return refType.getPanel();
104    }
105
106    /**
107    * Used to create exact copy of instance of this class.
108    * The newly created instance will have all the properties
109    * same as the copied one.
110    *
111    * @return The newly created instance of this class.
112    */

113    public Object JavaDoc clone () {
114       Implementation i=(Implementation)super.clone();
115
116       i.refType=(XMLComplexChoice)this.refType.clone();
117       i.fillStructure();
118
119       return i;
120    }
121
122 }
123
Popular Tags