@Override public boolean hasAttributes() { return node.hasAttributes(); }
/** * @see org.w3c.dom.Node#hasAttributes() */ public boolean hasAttributes() { return m_attributeNode.hasAttributes(); }
private void parseAttrList(NodeList nodeList) { for (int count = 0; count < nodeList.getLength(); count++) { Node tempNode = nodeList.item(count); if (tempNode.getNodeType() == Node.ELEMENT_NODE && tempNode.hasAttributes() && tempNode.hasChildNodes()) { String name = null; NamedNodeMap nodeMap = tempNode.getAttributes(); for (int i = 0; i < nodeMap.getLength(); i++) { Node node = nodeMap.item(i); if (node.getNodeName().equals("name")) { name = node.getNodeValue(); break; } } if (name != null && tempNode.getNodeName().equals("attr")) { parseValues(name, tempNode.getChildNodes()); } else { parseAttrList(tempNode.getChildNodes()); } } } }
/** * Climb through <code>node</code>'s ancestors, looking for one with an attribute named <code>attributeName</code>, * irrespective of the respective <code>ancestorName</code>, and return the attribute's value * * @param node * node * @param attributeName * attributeName * @return value of attribute from closest ancestor with that attribute, or the empty string if no ancestor has that * attribute. * */ public static String getAttributeFromClosestAncestorOfAnyKind(Node node, String attributeName) { Node parentNode; while (node != null && (parentNode = node.getParentNode()) != null) { if (parentNode.hasAttributes()) { Element parentElement = (Element) parentNode; if (parentElement.hasAttribute(attributeName)) { return parentElement.getAttribute(attributeName); } } node = parentNode; } return ""; }
private void removeEmptyNodes( NodeList nodes ) { for ( int i = 0; i < nodes.getLength(); i++ ) { Node node = nodes.item( i ); // Process the tree bottom-up if ( node.hasChildNodes() ) { removeEmptyNodes( node.getChildNodes() ); } boolean nodeIsEmpty = node.getNodeType() == Node.ELEMENT_NODE && !node.hasAttributes() && !node.hasChildNodes() && node.getTextContent().length() == 0; if ( nodeIsEmpty ) { // We shifted elements left, do not increment counter node.getParentNode().removeChild( node ); i--; } } } }
Node tempNode = nodeList.item(count); if (tempNode.getNodeType() == Node.ELEMENT_NODE && tempNode.hasAttributes()) { if (attr == null) { if (tempNode.getNodeName().equals("enum")) {
/** * Climb through <code>node</code>'s ancestors, looking for one with an attribute named <code>attributeName</code>, * irrespective of the respective <code>ancestorName</code>, and return the attribute's value * * @param node * node * @param attributeName * attributeName * @return value of attribute from closest ancestor with that attribute, or the empty string if no ancestor has that * attribute. * */ public static String getAttributeFromClosestAncestorOfAnyKind(Node node, String attributeName) { Node parentNode; while (node != null && (parentNode = node.getParentNode()) != null) { if (parentNode.hasAttributes()) { Element parentElement = (Element) parentNode; if (parentElement.hasAttribute(attributeName)) { return parentElement.getAttribute(attributeName); } } node = parentNode; } return ""; }
public List<Object[]> getParameters(Element element) { List<Object[]> allParameters = Lists.newArrayList(); if (m_onElement != null) { List<Object> result = Lists.newArrayList(); for (String attributeName : m_onElement.attributes()) { result.add(element.getAttribute(attributeName)); } allParameters.add(result.toArray()); } else if (m_tag != null) { List<Object> result = Lists.newArrayList(); result.add(m_bean); allParameters.add(result.toArray()); } else { NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { if (childNodes.item(i).hasAttributes()) { Element item = (Element) childNodes.item(i); List<Object> result = Lists.newArrayList(); for (String attributeName : m_onElementList.attributes()) { result.add(item.getAttribute(attributeName)); } allParameters.add(result.toArray()); } } } return allParameters; } }
public List<Object[]> getParameters(Element element) { List<Object[]> allParameters = Lists.newArrayList(); if (m_onElement != null) { List<Object> result = Lists.newArrayList(); for (String attributeName : m_onElement.attributes()) { result.add(element.getAttribute(attributeName)); } allParameters.add(result.toArray()); } else if (m_tag != null) { List<Object> result = Lists.newArrayList(); result.add(m_bean); allParameters.add(result.toArray()); } else { NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { if (childNodes.item(i).hasAttributes()) { Element item = (Element) childNodes.item(i); List<Object> result = Lists.newArrayList(); for (String attributeName : m_onElementList.attributes()) { result.add(item.getAttribute(attributeName)); } allParameters.add(result.toArray()); } } } return allParameters; } }
if (n.hasAttributes()) { NamedNodeMap atts = n.getAttributes(); int length = atts.getLength();
if (node.hasAttributes()) { if (node.getNodeType() == Node.ELEMENT_NODE && semanticAttributes && node.hasAttributes() && (node.getAttributes().getNamedItem(VALUE) != null || node.getAttributes().getNamedItem(LOCATION) != null
if (el.hasAttributes() || el.hasChildNodes()) { if (el.getChildNodes().getLength() == 1 && el.getFirstChild().getNodeType() == Node.TEXT_NODE) { ReferenceMemory one = result.getByScalar(el.getNodeName());
private static String getFirstAttribute(Node node, String ns, String name) { if (node.hasAttributes()) { NamedNodeMap attrs = node.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Node attr = attrs.item(i); if (attr.getLocalName().equals(name)) { return attr.getNodeValue(); } } } return null; }
private void parseStandardMappings(Element root, Map<String, ColorThemeMapping> mappings) { Node mappingsNode = root.getElementsByTagName("mappings").item(0); NodeList mappingNodes = mappingsNode.getChildNodes(); for (int i = 0; i < mappingNodes.getLength(); i++) { Node mappingNode = mappingNodes.item(i); if (mappingNode.hasAttributes()) { String pluginKey = extractAttribute(mappingNode, "pluginKey"); String themeKey = extractAttribute(mappingNode, "themeKey"); mappings.put(pluginKey, createMapping(pluginKey, themeKey)); } } }
private void parseSemanticHighlightingMappings(Element root, Map<String, ColorThemeMapping> mappings) { Node mappingsNode = root.getElementsByTagName("semanticHighlightingMappings").item(0); if (mappingsNode != null) { NodeList mappingNodes = mappingsNode.getChildNodes(); for (int i = 0; i < mappingNodes.getLength(); i++) { Node mappingNode = mappingNodes.item(i); if (mappingNode.hasAttributes()) { String pluginKey = extractAttribute(mappingNode, "pluginKey"); String themeKey = extractAttribute(mappingNode, "themeKey"); mappings.put(pluginKey, createSemanticHighlightingMapping(pluginKey, themeKey)); } } } }
/** * Add element to priority list examining node attributes: priority (for urls) and type (for checksums) */ protected static void addPriorityListElementExaminingNode(String tagName, Node node, List<Pair<String, Integer>> priorityList) { Integer priority = Integer.MAX_VALUE; String first = node.getTextContent(); if (node.hasAttributes()) { NamedNodeMap attributes = node.getAttributes(); for (int k=0; k<attributes.getLength(); k++) { Node attr = attributes.item(k); if (tagName.equals("url") && attr.getNodeName().equals("priority")) { String prio = attr.getNodeValue().replace("\"", ""); priority = Integer.parseInt(prio); break; } else if (tagName.equals("hash") && attr.getNodeName().equals("type")) { first = "{" + attr.getNodeValue() + "}" + first; break; } } } priorityList.add(new Pair<>(first, priority)); }
static <T> T forAllAttributesUntil(final Node node, final T defaultValue, final String xmlns, final String[] attributeNames, final Function<Node, T> function) { if (node.hasAttributes()) { final String xmlnsPrefix = xmlnsPrefix(node, xmlns); final NamedNodeMap attributes = node.getAttributes(); int iMax = attributes.getLength(); for (int i = 0; i < iMax; i++) { Node item = attributes.item(i); if (attributeNames == null || attributeNames.length == 0) { // pass all children T result = function.apply(item); if (result != null) { return result; } } else { for (String attributeName : attributeNames) { if (item.getNodeName().equals(xmlnsPrefix + attributeName)) { T result = function.apply(item); if (result != null) { return result; } } } } } } return defaultValue; }
for (int i = 0; i < entryNodes.getLength(); i++) { Node entryNode = entryNodes.item(i); if (entryNode.hasAttributes()) { String color = entryNode.getAttributes().getNamedItem("color") .getNodeValue(); for (int i = 0; i < nodeListEclipseColorThemeMapping.getLength(); ++i) { Node eclipseColorThemeMapping = nodeListEclipseColorThemeMapping.item(i); if (eclipseColorThemeMapping.hasAttributes()) { String pluginId = eclipseColorThemeMapping.getAttributes().getNamedItem("plugin").getNodeValue(); Map<String, ColorThemeMapping> mapMappings = new HashMap<String, ColorThemeMapping>();
ColorMap symbol = factory.createColorMap(); if (root.hasAttributes()) {
private static String getFirstAttribute(Node node, String ns, String name) { if (node.hasAttributes()) { NamedNodeMap attrs = node.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Node attr = attrs.item(i); if (attr.getLocalName().equals(name)) { return attr.getNodeValue(); } } } return null; }