From b2f263e5ed4352d3f851667b3331fc7201adbef7 Mon Sep 17 00:00:00 2001 From: paul-loedige Date: Mon, 4 Jan 2021 23:20:46 +0100 Subject: [PATCH] value info is no longer needed --- .../com/example/aped/utils/XMLHandler.java | 46 ------------------- .../com/example/aped/XMLHandlerUnitTest.java | 24 ---------- 2 files changed, 70 deletions(-) diff --git a/APED/app/src/main/java/com/example/aped/utils/XMLHandler.java b/APED/app/src/main/java/com/example/aped/utils/XMLHandler.java index 52d388a..8a91098 100644 --- a/APED/app/src/main/java/com/example/aped/utils/XMLHandler.java +++ b/APED/app/src/main/java/com/example/aped/utils/XMLHandler.java @@ -70,52 +70,6 @@ public class XMLHandler implements IXML { return returnList; } - /** - * reads the value info from the XML file. - * @param deviceName the name of the relevant device - * @return the value info as a dictionary {'unit','type','Offset','Factor'} - */ - @Override - public Dictionary getValueInfo(final String deviceName) { - Dictionary returnDictionary = new Hashtable<>(); - XPathFactory xPathFactory = XPathFactory.newInstance(); - XPath xPath = xPathFactory.newXPath(); - try { - XPathExpression xPathExpression = xPath.compile( - "//Device[@name='" + deviceName + "']/ValueInfo"); - Element result = (Element) xPathExpression.evaluate( - root, XPathConstants.NODE); - returnDictionary.put("type", result.getAttribute("type")); - returnDictionary.put("unit", result.getAttribute("unit")); - NodeList childNodes = result.getChildNodes(); - float offset = 0.0f; - float factor = 1.0f; - for (int i = 0; i < childNodes.getLength(); i++) { - switch (childNodes.item(i).getNodeName()) { - case "Offset": - offset = Float.parseFloat(childNodes.item(i) - .getTextContent()); - break; - case "Factor": - factor = Float.parseFloat(childNodes.item(i) - .getTextContent()); - break; - default: - break; - } - } - returnDictionary.put("offset", offset); - returnDictionary.put("factor", factor); - } catch (XPathExpressionException e) { - Log.e( - "XMLHandler", - "the XPath for getting the value info has errors:" - + e.getMessage() - ); - } - return returnDictionary; - } - /** * reads the port information from the XML file. * @param deviceName the name of the relevant device diff --git a/APED/app/src/test/java/com/example/aped/XMLHandlerUnitTest.java b/APED/app/src/test/java/com/example/aped/XMLHandlerUnitTest.java index b8072a6..00f6789 100644 --- a/APED/app/src/test/java/com/example/aped/XMLHandlerUnitTest.java +++ b/APED/app/src/test/java/com/example/aped/XMLHandlerUnitTest.java @@ -43,30 +43,6 @@ public class XMLHandlerUnitTest { } } - @Test - public void TestInput_SimpleValueInfo(){ - try{ - XMLHandler xmlHandler = new XMLHandler(xmlFile); - Dictionary valueInfo = xmlHandler.getValueInfo("example"); - assertEquals("{factor=1.0, type=boolean, unit=, offset=0.0}",valueInfo.toString()); - }catch(IOException | ParserConfigurationException | SAXException e){ - System.out.println("XMLHandler failed"); - assert(false); - } - } - - @Test - public void TestInput_ComplexValueInfo(){ - try{ - XMLHandler xmlHandler = new XMLHandler(xmlFile); - Dictionary valueInfo = xmlHandler.getValueInfo("sensorarray"); - assertEquals("{factor=2.5, type=int, unit=°C, offset=1.2}",valueInfo.toString()); - }catch(IOException | ParserConfigurationException | SAXException e){ - System.out.println("XMLHandler failed"); - assert(false); - } - } - @Test public void TestInput_SimplePort(){ try{