List of utility methods to do XML Attribute Get
boolean | getBooleanAttributeOption(final Element configuration, final String option, boolean defaultValue) get Boolean Attribute Option if (configuration == null) { return defaultValue; String value = configuration.getAttribute(option); return Boolean.valueOf(value).booleanValue(); |
Boolean | getBooleanAttributeOptional(Node node, String attributeName, Boolean valueIfEmpty) get Boolean Attribute Optional String string = getStringAttributeOptional(node, attributeName, null); if (string == null) { return valueIfEmpty; if (VALUE_TRUE.equals(string)) { return true; } else if (VALUE_FALSE.equals(string)) { return false; ... |
boolean | getBooleanAttributeRequired(Node node, String attributeName) get Boolean Attribute Required String string = getStringAttributeRequired(node, attributeName); if (VALUE_TRUE.equals(string)) { return true; } else if (VALUE_FALSE.equals(string)) { return false; throw new Exception("Could not read boolean from value '" + string + "' in attribute '" + attributeName + "' in node '" + node.getLocalName() + "'"); ... |
Boolean | getBooleanAttributeValue(Node node, String attribute) get Boolean Attribute Value String value = getAttributeValue(node, attribute); if (value == null) return null; if (value.equals("1")) return true; if (value.equals("true")) return true; return false; ... |
String | getCascadeValue(final Element elem, final String attrName) Get cascaded attribute value. Element current = elem; while (current != null) { final Attr attr = current.getAttributeNode(attrName); if (attr != null) { return attr.getValue(); final Node parent = current.getParentNode(); if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { ... |
Element | getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName) Search upwards through the ancestors of node with name ancestorName , and return the first ancestor for which an attribute named attributeName is present.
for (Node a = getAncestor(node, ancestorName); a != null; a = getAncestor(a, ancestorName)) { if (a.getNodeType() == Node.ELEMENT_NODE && ((Element) a).hasAttribute(attributeName)) { return (Element) a; return null; |
Element | getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName) Search upwards through the ancestors of node with name ancestorName , and return the first ancestor for which an attribute named attributeName is present.
for (Node a = getAncestor(node, ancestorName); a != null; a = getAncestor(a, ancestorName)) { if (a.getNodeType() == Node.ELEMENT_NODE && ((Element) a).hasAttribute(attributeName)) { return (Element) a; return null; |
String | getCurrentLevelAttributeTextValue(Element ele, String attribute) get Current Level Attribute Text Value if (ele == null || attribute == null) { return null; } else { return ele.getAttribute(attribute); |
Node | getDirectAttribute(Node node, String name) get Direct Attribute Node attribute = null; NamedNodeMap attributes = node.getAttributes(); if (attributes != null) { attribute = attributes.getNamedItem(name); return attribute; |
String | getDivHeadAttr(Element annotU, String attrName) get Div Head Attr String a = annotU.getAttribute(attrName); if (a == null || a.isEmpty()) return getHeadAttr(annotU, attrName); return a; |