1 package com.neuronrobotics.sdk.common;
5 import javax.xml.parsers.DocumentBuilder;
6 import javax.xml.parsers.DocumentBuilderFactory;
8 import org.w3c.dom.Document;
9 import org.w3c.dom.Element;
10 import org.w3c.dom.Node;
11 import org.w3c.dom.NodeList;
13 import com.neuronrobotics.sdk.network.BowlerTCPClient;
14 import com.neuronrobotics.sdk.network.UDPBowlerConnection;
32 File file =
new File(filename);
33 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
34 DocumentBuilder db = dbf.newDocumentBuilder();
35 Document doc = db.parse(file);
36 doc.getDocumentElement().normalize();
37 NodeList nodeLst = doc.getElementsByTagName(
"connection");
39 for (
int s = 0; s < nodeLst.getLength(); s++) {
41 Node fstNode = nodeLst.item(s);
43 if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
45 Element e = (Element) fstNode;
52 if(type.equalsIgnoreCase(
"serial")) {
56 if(type.equalsIgnoreCase(
"udp")) {
60 if(type.equalsIgnoreCase(
"tcp")) {
66 }
catch (Exception e) {
82 NodeList elmntLst = e.getElementsByTagName(key);
83 if(elmntLst.getLength() > 0) {
84 Element elmnt = (Element) elmntLst.item(0);
85 NodeList value = elmnt.getChildNodes();
86 ((Node) value.item(0)).getNodeValue();
87 return ((Node) value.item(0)).getNodeValue();
static String getElementValue(Element e, String key, String dval)
static BowlerAbstractConnection loadDefaultConnection(String filename)