private Map<String, String> readInitParams(Node configData) { Map<String, String> paramMap = new HashMap<>(); List<Node> params = configData.selectNodes("init-params/init-param"); for (Node param : params) { String paramName = param.selectSingleNode("param-name").getStringValue(); String paramValue = param.selectSingleNode("param-value").getStringValue(); paramMap.put(paramName, paramValue); } return paramMap; }
private static String getChildText(Node node, String childName) throws PluginException { Node child = node.selectSingleNode(childName); if (child == null) { throw new PluginException("Could not find child \"" + childName + "\" for node"); } return child.getText(); }
private void registerCache(String pluginName, Node configData) { String cacheName = configData.selectSingleNode("cache-name").getStringValue(); String schemeName = configData.selectSingleNode("scheme-name").getStringValue(); if (cacheName == null || schemeName == null) { throw new IllegalArgumentException("Both cache-name and scheme-name elements are required. Found cache-name: " + cacheName + " and scheme-name: " + schemeName); } Map<String, String> initParams = readInitParams(configData); CacheInfo info = new CacheInfo(cacheName, CacheInfo.Type.valueof(schemeName), initParams); PluginCacheRegistry.getInstance().registerCache(pluginName, info); }
} else { Node n = node.selectSingleNode( XPathValue ); if ( n != null ) { nodevalue = n.asXML();
@Nullable private Node getErrorMessageNode(@NotNull Node testNode, @NotNull String namespacePrefix) { if (namespacePrefix.equals(VS_2006_PREFIX)) { return testNode.selectSingleNode(namespacePrefix + "Output"); } else { return testNode.selectSingleNode(namespacePrefix + "Output/" + namespacePrefix + "ErrorInfo/" + namespacePrefix + "Message"); } }
SAXReader reader = new SAXReader(); Document document = reader.read(file); List<Node> nodes = document.selectNodes("/options/category/option"); for (Node node : nodes) { System.out.println("caption: " + node.selectSingleNode("control/caption").getText()); System.out.println("value : " + node.selectSingleNode("value").getText()); }
public int compare(Object o1, Object o2) { try { Double pos1 = Double.parseDouble(((Node) o1).selectSingleNode("Position").getText()); Double pos2 = Double.parseDouble(((Node) o2).selectSingleNode("Position").getText()); return pos1.compareTo(pos2); } catch (Exception e) { return 0; } } }
public int compare(Object o1, Object o2) { try { Double pos1 = Double.parseDouble(((Node) o1).selectSingleNode("Sort").getText()); Double pos2 = Double.parseDouble(((Node) o2).selectSingleNode("Sort").getText()); return pos1.compareTo(pos2); } catch (Exception e) { return 0; } } }
public static String getNodeText( final String xpath, final Node rootNode, final String defaultValue ) { if ( rootNode == null ) { return ( defaultValue ); } Node node = rootNode.selectSingleNode( xpath ); if ( node == null ) { return defaultValue; } return node.getText(); }
public Map<String, String> getDefaultClassesConfigForKey(String key) throws DocumentException, IOException { Map<String, String> defaults = new HashMap<>(); for (Node node : defaultsBaseNodes) { Node defaultsNode = node.selectSingleNode(key); if (defaultsNode != null) defaults.putAll(XMLConfigUtil.parseRepositoryElementForClassNames((Element) defaultsNode)); } return defaults; }
/** * Executes the specified XPath query as a single node query, returning the text value of the resulting single node. */ public static String selectSingleNodeValue(Node node, String xpathQuery) { Node resultNode = node.selectSingleNode(xpathQuery); if (resultNode != null) { return resultNode.getText(); } else { return null; } }
private Map<String, String> readInitParams(Node configData) { Map<String, String> paramMap = new HashMap<>(); List<Node> params = configData.selectNodes("init-params/init-param"); for (Node param : params) { String paramName = param.selectSingleNode("param-name").getStringValue(); String paramValue = param.selectSingleNode("param-value").getStringValue(); paramMap.put(paramName, paramValue); } return paramMap; }
private Optional<Duration> parseDuration(@NotNull Node testNode) { // duration will be in hh:mm:ss.mmmmmmm format final Node durationAttr = testNode.selectSingleNode("@duration"); if (durationAttr != null) { return convertDuration(durationAttr.getStringValue()); } return Optional.empty(); }
private String getSingleNodeTextSafe(Node node, String tag) { Node nodeWithTag = node.selectSingleNode(tag); if(nodeWithTag != null) return nodeWithTag.getText(); else throw new RuntimeException("Node with tag "+tag+" not found in "+node.getPath()); }
private String getSingleNodeTextSafe(Node node, String tag) { Node nodeWithTag = node.selectSingleNode(tag); if(nodeWithTag != null) return nodeWithTag.getText(); else throw new RuntimeException("Node with tag "+tag+" not found in "+node.getPath()); }
private String getSingleNodeTextSafe(Node node, String tag) { Node nodeWithTag = node.selectSingleNode(tag); if(nodeWithTag != null) return nodeWithTag.getText(); else throw new RuntimeException("Node with tag "+tag+" not found in "+node.getPath()); }
private static String getChildText(Node node, String childName) throws PluginException { Node child = node.selectSingleNode(childName); if (child == null) { throw new PluginException("Could not find child \"" + childName + "\" for node"); } return child.getText(); }
@Override public String apply(Tuple<String, Node> data) { final String[] keyParts = splitKey(data.first); final Node node = data.second.selectSingleNode( "/permission-set/principal/child::node()/child::text()"); final String principal = node.getText(); return principal + "__" + keyParts[3] + "__" + keyParts[0]; } }
protected Object getInputValue( final String inputName ) { // first check to see if we have an input parameter that we can use for // this. if ( runtimeContext.getInputNames().contains( inputName ) ) { return runtimeContext.getInputParameterValue( inputName ); } // now check the component node from the action definition. Node node = componentDefinition.selectSingleNode( inputName ); if ( node == null ) { return null; } return node.getText(); }
private void registerCache(String pluginName, Node configData) { String cacheName = configData.selectSingleNode("cache-name").getStringValue(); String schemeName = configData.selectSingleNode("scheme-name").getStringValue(); if (cacheName == null || schemeName == null) { throw new IllegalArgumentException("Both cache-name and scheme-name elements are required. Found cache-name: " + cacheName + " and scheme-name: " + schemeName); } Map<String, String> initParams = readInitParams(configData); CacheInfo info = new CacheInfo(cacheName, CacheInfo.Type.valueof(schemeName), initParams); PluginCacheRegistry.getInstance().registerCache(pluginName, info); }