1 6 7 package SOFA.Connector.EEG; 8 9 import org.w3c.dom.Element ; 10 import org.w3c.dom.Node ; 11 12 17 public class ElementInputDescriptor { 18 19 public String instanceName; 20 public String implementation; 21 22 public SOFA.Connector.Property[] props; 23 24 public SOFA.Connector.Property[] techProps; 26 27 public ElementInputDescriptor() { 28 } 29 30 static public ElementInputDescriptor fromXML(Element rootElement) throws ElementDescriptorXMLException { 31 ElementInputDescriptor eid=new ElementInputDescriptor(); 32 java.util.LinkedList descrProps=new java.util.LinkedList (); 33 Node 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 el=(Element )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]; 58 eid.props=new SOFA.Connector.Property[descrProps.size()]; 59 java.util.Iterator 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 |