public String getMacIcon() { Element domLauncher = dom.getChild("launcher"); if (domLauncher == null) { return null; } Element linux = domLauncher.getChild("macosx"); if (linux == null) { return null; } return linux.getAttributeValue("icon"); }
public List<Element> getArtifacts() { Element artifacts = iuDom.getChild(ARTIFACTS); if (artifacts == null) return null; return artifacts.getChildren(ARTIFACT); }
public void setDescriptionURL(String descriptionURL) { Element descElement = dom.getChild("description"); if (descElement == null) { descElement = new Element("description"); dom.addNode(descElement); } descElement.setAttribute("url", descriptionURL); }
public void addArtifact(String classifier, String id, String version) { Element artifacts = iuDom.getChild(ARTIFACTS); if (artifacts == null) { artifacts = new Element(ARTIFACTS); iuDom.addNode(artifacts); } Element newArtifact = new Element(ARTIFACT); newArtifact.addAttribute(CLASSIFIER, classifier); newArtifact.addAttribute(ID, id); newArtifact.addAttribute(VERSION, version); artifacts.addNode(newArtifact); }
public Map<String, BundleConfiguration> getPluginConfiguration() { Element configurationsDom = dom.getChild("configurations"); if (configurationsDom == null) { return null; } Map<String, BundleConfiguration> configs = new HashMap<>(); for (Element pluginDom : configurationsDom.getChildren("plugin")) { configs.put(pluginDom.getAttributeValue("id"), new BundleConfiguration(pluginDom)); } return Collections.unmodifiableMap(configs); }
public static void addParentNamespaces(Element element, Parent parent) { if (parent instanceof Element) { for (Attribute attr : ((Element) parent).getAttributes()) { String name = attr.getName(); if (name.startsWith("xmlns") && element.getAttributeValue(name) == null) { element.setAttribute(name, attr.getValue()); } } addParentNamespaces(element, ((Element) parent).getParent()); } }
public String getPatch() { String patch = dom.getAttributeValue("patch"); if (patch == null) { return "false"; } else { return patch; } } }
public List<Element> getRequiredCapabilites() { List<Element> requires = iuDom.getChildren(REQUIRES); if (requires == null || requires.size() == 0) return null; return requires.get(0).getChildren(REQUIRED); }
public void removeRootInstalledFeatures() { Element featuresDom = dom.getChild("features"); if (featuresDom != null) { for (int childIx = featuresDom.getNodes().size() - 1; childIx > 0; --childIx) { Node nodeDom = featuresDom.getNode(childIx); if (nodeDom instanceof Element) { Element elementDom = (Element) nodeDom; if (parseFeature(elementDom).getInstallMode() == FeatureRef.InstallMode.root) { featuresDom.removeNode(childIx); } } } } }
public Map<String, String> getArchives() { Map<String, String> archives = new HashMap<>(); for (Element archiveDom : dom.getChildren("archive")) { String path = archiveDom.getAttributeValue("path"); String url = archiveDom.getAttributeValue("url"); archives.put(path, url); } return Collections.unmodifiableMap(archives); }
public static List<Element> findElementsWithName(Element rootElement, String elementName) { List<Element> answer = new ArrayList<>(); List<Element> children = rootElement.getChildren(); for (Element child : children) { if (Objects.equal(elementName, child.getName())) { answer.add(child); } else { answer.addAll(findElementsWithName(child, elementName)); } } return answer; }
public String getChildPath () { if (getParent () == null) return getName (); Element p = getParentElement (); if (p == null) return "/" + getName (); int index = p.childIndexOf (this); if (index == 0) return p.getChildPath () + "/" + getName (); return p.getChildPath () + "/" + getName () + "[" + index + "]"; }
public void setLocation( String location ) { dom.setAttribute( "location", location ); } }
protected void replaceCamelElement(Element docElem, Node camelElem, Node oldNode) { replaceChild(docElem, camelElem, oldNode); // lets replace the camel namespace, copying any namespace from the old node as well if (camelElem instanceof Element && oldNode instanceof Element) { for (Attribute attr : ((Element) oldNode).getAttributes()) { if (attr.getName().startsWith("xmlns")) { ((Element) camelElem).setAttribute(attr.getName(), attr.getValue()); } } } }
protected static Element findOrCreateDescriptionOnNextElement(Element element, int commentIndex, Parent root) { // lets find the next peer element node and if it can contain a description lets use that List<Node> nodes = element.getNodes(); Node[] array = nodes.toArray(new Node[nodes.size()]); for (int i = commentIndex + 1; i < array.length; i++) { if (array[i] instanceof Element) { if (elementsWithDescription().contains(element.getName())) { return findOrCreateDescrptionElement((Element) array[i], root); } } } return findOrCreateDescrptionElement(element, root); }
public Element checkMandatoryAttribute (String name) { Attribute a = getAttribute (name); if (a == null) throw new XMLParseException ("Element "+getName ()+" has no attribute "+name); return this; }
@Override public boolean matches (Node n) { if (!isElement (n)) return false; Element e = (Element)n; boolean match = true; if (match && name != null && !e.getName ().equals (name)) match = false; if (match && ns != null && !ns.equals (getNamespace ())) match = false; return match; } };