/** * Reads profile from XML file if present * * @return boolean success */ private boolean readDeviceXMLFile() { try { // Open and parse XML File fXmlFile = new File(pathToDeviceSettingsFile); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(fXmlFile); doc.getDocumentElement().normalize(); // Read XML NodeList manufacturerList = doc.getElementsByTagName(this.DEVICE_MANUFACTURER); NodeList deviceModelList = doc.getElementsByTagName(this.DEVICE_MODEL); NodeList deviceGenericList = doc.getElementsByTagName(this.DEVICE_GENERIC); NodeList deviceClassNameList = doc.getElementsByTagName(this.DEVICE_CLASS_NAME); NodeList devicePortNameList = doc.getElementsByTagName(this.DEVICE_PORT_NAME); String manufacturerValue = manufacturerList.item(0).getTextContent(); String modelValue = deviceModelList.item(0).getTextContent(); String deviceGenericValue = deviceGenericList.item(0).getTextContent(); String deviceClassNameValue = deviceClassNameList.item(0).getTextContent(); String devicePortNameValue = devicePortNameList.item(0).getTextContent(); boolean deviceIsGeneric = Boolean.parseBoolean(deviceGenericValue); // Populate class wide device settings profile deviceXMLProfile.setDeviceManufacturer(manufacturerValue); deviceXMLProfile.setDeviceModel(modelValue); deviceXMLProfile.setDeviceGeneric(deviceIsGeneric); deviceXMLProfile.setDevicePortName(devicePortNameValue); deviceXMLProfile.setDeviceClassName(deviceClassNameValue); deviceXMLProfile.setPopulated(true); } catch (Exception ex) { Logger.getLogger(AnonymousDataCollection.class.getName()).log(Level.SEVERE, null, ex); return false; } return true; }