KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > Connector > EEG > ElementInputDescriptor


1 /*
2  * ElementInputDescriptor.java
3  *
4  * Created on 2. duben 2002, 20:31
5  */

6
7 package SOFA.Connector.EEG;
8
9 import org.w3c.dom.Element JavaDoc;
10 import org.w3c.dom.Node JavaDoc;
11
12 /**
13  *
14  * @author ghort
15  * @version
16  */

17 public class ElementInputDescriptor {
18
19     public String JavaDoc instanceName;
20     public String JavaDoc implementation;
21     
22     public SOFA.Connector.Property[] props;
23
24     public SOFA.Connector.Property[] techProps; // mozna tohle do props
25

26     /** Creates new ElementInputDescriptor */
27     public ElementInputDescriptor() {
28     }
29
30     static public ElementInputDescriptor fromXML(Element JavaDoc rootElement) throws ElementDescriptorXMLException {
31         ElementInputDescriptor eid=new ElementInputDescriptor();
32         java.util.LinkedList JavaDoc descrProps=new java.util.LinkedList JavaDoc();
33         Node JavaDoc node;
34
35         if (!rootElement.hasAttribute("name")) {
36             throw new ElementDescriptorXMLException("Element doesn't have 'name' attribute.");
37         }
38         eid.instanceName=rootElement.getAttribute("name");
39
40         if (!rootElement.hasAttribute("impl")) {
41             throw new ElementDescriptorXMLException("Element doesn't have 'impl' attribute.");
42         }
43         eid.implementation=rootElement.getAttribute("impl");
44         
45         node=rootElement.getFirstChild();
46         while (node!=null) {
47             if (node.getNodeType()==Node.ELEMENT_NODE) {
48                 Element JavaDoc el=(Element JavaDoc)node;
49                 if (el.getNodeName().equals("property") && el.hasAttribute("name") && el.hasAttribute("value")) {
50                     descrProps.add(new SOFA.Connector.Property(el.getAttribute("name"),el.getAttribute("value")));
51                 }
52             }
53             node=node.getNextSibling();
54         }
55         
56         eid.techProps=new SOFA.Connector.Property[0]; // FIXME: mela by se nacitat take z XML
57

58         eid.props=new SOFA.Connector.Property[descrProps.size()];
59         java.util.Iterator JavaDoc iter=descrProps.iterator();
60         for (int i=0;iter.hasNext();i++) {
61             eid.props[i]=(SOFA.Connector.Property)iter.next();
62         }
63         
64         return eid;
65     }
66 }
67
Popular Tags