@Test public void testInvalidGetPathNodeTextIgnored() throws Exception { Document document = getBasicDocument(); Assert.assertNull(xmlUtils.getPathNodeText(document, "/sample/subobject/anotherX", true)); }
@Override public String getPathNodeText(Node parentNode, String path, boolean allowNone) throws XPathExpressionException, XmlSearchException { Node subNode = (Node) xPath.evaluate(path, parentNode, XPathConstants.NODE); if (subNode != null) { return subNode.getTextContent(); } if(allowNone) { return null; } throw new XmlSearchException(String.format("Failed to find subnode: %1$s", path)); }
XmlUtilsImpl implements XmlUtils { @Override public String getPathNodeText(Node parentNode, String path, boolean allowNone) throws XPathExpressionException, XmlSearchException { Node subNode = (Node) xPath.evaluate(path, parentNode, XPathConstants.NODE); if (subNode != null) { return subNode.getTextContent(); } if(allowNone) { return null; } throw new XmlSearchException(String.format("Failed to find subnode: %1$s", path)); } }
XmlUtilsImpl implements XmlUtils { @Override public String getPathNodeText(Node parentNode, String path, boolean allowNone) throws XPathExpressionException, XmlSearchException { Node subNode = (Node) xPath.evaluate(path, parentNode, XPathConstants.NODE); if (subNode != null) { return subNode.getTextContent(); } if(allowNone) { return null; } throw new XmlSearchException(String.format("Failed to find subnode: %1$s", path)); }  }
XmlUtilsImpl implements XmlUtils { @Override public String getPathNodeText(Node parentNode, String path, boolean allowNone) throws XPathExpressionException, XmlSearchException { Node subNode = (Node) xPath.evaluate(path, parentNode, XPathConstants.NODE); if (subNode != null) { return subNode.getTextContent(); } if(allowNone) { return null; } throw new XmlSearchException(String.format("Failed to find subnode: %1$s", path)); }  @Override String getDocumentXmlString(Document document); @Override Document createDocument(String rootElementName); @Override Document getDocumentFromString(String inputXml); @Override Node getOrCreateChildNode(String tagName, Node parentNode); @Override String getSubNodeText(Node parentNode, String subNodeName, boolean allowNone); @Override String getPathNodeText(Node parentNode, String path, boolean allowNone); @Override void setSubNodeText(Node filterNode, String subNodeName, String newValue); @Override String getAttributeText(Node node, String attribute); @Override Node appendChildNode(Node parentNode, String nodeName, String nodeValue); @Override String getNodeXmlString(Node node); @Override XPath getxPath(); XmlUtilsImpl setxPath(XPath xPath); }
XmlUtilsImpl implements XmlUtils { @Override public String getPathNodeText(Node parentNode, String path, boolean allowNone) throws XPathExpressionException, XmlSearchException { Node subNode = (Node) xPath.evaluate(path, parentNode, XPathConstants.NODE); if (subNode != null) { return subNode.getTextContent(); } if(allowNone) { return null; } throw new XmlSearchException(String.format("Failed to find subnode: %1$s", path)); }  @Override String getDocumentXmlString(Document document); @Override Document createDocument(String rootElementName); @Override Document getDocumentFromString(String inputXml); @Override Node getOrCreateChildNode(String tagName, Node parentNode); @Override String getSubNodeText(Node parentNode, String subNodeName, boolean allowNone); @Override String getPathNodeText(Node parentNode, String path, boolean allowNone); @Override void setSubNodeText(Node filterNode, String subNodeName, String newValue); @Override String getAttributeText(Node node, String attribute); @Override Node appendChildNode(Node parentNode, String nodeName, String nodeValue); @Override String getNodeXmlString(Node node); @Override XPath getxPath(); XmlUtilsImpl setxPath(XPath xPath);  }