List of utility methods to do XML NodeList
String | mergeTextContent(NodeList nodes) based on the following quote from public Java5 javadoc of org.w3c.dom.Node.getTextContent method: "concatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. StringBuffer buf = new StringBuffer(); for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.item(i); final String text; switch (n.getNodeType()) { case Node.COMMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: text = null; ... |
Object | parserXml(NodeList employees, Class extends Map> class_type) parser Xml Map map = class_type.newInstance(); String value = null; for (int i = 0; i < employees.getLength(); i++) { Node employee = employees.item(i); if (employee.getNodeType() != 8) if (employee.getNodeType() == 1 || employee.getNodeValue() == null || employee.getNodeValue().trim().isEmpty()) { if (employee.hasChildNodes() || employee.hasAttributes()) { ... |
Map | parseSwitcherConfigs(NodeList switcherConfigNodes) parse Switcher Configs Map<String, String> configs = new HashMap<>(); for (int i = 0; i < switcherConfigNodes.getLength(); ++i) { NamedNodeMap attributes = switcherConfigNodes.item(i).getAttributes(); if (attributes != null) { String[] keyValue = parseConfigAttr(attributes); configs.put(keyValue[0], keyValue[1]); return configs; |
Map | parseSwitchers(NodeList switcherNodes) parse Switchers Map<String, Map<String, String>> switchers = new HashMap<>(); for (int i = 0; i < switcherNodes.getLength(); ++i) { Node switcherNode = switcherNodes.item(i); NamedNodeMap switcherAttributes = switcherNode.getAttributes(); if (switcherAttributes != null) { String switcherClassName = switcherAttributes.getNamedItem("class").getTextContent(); Map<String, String> configs = parseSwitcherConfigs(switcherNode.getChildNodes()); switchers.put(switcherClassName, configs); ... |
Map | parseWidget(NodeList widgetList) parse Widget Map map = new HashMap(); try { for (int i = 0; i < widgetList.getLength(); i++) { Node widget = widgetList.item(i); if (widget.getNodeName().equals("widget")) { String id = widget.getAttributes().getNamedItem("id").getTextContent(); Map attrMap = parseAttribute(widget.getChildNodes()); map.put(id, attrMap); ... |
void | prettyPrintLoop(NodeList nodes, StringBuilder string, String indentation) pretty Print Loop for (int index = 0; index < nodes.getLength(); index++) { prettyPrintLoop(nodes.item(index), string, indentation); |
void | printNode(NodeList nodeList, int level) print Node level++; if (nodeList != null && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { System.out.println(node.getNodeName() + "[" + level + "]"); printNode(node.getChildNodes(), level); if (level > depthOfXML) ... |
void | printNodeList(NodeList nodes) print Node List for (int i = 0; i < nodes.getLength(); i++) { System.out.println(nodes.item(i).getNodeValue()); |
void | printNodeTypes(NodeList rows) For testing purpose, it print out Node list System.out.println("\tenumerating NodeList (of Elements):"); System.out.println("\tClass\tNT\tNV"); for (int ri = 0; ri < rows.getLength(); ri++) { Node n = (Node) rows.item(ri); if (n instanceof Element) { System.out.print("\tElement"); } else System.out.print("\tNode"); ... |
void | removeBlankTextNode(NodeList nodes) remove Blank Text Node for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (Node.TEXT_NODE == node.getNodeType() && 0 == node.getNodeValue().trim().length()) { removeNode(node); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); ... |