
com.neuronrobotics.sdk.bootloader.Hexml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-bowler Show documentation
Show all versions of java-bowler Show documentation
A command line utility for accesing the bowler framework.
The newest version!
package com.neuronrobotics.sdk.bootloader;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
// TODO: Auto-generated Javadoc
/**
* The Class Hexml.
*/
public class Hexml {
/** The cores. */
ArrayList cores = new ArrayList();
/** The revision. */
private String revision="";
/**
* Instantiates a new hexml.
*
* @param hexml the hexml
* @throws ParserConfigurationException the parser configuration exception
* @throws SAXException the SAX exception
* @throws IOException Signals that an I/O exception has occurred.
*/
public Hexml(File hexml) throws ParserConfigurationException, SAXException, IOException{
/**
* sample code from
* http://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/
*/
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder;
Document doc = null;
dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(hexml);
doc.getDocumentElement().normalize();
////System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
loadRevision(doc);
//NodeList nList = doc.getElementsByTagName("revision");
//revision = getTagValue("revision",(Element)nList.item(0));
////System.out.println("Revision is:"+revision);
NodeList nList = doc.getElementsByTagName("core");
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
int index = Integer.parseInt(getTagValue("index",eElement));
//int word = Integer.parseInt(getTagValue("wordSize",eElement));
NRBootCoreType type = NRBootCoreType.find(getTagValue("type",eElement));
if (type == null) {
System.err.println("Failed to get a core type for: "+getTagValue("type",eElement));
continue;
}
String hexFile = getTagValue("hex",eElement);
ArrayList lines=new ArrayList();
String[] tokens = hexFile.split("\n");
for (int i=0;i getCores(){
return cores;
}
/**
* Gets the revision.
*
* @return the revision
*/
public String getRevision() {
return revision;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy