List of usage examples for org.w3c.dom Node getNextSibling
public Node getNextSibling();
From source file:org.eclipse.ecr.common.xmap.DOMHelper.java
public static void visitAttributes(Context ctx, XAnnotatedList xam, Node base, String name, String attrName, NodeVisitor visitor, Collection<Object> result) { Node p = base.getFirstChild(); while (p != null) { if (p.getNodeType() == Node.ELEMENT_NODE) { if (name.equals(p.getNodeName())) { Node at = p.getAttributes().getNamedItem(attrName); if (at != null) { visitor.visitNode(ctx, xam, at, result); }//w ww .j av a2 s .c om } } p = p.getNextSibling(); } }
From source file:org.eclipse.ecr.common.xmap.DOMHelper.java
public static void visitElements(Context ctx, XAnnotatedList xam, Node base, String name, NodeVisitor visitor, Collection<Object> result) { Node p = base.getFirstChild(); while (p != null) { if (p.getNodeType() == Node.ELEMENT_NODE) { if (name.equals(p.getNodeName())) { visitor.visitNode(ctx, xam, p, result); }//from w ww . ja v a 2 s . com } p = p.getNextSibling(); } }
From source file:org.eclipse.ecr.common.xmap.DOMHelper.java
public static void visitMapAttributes(Context ctx, XAnnotatedMap xam, Node base, String name, String attrName, NodeMapVisitor visitor, Map<String, Object> result) { Node p = base.getFirstChild(); while (p != null) { if (p.getNodeType() == Node.ELEMENT_NODE) { if (name.equals(p.getNodeName())) { Node at = p.getAttributes().getNamedItem(attrName); if (at != null) { String key = getNodeValue((Element) p, xam.key); if (key != null) { visitor.visitNode(ctx, xam, at, key, result); }// w ww . j av a 2s.co m } } } p = p.getNextSibling(); } }
From source file:org.eclipse.ecr.common.xmap.DOMHelper.java
public static void visitMapElements(Context ctx, XAnnotatedMap xam, Node base, String name, NodeMapVisitor visitor, Map<String, Object> result) { Node p = base.getFirstChild(); while (p != null) { if (p.getNodeType() == Node.ELEMENT_NODE) { if (name.equals(p.getNodeName())) { String key = getNodeValue((Element) p, xam.key); if (key != null) { visitor.visitNode(ctx, xam, p, key, result); }/*w ww .j av a 2 s .co m*/ } } p = p.getNextSibling(); } }
From source file:org.eclipse.ecr.common.xmap.DOMHelper.java
/** * Gets the first child element node having the given name. *//*from www .j a v a2s .c om*/ public static Node getElementNode(Node base, String name) { Node node = base.getFirstChild(); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE) { if (name.equals(node.getNodeName())) { return node; } } node = node.getNextSibling(); } return null; }
From source file:org.eclipse.ecr.runtime.model.persistence.fs.FileSystemStorage.java
public static void loadMetadata(Contribution contrib) { try {// w w w . jav a2 s .com DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.parse(new ByteArrayInputStream(contrib.getContent().getBytes())); Element root = doc.getDocumentElement(); contrib.setDisabled(Boolean.parseBoolean(root.getAttribute("disabled"))); Node node = root.getFirstChild(); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE && "documentation".equals(node.getNodeName())) { break; } node = node.getNextSibling(); } if (node != null) { node = node.getFirstChild(); StringBuilder buf = new StringBuilder(); while (node != null) { if (node.getNodeType() == Node.TEXT_NODE) { buf.append(node.getNodeValue()); } node = node.getNextSibling(); } contrib.setDescription(buf.toString().trim()); } else { contrib.setDescription(""); } } catch (Exception e) { log.error("Failed to read contribution metadata", e); } }
From source file:org.eclipse.ecr.runtime.model.persistence.fs.FileSystemStorage.java
@Override public Contribution updateContribution(Contribution contribution) throws Exception { File file = new File(root, contribution.getName() + ".xml"); String content = safeRead(file); DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.parse(new ByteArrayInputStream(content.getBytes())); Element root = doc.getDocumentElement(); if (contribution.isDisabled()) { root.setAttribute("disabled", "true"); } else {//from w w w . j a v a 2s .c o m root.removeAttribute("disabled"); } Node node = root.getFirstChild(); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE && "documentation".equals(node.getNodeName())) { break; } node = node.getNextSibling(); } String description = contribution.getDescription(); if (description == null) { description = ""; } if (node != null) { root.removeChild(node); } Element el = doc.createElement("documentation"); el.appendChild(doc.createTextNode(description)); root.appendChild(el); safeWrite(file, DOMSerializer.toString(doc)); return getContribution(contribution.getName()); }
From source file:org.eclipse.skalli.core.rest.ProjectsV1V2Diff.java
protected boolean hasEmptyChildNode(NodeDetail nodeDetails, String name) { Node node = nodeDetails.getNode().getFirstChild(); while (node != null) { if (name.equals(node.getNodeName())) { return !node.hasChildNodes(); }//from w ww . java 2 s .c o m node = node.getNextSibling(); } return false; }
From source file:org.eclipse.skalli.core.rest.ProjectsV1V2Diff.java
protected boolean hasBooleanChildNode(NodeDetail nodeDetails, String name) { Node node = nodeDetails.getNode().getFirstChild(); while (node != null) { if (name.equals(node.getNodeName())) { return "true".equals(node.getTextContent()) || "false".equals(node.getTextContent()); }// www . ja v a2 s.c om node = node.getNextSibling(); } return false; }
From source file:org.eclipse.skalli.core.rest.ProjectsV1V2Diff.java
protected boolean hasAnyChildNode(NodeDetail nodeDetails, Set<String> names) { Node node = nodeDetails.getNode().getFirstChild(); while (node != null) { if (names.contains(node.getNodeName())) { return true; }// w w w . j a va 2 s . c o m node = node.getNextSibling(); } return false; }