1 package com.neuronrobotics.sdk.bootloader;
4 import java.io.IOException;
5 import java.util.ArrayList;
7 import javax.xml.parsers.DocumentBuilder;
8 import javax.xml.parsers.DocumentBuilderFactory;
9 import javax.xml.parsers.ParserConfigurationException;
11 import org.w3c.dom.Document;
12 import org.w3c.dom.Element;
13 import org.w3c.dom.Node;
14 import org.w3c.dom.NodeList;
15 import org.xml.sax.SAXException;
25 ArrayList<Core> cores =
new ArrayList<Core>();
38 public Hexml(File hexml)
throws ParserConfigurationException, SAXException, IOException{
43 DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
44 DocumentBuilder dBuilder;
47 dBuilder = dbFactory.newDocumentBuilder();
48 doc = dBuilder.parse(hexml);
49 doc.getDocumentElement().normalize();
56 NodeList nList = doc.getElementsByTagName(
"core");
57 for (
int temp = 0; temp < nList.getLength(); temp++) {
58 Node nNode = nList.item(temp);
59 if (nNode.getNodeType() == Node.ELEMENT_NODE) {
60 Element eElement = (Element) nNode;
61 int index = Integer.parseInt(
getTagValue(
"index",eElement));
65 System.err.println(
"Failed to get a core type for: "+
getTagValue(
"type",eElement));
69 ArrayList<hexLine> lines=
new ArrayList<hexLine>();
70 String[] tokens = hexFile.split(
"\n");
71 for (
int i=0;i<tokens.length;i++){
73 lines.add(
new hexLine(tokens[i]));
74 }
catch (Exception e) {
79 Core tmp =
new Core(index, lines, type);
95 NodeList nlList= doc.getElementsByTagName(
"revision").item(0).getChildNodes();
96 Node nValue = (Node) nlList.item(0);
98 }
catch(NullPointerException e){
111 NodeList nlList= eElement.getElementsByTagName(sTag).item(0).getChildNodes();
112 Node nValue = (Node) nlList.item(0);
113 return nValue.getNodeValue();
ArrayList< Core > getCores()
static String getTagValue(String sTag, Element eElement)
void loadRevision(Document doc)
static NRBootCoreType find(String tagValue)