@Test public void readValueByXPathExp() throws Exception { String simpleDefaultStringElement = prepareElement(STRING_TAG, DEFAULT_STRING); String simpleStringElement = prepareElement(STRING_TAG, stringValue); String grandChildXml = prepareElement(XML_GRAND_CHILD_TAG, simpleStringElement); String childXml = prepareElement(XML_CHILD_TAG, grandChildXml); String rootXml = prepareElement(XML_ROOT_TAG, simpleDefaultStringElement + childXml); xsr = new XmlSettingsReader(rootXml); String xPath = "descendant::" + XML_GRAND_CHILD_TAG; String readStringPropertyByXPath = xsr.getStringPropertyByXPath(xPath, STRING_TAG, DEFAULT_STRING); assertNotEquals(stringValue, DEFAULT_INT); assertEquals(stringValue, readStringPropertyByXPath); }
public String getStringPropertyByXPath(String xPathExp, String tagName) { return getStringPropertyByXPath(xPathExp, tagName, null); }
XmlSettingsReader { public String getStringPropertyByXPath(String xPathExp, String tagName) { return getStringPropertyByXPath(xPathExp, tagName, null); } }
XmlSettingsReader { public String getStringPropertyByXPath(String xPathExp, String tagName) { return getStringPropertyByXPath(xPathExp, tagName, null); } XmlSettingsReader(String xmlString); }
XmlSettingsReader { public String getStringPropertyByXPath(String xPathExp, String tagName) { return getStringPropertyByXPath(xPathExp, tagName, null); } XmlSettingsReader(String xmlString); int getIntProperty(String xPathExp, String tagName, int defaultVal); String getStringPropertyByXPath(String xPathExp, String tagName); String getStringPropertyByXPath(String xPathExp, String tagName, String defaultVal); boolean getBooleanProperty(String xPathExp, String tagName, boolean defaultVal); String getStringProperty(String tagName); File getFileProperty(String tagName); String getStringProperty(String tagName, String defaultValue); List<String> getStringListProperty(String tagName); Map<String, Boolean> getStringKeyedBooleanMapProperty(String tagName); Map<String, T> getStringKeyedMapProperty(String tagName, Function<String, T> mapFunction); T getComplexType(String tagName, Class<T> targetClass); }
XmlSettingsReader { public String getStringPropertyByXPath(String xPathExp, String tagName) { return getStringPropertyByXPath(xPathExp, tagName, null); } XmlSettingsReader(String xmlString); int getIntProperty(String xPathExp, String tagName, int defaultVal); String getStringPropertyByXPath(String xPathExp, String tagName); String getStringPropertyByXPath(String xPathExp, String tagName, String defaultVal); boolean getBooleanProperty(String xPathExp, String tagName, boolean defaultVal); String getStringProperty(String tagName); File getFileProperty(String tagName); String getStringProperty(String tagName, String defaultValue); List<String> getStringListProperty(String tagName); Map<String, Boolean> getStringKeyedBooleanMapProperty(String tagName); Map<String, T> getStringKeyedMapProperty(String tagName, Function<String, T> mapFunction); T getComplexType(String tagName, Class<T> targetClass);  }