diff --git a/ant.freeform/nbproject/project.xml b/ant.freeform/nbproject/project.xml
--- a/ant.freeform/nbproject/project.xml
+++ b/ant.freeform/nbproject/project.xml
@@ -160,7 +160,7 @@
- 8.0
+ 8.3
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/Actions.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/Actions.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/Actions.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/Actions.java
@@ -42,6 +42,7 @@
package org.netbeans.modules.ant.freeform;
import java.awt.event.ActionEvent;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
@@ -64,7 +65,6 @@
import javax.swing.AbstractAction;
import javax.swing.Action;
import org.apache.tools.ant.module.api.support.ActionUtils;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.modules.ant.freeform.ui.TargetMappingPanel;
import org.netbeans.modules.ant.freeform.ui.UnboundTargetAlert;
import org.netbeans.spi.project.ActionProvider;
@@ -79,10 +79,12 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
+import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.util.actions.SystemAction;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -135,13 +137,13 @@
public String[] getSupportedActions() {
Element genldata = project.getPrimaryConfigurationData();
- Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
if (actionsEl == null) {
return new String[0];
}
// Use a set, not a list, since when using context you can define one action several times:
Set names = new LinkedHashSet();
- for (Element actionEl : Util.findSubElements(actionsEl)) {
+ for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
names.add(actionEl.getAttribute("name")); // NOI18N
}
// #46886: also always enable all common global actions, in case they should be selected:
@@ -168,16 +170,16 @@
}
Element genldata = project.getPrimaryConfigurationData();
- Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
if (actionsEl == null) {
throw new IllegalArgumentException("No commands supported"); // NOI18N
}
boolean foundAction = false;
- for (Element actionEl : Util.findSubElements(actionsEl)) {
+ for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
if (actionEl.getAttribute("name").equals(command)) { // NOI18N
foundAction = true;
// XXX perhaps check also existence of script
- Element contextEl = Util.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element contextEl = XMLUtil.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
if (contextEl != null) {
// Check whether the context contains files all in this folder,
// matching the pattern if any, and matching the arity (single/multiple).
@@ -188,9 +190,9 @@
return true;
} else if (!selection.isEmpty()) {
// Multiple selection; check arity.
- Element arityEl = Util.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element arityEl = XMLUtil.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
assert arityEl != null : "No in for " + command;
- if (Util.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL) != null) { // NOI18N
+ if (XMLUtil.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL) != null) { // NOI18N
// Supports multiple selection, take it.
return true;
}
@@ -232,12 +234,12 @@
}
Element genldata = project.getPrimaryConfigurationData();
- Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
if (actionsEl == null) {
throw new IllegalArgumentException("No commands supported"); // NOI18N
}
boolean foundAction = false;
- for (Element actionEl : Util.findSubElements(actionsEl)) {
+ for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
if (actionEl.getAttribute("name").equals(command)) { // NOI18N
foundAction = true;
runConfiguredAction(project, actionEl, context);
@@ -272,9 +274,9 @@
_files.add(d.getPrimaryFile());
}
Collection extends FileObject> files = _files;
- Element folderEl = Util.findElement(contextEl, "folder", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element folderEl = XMLUtil.findElement(contextEl, "folder", FreeformProjectType.NS_GENERAL); // NOI18N
assert folderEl != null : "Must have in ";
- String rawtext = Util.findText(folderEl);
+ String rawtext = XMLUtil.findText(folderEl);
assert rawtext != null : "Must have text contents in ";
String evaltext = project.evaluator().evaluate(rawtext);
if (evaltext == null) {
@@ -285,9 +287,9 @@
return Collections.emptyMap();
}
Pattern pattern = null;
- Element patternEl = Util.findElement(contextEl, "pattern", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element patternEl = XMLUtil.findElement(contextEl, "pattern", FreeformProjectType.NS_GENERAL); // NOI18N
if (patternEl != null) {
- String text = Util.findText(patternEl);
+ String text = XMLUtil.findText(patternEl);
assert text != null : "Must have text contents in ";
try {
pattern = Pattern.compile(text);
@@ -316,9 +318,9 @@
*/
private static void runConfiguredAction(FreeformProject project, Element actionEl, Lookup context) {
String script;
- Element scriptEl = Util.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element scriptEl = XMLUtil.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
if (scriptEl != null) {
- script = Util.findText(scriptEl);
+ script = XMLUtil.findText(scriptEl);
} else {
script = "build.xml"; // NOI18N
}
@@ -334,13 +336,13 @@
DialogDisplayer.getDefault().notify(nd);
return;
}
- List targets = Util.findSubElements(actionEl);
+ List targets = XMLUtil.findSubElements(actionEl);
List targetNames = new ArrayList(targets.size());
for (Element targetEl : targets) {
if (!targetEl.getLocalName().equals("target")) { // NOI18N
continue;
}
- targetNames.add(Util.findText(targetEl));
+ targetNames.add(XMLUtil.findText(targetEl));
}
String[] targetNameArray;
if (!targetNames.isEmpty()) {
@@ -350,7 +352,7 @@
targetNameArray = null;
}
Properties props = new Properties();
- Element contextEl = Util.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element contextEl = XMLUtil.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
if (contextEl != null) {
Map selection = findSelection(contextEl, context, project);
if (selection.isEmpty()) {
@@ -359,18 +361,18 @@
String separator = null;
if (selection.size() > 1) {
// Find the right separator.
- Element arityEl = Util.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element arityEl = XMLUtil.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
assert arityEl != null : "No in for " + actionEl.getAttribute("name");
- Element sepFilesEl = Util.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element sepFilesEl = XMLUtil.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL); // NOI18N
if (sepFilesEl == null) {
// Only handles single files -> skip it.
return;
}
- separator = Util.findText(sepFilesEl);
+ separator = XMLUtil.findText(sepFilesEl);
}
- Element formatEl = Util.findElement(contextEl, "format", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element formatEl = XMLUtil.findElement(contextEl, "format", FreeformProjectType.NS_GENERAL); // NOI18N
assert formatEl != null : "No in for " + actionEl.getAttribute("name");
- String format = Util.findText(formatEl);
+ String format = XMLUtil.findText(formatEl);
StringBuffer buf = new StringBuffer();
Iterator> it = selection.entrySet().iterator();
while (it.hasNext()) {
@@ -421,9 +423,9 @@
buf.append(separator);
}
}
- Element propEl = Util.findElement(contextEl, "property", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element propEl = XMLUtil.findElement(contextEl, "property", FreeformProjectType.NS_GENERAL); // NOI18N
assert propEl != null : "No in for " + actionEl.getAttribute("name");
- String prop = Util.findText(propEl);
+ String prop = XMLUtil.findText(propEl);
assert prop != null : "Must have text contents in ";
props.setProperty(prop, buf.toString());
}
@@ -431,7 +433,7 @@
if (!propEl.getLocalName().equals("property")) { // NOI18N
continue;
}
- String rawtext = Util.findText(propEl);
+ String rawtext = XMLUtil.findText(propEl);
if (rawtext == null) {
// Legal to have e.g.
rawtext = ""; // NOI18N
@@ -454,12 +456,23 @@
actions.add(CommonProjectActions.newFileAction());
// Requested actions.
Element genldata = p.getPrimaryConfigurationData();
- Element viewEl = Util.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
+
+ // TODO REMOVE THS
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ XMLUtil.write(genldata.getOwnerDocument(), baos, "UTF-8");
+ System.out.println(baos);
+ } catch (IOException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ System.out.println("Done-dump");
+ // REMOVE THIS
+ Element viewEl = XMLUtil.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
if (viewEl != null) {
- Element contextMenuEl = Util.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
if (contextMenuEl != null) {
actions.add(null);
- for (Element actionEl : Util.findSubElements(contextMenuEl)) {
+ for (Element actionEl : XMLUtil.findSubElements(contextMenuEl)) {
if (actionEl.getLocalName().equals("ide-action")) { // NOI18N
String cmd = actionEl.getAttribute("name");
String displayName;
@@ -517,9 +530,9 @@
public boolean isEnabled() {
String script;
- Element scriptEl = Util.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element scriptEl = XMLUtil.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
if (scriptEl != null) {
- script = Util.findText(scriptEl);
+ script = XMLUtil.findText(scriptEl);
} else {
script = "build.xml"; // NOI18N
}
@@ -529,8 +542,8 @@
public Object getValue(String key) {
if (key.equals(Action.NAME)) {
- Element labelEl = Util.findElement(actionEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
- return Util.findText(labelEl);
+ Element labelEl = XMLUtil.findElement(actionEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
+ return XMLUtil.findText(labelEl);
} else {
return super.getValue(key);
}
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/ArtifactProvider.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/ArtifactProvider.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/ArtifactProvider.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/ArtifactProvider.java
@@ -47,16 +47,15 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ant.AntArtifact;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.project.ant.AntArtifactProvider;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.openide.ErrorManager;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -76,7 +75,7 @@
List artifacts = new ArrayList();
Set ids = new HashSet();
HashMap uniqueArtifacts = new HashMap();
- for (Element export : Util.findSubElements(data)) {
+ for (Element export : XMLUtil.findSubElements(data)) {
if (!export.getLocalName().equals("export")) { // NOI18N
continue;
}
@@ -112,9 +111,9 @@
}
public static URI readArtifactLocation(Element export, PropertyEvaluator eval) {
- Element locEl = Util.findElement(export, "location", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element locEl = XMLUtil.findElement(export, "location", FreeformProjectType.NS_GENERAL); // NOI18N
assert locEl != null;
- String loc = Util.findText(locEl);
+ String loc = XMLUtil.findText(locEl);
assert loc != null;
String locationResolved = eval.evaluate(loc);
if (locationResolved == null) {
@@ -154,40 +153,40 @@
}
public String getType() {
- Element typeEl = Util.findElement(export, "type", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element typeEl = XMLUtil.findElement(export, "type", FreeformProjectType.NS_GENERAL); // NOI18N
assert typeEl != null;
- String type = Util.findText(typeEl);
+ String type = XMLUtil.findText(typeEl);
assert type != null;
return type;
}
public String getTargetName() {
- Element targetEl = Util.findElement(export, "build-target", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element targetEl = XMLUtil.findElement(export, "build-target", FreeformProjectType.NS_GENERAL); // NOI18N
assert targetEl != null;
- String target = Util.findText(targetEl);
+ String target = XMLUtil.findText(targetEl);
assert target != null;
return target;
}
public String getCleanTargetName() {
- Element targetEl = Util.findElement(export, "clean-target", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element targetEl = XMLUtil.findElement(export, "clean-target", FreeformProjectType.NS_GENERAL); // NOI18N
if (targetEl != null) {
- String target = Util.findText(targetEl);
+ String target = XMLUtil.findText(targetEl);
assert target != null;
return target;
} else {
// Guess based on configured target for 'clean' command, if any.
String target = null;
Element genldata = project.getPrimaryConfigurationData();
- Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
if (actionsEl != null) {
- for (Element actionEl : Util.findSubElements(actionsEl)) {
+ for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
if (actionEl.getAttribute("name").equals("clean")) { // NOI18N
- for (Element actionTargetEl : Util.findSubElements(actionEl)) {
+ for (Element actionTargetEl : XMLUtil.findSubElements(actionEl)) {
if (!actionTargetEl.getLocalName().equals("target")) { // NOI18N
continue;
}
- String possibleTarget = Util.findText(actionTargetEl);
+ String possibleTarget = XMLUtil.findText(actionTargetEl);
assert possibleTarget != null;
if (target == null) {
// OK, probably use it (unless there is another target for this command).
@@ -213,9 +212,9 @@
public File getScriptLocation() {
String loc = null;
- Element scriptEl = Util.findElement(export, "script", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element scriptEl = XMLUtil.findElement(export, "script", FreeformProjectType.NS_GENERAL); // NOI18N
if (scriptEl != null) {
- String script = Util.findText(scriptEl);
+ String script = XMLUtil.findText(scriptEl);
assert script != null;
loc = project.evaluator().evaluate(script);
}
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformEvaluator.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformEvaluator.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformEvaluator.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformEvaluator.java
@@ -52,7 +52,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.project.support.ant.AntProjectEvent;
import org.netbeans.spi.project.support.ant.AntProjectListener;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
@@ -60,6 +59,7 @@
import org.netbeans.spi.project.support.ant.PropertyUtils;
import org.openide.ErrorManager;
import org.openide.util.Parameters;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -105,18 +105,18 @@
PropertyProvider preprovider = project.helper().getStockPropertyPreprovider();
List defs = new ArrayList();
Element genldata = project.getPrimaryConfigurationData();
- Element properties = Util.findElement(genldata, "properties", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element properties = XMLUtil.findElement(genldata, "properties", FreeformProjectType.NS_GENERAL); // NOI18N
if (properties != null) {
- for (Element e : Util.findSubElements(properties)) {
+ for (Element e : XMLUtil.findSubElements(properties)) {
if (e.getLocalName().equals("property")) { // NOI18N
- String val = Util.findText(e);
+ String val = XMLUtil.findText(e);
if (val == null) {
val = "";
}
defs.add(PropertyUtils.fixedPropertyProvider(Collections.singletonMap(e.getAttribute("name"), val))); // NOI18N
} else {
assert e.getLocalName().equals("property-file") : e;
- String fname = Util.findText(e);
+ String fname = XMLUtil.findText(e);
if (fname.contains("${")) { // NOI18N
// Tricky (#48230): need to listen to changes in the location of the file as well as its contents.
PropertyEvaluator intermediate = PropertyUtils.sequentialPropertyEvaluator(preprovider, defs.toArray(new PropertyProvider[defs.size()]));
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformFileEncodingQueryImpl.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformFileEncodingQueryImpl.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformFileEncodingQueryImpl.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformFileEncodingQueryImpl.java
@@ -60,6 +60,7 @@
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.openide.util.Exceptions;
import org.openide.util.Mutex;
+import org.openide.xml.XMLUtil;
/**
* Implementation of FileEncodingQuery for Freeform project, its instance can be
@@ -114,23 +115,23 @@
private void computeEncodingsCache() {
Map cache = new HashMap(3);
Element data = Util.getPrimaryConfigurationData(helper);
- Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
+ Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
if (foldersEl != null) {
- for (Element sourceFolderEl : Util.findSubElements(foldersEl)) {
+ for (Element sourceFolderEl : XMLUtil.findSubElements(foldersEl)) {
if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
continue;
}
FileObject srcRoot = null;
- Element locationEl = Util.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
+ Element locationEl = XMLUtil.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
if (locationEl != null) {
- String location = evaluator.evaluate(Util.findText(locationEl));
+ String location = evaluator.evaluate(XMLUtil.findText(locationEl));
if (location != null) {
srcRoot = helper.resolveFileObject(location);
}
}
- Element encodingEl = Util.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
+ Element encodingEl = XMLUtil.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
if (encodingEl != null && srcRoot != null) {
- String encoding = evaluator.evaluate(Util.findText(encodingEl));
+ String encoding = evaluator.evaluate(XMLUtil.findText(encodingEl));
Charset charset = null;
if (encoding != null) {
try {
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProject.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProject.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProject.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProject.java
@@ -46,7 +46,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
-import javax.swing.ImageIcon;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectInformation;
import org.netbeans.api.project.ProjectManager;
@@ -66,6 +65,7 @@
import org.openide.util.Lookup;
import org.openide.util.Mutex;
import org.openide.util.lookup.Lookups;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -196,12 +196,12 @@
return ProjectManager.mutex().readAccess(new Mutex.Action() {
public String run() {
Element genldata = getPrimaryConfigurationData();
- Element nameEl = Util.findElement(genldata, "name", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element nameEl = XMLUtil.findElement(genldata, "name", FreeformProjectType.NS_GENERAL); // NOI18N
if (nameEl == null) {
// Corrupt. Cf. #48267 (cause unknown).
return "???"; // NOI18N
}
- return Util.findText(nameEl);
+ return XMLUtil.findText(nameEl);
}
});
}
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectGenerator.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectGenerator.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectGenerator.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectGenerator.java
@@ -63,6 +63,7 @@
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileUtil;
import org.openide.util.NbBundle;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -196,47 +197,47 @@
//assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
List list = new ArrayList();
Element genldata = Util.getPrimaryConfigurationData(helper);
- Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
if (actionsEl == null) {
return list;
}
- for (Element actionEl : Util.findSubElements(actionsEl)) {
+ for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
TargetMapping tm = new TargetMapping();
tm.name = actionEl.getAttribute("name"); // NOI18N
List targetNames = new ArrayList();
EditableProperties props = new EditableProperties(false);
- for (Element subEl : Util.findSubElements(actionEl)) {
+ for (Element subEl : XMLUtil.findSubElements(actionEl)) {
if (subEl.getLocalName().equals("target")) { // NOI18N
- targetNames.add(Util.findText(subEl));
+ targetNames.add(XMLUtil.findText(subEl));
continue;
}
if (subEl.getLocalName().equals("script")) { // NOI18N
- tm.script = Util.findText(subEl);
+ tm.script = XMLUtil.findText(subEl);
continue;
}
if (subEl.getLocalName().equals("context")) { // NOI18N
TargetMapping.Context ctx = new TargetMapping.Context();
- for (Element contextSubEl : Util.findSubElements(subEl)) {
+ for (Element contextSubEl : XMLUtil.findSubElements(subEl)) {
if (contextSubEl.getLocalName().equals("property")) { // NOI18N
- ctx.property = Util.findText(contextSubEl);
+ ctx.property = XMLUtil.findText(contextSubEl);
continue;
}
if (contextSubEl.getLocalName().equals("format")) { // NOI18N
- ctx.format = Util.findText(contextSubEl);
+ ctx.format = XMLUtil.findText(contextSubEl);
continue;
}
if (contextSubEl.getLocalName().equals("folder")) { // NOI18N
- ctx.folder = Util.findText(contextSubEl);
+ ctx.folder = XMLUtil.findText(contextSubEl);
continue;
}
if (contextSubEl.getLocalName().equals("pattern")) { // NOI18N
- ctx.pattern = Util.findText(contextSubEl);
+ ctx.pattern = XMLUtil.findText(contextSubEl);
continue;
}
if (contextSubEl.getLocalName().equals("arity")) { // NOI18N
- Element sepFilesEl = Util.findElement(contextSubEl, "separated-files", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element sepFilesEl = XMLUtil.findElement(contextSubEl, "separated-files", FreeformProjectType.NS_GENERAL); // NOI18N
if (sepFilesEl != null) {
- ctx.separator = Util.findText(sepFilesEl);
+ ctx.separator = XMLUtil.findText(sepFilesEl);
}
continue;
}
@@ -259,7 +260,7 @@
private static void readProperty(Element propertyElement, EditableProperties props) {
String key = propertyElement.getAttribute("name"); // NOI18N
- String value = Util.findText(propertyElement);
+ String value = XMLUtil.findText(propertyElement);
props.setProperty(key, value);
}
@@ -273,7 +274,7 @@
//assert ProjectManager.mutex().isWriteAccess();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element actions = Util.findElement(data, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element actions = XMLUtil.findElement(data, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
if (actions != null) {
data.removeChild(actions);
}
@@ -331,7 +332,7 @@
}
actions.appendChild(action);
}
- Util.appendChildElement(data, actions, rootElementsOrder);
+ XMLUtil.appendChildElement(data, actions, rootElementsOrder);
Util.putPrimaryConfigurationData(helper, data);
}
@@ -357,17 +358,17 @@
//assert ProjectManager.mutex().isWriteAccess();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element viewEl = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element viewEl = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
if (viewEl == null) {
viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
- Util.appendChildElement(data, viewEl, rootElementsOrder);
+ XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
}
- Element contextMenuEl = Util.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
if (contextMenuEl == null) {
contextMenuEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "context-menu"); // NOI18N
- Util.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
+ XMLUtil.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
}
- for (Element ideActionEl : Util.findSubElements(contextMenuEl)) {
+ for (Element ideActionEl : XMLUtil.findSubElements(contextMenuEl)) {
if (!ideActionEl.getLocalName().equals("ide-action")) { // NOI18N
continue;
}
@@ -380,7 +381,7 @@
}
Element ideAction = doc.createElementNS(FreeformProjectType.NS_GENERAL, "ide-action"); //NOI18N
ideAction.setAttribute("name", tm.name); // NOI18N
- Util.appendChildElement(contextMenuEl, ideAction, contextMenuElementsOrder);
+ XMLUtil.appendChildElement(contextMenuEl, ideAction, contextMenuElementsOrder);
}
Util.putPrimaryConfigurationData(helper, data);
}
@@ -394,32 +395,32 @@
//assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
List list = new ArrayList();
Element genldata = Util.getPrimaryConfigurationData(helper);
- Element viewEl = Util.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element viewEl = XMLUtil.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
if (viewEl == null) {
return list;
}
- Element contextMenuEl = Util.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
if (contextMenuEl == null) {
return list;
}
- for (Element actionEl : Util.findSubElements(contextMenuEl)) {
+ for (Element actionEl : XMLUtil.findSubElements(contextMenuEl)) {
if (!actionEl.getLocalName().equals("action")) { // NOI18N
continue;
}
CustomTarget ct = new CustomTarget();
List targetNames = new ArrayList();
EditableProperties props = new EditableProperties(false);
- for (Element subEl : Util.findSubElements(actionEl)) {
+ for (Element subEl : XMLUtil.findSubElements(actionEl)) {
if (subEl.getLocalName().equals("target")) { // NOI18N
- targetNames.add(Util.findText(subEl));
+ targetNames.add(XMLUtil.findText(subEl));
continue;
}
if (subEl.getLocalName().equals("script")) { // NOI18N
- ct.script = Util.findText(subEl);
+ ct.script = XMLUtil.findText(subEl);
continue;
}
if (subEl.getLocalName().equals("label")) { // NOI18N
- ct.label = Util.findText(subEl);
+ ct.label = XMLUtil.findText(subEl);
continue;
}
if (subEl.getLocalName().equals("property")) { // NOI18N
@@ -448,17 +449,17 @@
//assert ProjectManager.mutex().isWriteAccess();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element viewEl = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element viewEl = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
if (viewEl == null) {
viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
- Util.appendChildElement(data, viewEl, rootElementsOrder);
+ XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
}
- Element contextMenuEl = Util.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
if (contextMenuEl == null) {
contextMenuEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "context-menu"); // NOI18N
- Util.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
+ XMLUtil.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
}
- for (Element actionEl : Util.findSubElements(contextMenuEl)) {
+ for (Element actionEl : XMLUtil.findSubElements(contextMenuEl)) {
if (!actionEl.getLocalName().equals("action")) { // NOI18N
continue;
}
@@ -484,7 +485,7 @@
if (ct.properties != null) {
writeProperties(ct.properties, doc, action);
}
- Util.appendChildElement(contextMenuEl, action, contextMenuElementsOrder);
+ XMLUtil.appendChildElement(contextMenuEl, action, contextMenuElementsOrder);
}
Util.putPrimaryConfigurationData(helper, data);
}
@@ -523,21 +524,21 @@
private static void putBuildXMLSourceFile(AntProjectHelper helper, String antPath) {
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element viewEl = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element viewEl = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
if (viewEl == null) {
viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
- Util.appendChildElement(data, viewEl, rootElementsOrder);
+ XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
}
- Element itemsEl = Util.findElement(viewEl, "items", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element itemsEl = XMLUtil.findElement(viewEl, "items", FreeformProjectType.NS_GENERAL); // NOI18N
if (itemsEl == null) {
itemsEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "items"); // NOI18N
- Util.appendChildElement(viewEl, itemsEl, viewElementsOrder);
+ XMLUtil.appendChildElement(viewEl, itemsEl, viewElementsOrder);
}
Element fileEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "source-file"); // NOI18N
Element el = doc.createElementNS(FreeformProjectType.NS_GENERAL, "location"); // NOI18N
el.appendChild(doc.createTextNode(antPath)); // NOI18N
fileEl.appendChild(el);
- Util.appendChildElement(itemsEl, fileEl, viewItemElementsOrder);
+ XMLUtil.appendChildElement(itemsEl, fileEl, viewItemElementsOrder);
Util.putPrimaryConfigurationData(helper, data);
}
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectOperations.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectOperations.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectOperations.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectOperations.java
@@ -45,18 +45,15 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.netbeans.api.project.Project;
-import org.netbeans.api.project.ProjectManager;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.project.CopyOperationImplementation;
import org.netbeans.spi.project.DeleteOperationImplementation;
import org.netbeans.spi.project.MoveOperationImplementation;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
-import org.openide.ErrorManager;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -90,8 +87,8 @@
public List getDataFiles() {
Element genldata = project.getPrimaryConfigurationData();
- Element foldersEl = Util.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N
- List folders = foldersEl != null ? Util.findSubElements(foldersEl) : Collections.emptyList();
+ Element foldersEl = XMLUtil.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N
+ List folders = foldersEl != null ? XMLUtil.findSubElements(foldersEl) : Collections.emptyList();
List result = new ArrayList();
for (Element el : folders) {
@@ -106,14 +103,14 @@
}
private void addFile(Element folder, List result) {
- Element location = Util.findElement(folder, "location", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element location = XMLUtil.findElement(folder, "location", FreeformProjectType.NS_GENERAL); // NOI18N
if (location == null) {
return ;
}
PropertyEvaluator evaluator = project.evaluator();
- String val = evaluator.evaluate(Util.findText(location));
+ String val = evaluator.evaluate(XMLUtil.findText(location));
if (val == null) {
return ;
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSharabilityQuery.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSharabilityQuery.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSharabilityQuery.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSharabilityQuery.java
@@ -54,9 +54,7 @@
import org.openide.filesystems.FileUtil;
import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
*
@@ -117,9 +115,9 @@
final NodeList exports = root.getElementsByTagNameNS(FreeformProjectType.NS_GENERAL, "export"); //NOI18N
for (int i=0; i< exports.getLength(); i++) {
final Element export = (Element) exports.item(i);
- final Element location = Util.findElement(export, "location", FreeformProjectType.NS_GENERAL); //NOI18N
+ final Element location = XMLUtil.findElement(export, "location", FreeformProjectType.NS_GENERAL); //NOI18N
if (location != null) {
- final String path = Util.findText(location);
+ final String path = XMLUtil.findText(location);
if (path != null) {
final File exportedFile = Util.resolveFile(project.evaluator(), FileUtil.toFile(project.getProjectDirectory()), path);
if (exportedFile != null) {
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSources.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSources.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSources.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSources.java
@@ -46,12 +46,12 @@
import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.project.support.ant.AntProjectEvent;
import org.netbeans.spi.project.support.ant.AntProjectListener;
import org.netbeans.spi.project.support.ant.SourcesHelper;
import org.openide.util.ChangeSupport;
import org.openide.util.Mutex;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -86,32 +86,32 @@
private Sources initSources() {
SourcesHelper h = new SourcesHelper(project, project.helper(), project.evaluator());
Element genldata = project.getPrimaryConfigurationData();
- Element foldersE = Util.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element foldersE = XMLUtil.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N
if (foldersE != null) {
- for (Element folderE : Util.findSubElements(foldersE)) {
- Element locationE = Util.findElement(folderE, "location", FreeformProjectType.NS_GENERAL); // NOI18N
- String location = Util.findText(locationE);
+ for (Element folderE : XMLUtil.findSubElements(foldersE)) {
+ Element locationE = XMLUtil.findElement(folderE, "location", FreeformProjectType.NS_GENERAL); // NOI18N
+ String location = XMLUtil.findText(locationE);
if (folderE.getLocalName().equals("build-folder")) { // NOI18N
h.addNonSourceRoot(location);
} else if (folderE.getLocalName().equals("build-file")) { // NOI18N
h.addOwnedFile(location);
} else {
assert folderE.getLocalName().equals("source-folder") : folderE;
- Element nameE = Util.findElement(folderE, "label", FreeformProjectType.NS_GENERAL); // NOI18N
- String name = Util.findText(nameE);
- Element typeE = Util.findElement(folderE, "type", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element nameE = XMLUtil.findElement(folderE, "label", FreeformProjectType.NS_GENERAL); // NOI18N
+ String name = XMLUtil.findText(nameE);
+ Element typeE = XMLUtil.findElement(folderE, "type", FreeformProjectType.NS_GENERAL); // NOI18N
String includes = null;
- Element includesE = Util.findElement(folderE, "includes", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element includesE = XMLUtil.findElement(folderE, "includes", FreeformProjectType.NS_GENERAL); // NOI18N
if (includesE != null) {
- includes = Util.findText(includesE);
+ includes = XMLUtil.findText(includesE);
}
String excludes = null;
- Element excludesE = Util.findElement(folderE, "excludes", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element excludesE = XMLUtil.findElement(folderE, "excludes", FreeformProjectType.NS_GENERAL); // NOI18N
if (excludesE != null) {
- excludes = Util.findText(excludesE);
+ excludes = XMLUtil.findText(excludesE);
}
if (typeE != null) {
- String type = Util.findText(typeE);
+ String type = XMLUtil.findText(typeE);
h.addTypedSourceRoot(location, includes, excludes, type, name, null, null);
} else {
h.addPrincipalSourceRoot(location, includes, excludes, name, null, null);
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformTemplateAttributesProvider.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformTemplateAttributesProvider.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformTemplateAttributesProvider.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformTemplateAttributesProvider.java
@@ -51,6 +51,7 @@
import org.openide.loaders.CreateFromTemplateAttributesProvider;
import org.openide.loaders.DataFolder;
import org.openide.loaders.DataObject;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -77,14 +78,14 @@
public Map attributesFor(DataObject template, DataFolder target, String name) {
Element primData = Util.getPrimaryConfigurationData(helper);
- Element licenseEl = Util.findElement(primData, "project-license", Util.NAMESPACE); // NOI18N
+ Element licenseEl = XMLUtil.findElement(primData, "project-license", Util.NAMESPACE); // NOI18N
Charset charset = encodingQuery.getEncoding(target.getPrimaryFile());
if (licenseEl == null && charset == null) {
return null;
} else {
Map values = new HashMap();
if (licenseEl != null) {
- values.put("license", evaluator.evaluate(Util.findText(licenseEl))); // NOI18N
+ values.put("license", evaluator.evaluate(XMLUtil.findText(licenseEl))); // NOI18N
}
if (charset != null) {
values.put("encoding", charset.name()); // NOI18N
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/Subprojects.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/Subprojects.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/Subprojects.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/Subprojects.java
@@ -46,15 +46,14 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
import javax.swing.event.ChangeListener;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.project.SubprojectProvider;
import org.openide.ErrorManager;
import org.openide.filesystems.FileObject;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -88,11 +87,11 @@
*/
private Set createSubprojects(Set subprojects) {
Element config = project.getPrimaryConfigurationData();
- Element subprjsEl = Util.findElement(config, "subprojects", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element subprjsEl = XMLUtil.findElement(config, "subprojects", FreeformProjectType.NS_GENERAL); // NOI18N
if (subprjsEl != null) {
- for (Element prjEl : Util.findSubElements(subprjsEl)) {
+ for (Element prjEl : XMLUtil.findSubElements(subprjsEl)) {
assert prjEl.getLocalName().equals("project") : "Bad element " + prjEl + " in for " + project;
- String rawtext = Util.findText(prjEl);
+ String rawtext = XMLUtil.findText(prjEl);
assert rawtext != null : "Need text content for in " + project;
String evaltext = project.evaluator().evaluate(rawtext);
if (evaltext == null) {
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/spi/support/Util.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/spi/support/Util.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/spi/support/Util.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/spi/support/Util.java
@@ -43,10 +43,6 @@
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
import javax.xml.XMLConstants;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
@@ -71,10 +67,6 @@
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializer;
import org.xml.sax.SAXException;
@@ -87,84 +79,6 @@
private Util() {}
- // XXX XML methods copied from ant/project... make a general API of these instead?
-
- /**
- * Search for an XML element in the direct children of a parent.
- * DOM provides a similar method but it does a recursive search
- * which we do not want. It also gives a node list and we want
- * only one result.
- * @param parent a parent element
- * @param name the intended local name
- * @param namespace the intended namespace
- * @return the one child element with that name, or null if none or more than one
- */
- public static Element findElement(Element parent, String name, String namespace) {
- Element result = null;
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element)l.item(i);
- if (name.equals(el.getLocalName()) && namespace.equals(el.getNamespaceURI())) {
- if (result == null) {
- result = el;
- } else {
- return null;
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Extract nested text from an element.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent element
- * @return the nested text, or null if none was found
- */
- public static String findText(Element parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- /**
- * Find all direct child elements of an element.
- * More useful than {@link Element#getElementsByTagNameNS} because it does
- * not recurse into recursive child elements.
- * Children which are all-whitespace text nodes are ignored; others cause
- * an exception to be thrown.
- * @param parent a parent element in a DOM tree
- * @return a list of direct child elements (may be empty)
- * @throws IllegalArgumentException if there are non-element children besides whitespace
- */
- public static List findSubElements(Element parent) throws IllegalArgumentException {
- NodeList l = parent.getChildNodes();
- List elements = new ArrayList(l.getLength());
- for (int i = 0; i < l.getLength(); i++) {
- Node n = l.item(i);
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- elements.add((Element)n);
- } else if (n.getNodeType() == Node.TEXT_NODE) {
- String text = ((Text)n).getNodeValue();
- if (text.trim().length() > 0) {
- throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
- }
- } else if (n.getNodeType() == Node.COMMENT_NODE) {
- // skip
- } else {
- throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
- }
- }
- return elements;
- }
-
/**
* Finds AuxiliaryConfiguration for the given project helper. The method
* finds project associated with the helper and searches
@@ -241,31 +155,6 @@
}
}
- /**
- * Append child element to the correct position according to given
- * order.
- * @param parent parent to which the child will be added
- * @param el element to be added
- * @param order order of the elements which must be followed
- */
- public static void appendChildElement(Element parent, Element el, String[] order) {
- Element insertBefore = null;
- List l = Arrays.asList(order);
- int index = l.indexOf(el.getLocalName());
- assert index != -1 : el.getLocalName()+" was not found in "+l; // NOI18N
- Iterator it = Util.findSubElements(parent).iterator();
- while (it.hasNext()) {
- Element e = (Element)it.next();
- int index2 = l.indexOf(e.getLocalName());
- assert index2 != -1 : e.getLocalName()+" was not found in "+l; // NOI18N
- if (index2 > index) {
- insertBefore = e;
- break;
- }
- }
- parent.insertBefore(el, insertBefore);
- }
-
/**Get the "default" (user-specified) ant script for the given freeform project.
* Please note that this method may return null
if there is no such script.
*
@@ -287,31 +176,6 @@
}
/**
- * Convert an XML fragment from one namespace to another.
- */
- private static Element translateXML(Element from, String namespace) {
- Element to = from.getOwnerDocument().createElementNS(namespace, from.getLocalName());
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i = 0; i < length; i++) {
- Node node = nl.item(i);
- Node newNode;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- newNode = translateXML((Element) node, namespace);
- } else {
- newNode = node.cloneNode(true);
- }
- to.appendChild(newNode);
- }
- NamedNodeMap m = from.getAttributes();
- for (int i = 0; i < m.getLength(); i++) {
- Node attr = m.item(i);
- to.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- return to;
- }
-
- /**
* Namespace of data used in {@link #getPrimaryConfigurationData} and {@link #putPrimaryConfigurationData}.
* @since org.netbeans.modules.ant.freeform/1 1.15
*/
@@ -332,7 +196,7 @@
if (data != null) {
return data;
} else {
- return translateXML(helper.getPrimaryConfigurationData(true), NAMESPACE);
+ return XMLUtil.translateXML(helper.getPrimaryConfigurationData(true), NAMESPACE);
}
}
});
@@ -353,7 +217,7 @@
}
ProjectManager.mutex().writeAccess(new Mutex.Action() {
public Void run() {
- Element dataAs1 = translateXML(data, FreeformProjectType.NS_GENERAL_1);
+ Element dataAs1 = XMLUtil.translateXML(data, FreeformProjectType.NS_GENERAL_1);
if (SCHEMA_1 == null) {
try {
SchemaFactory f = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
@@ -390,7 +254,7 @@
Element dummy1 = doc.createElementNS(FreeformProjectType.NS_GENERAL_1, FreeformProjectType.NAME_SHARED);
// Make sure it is not invalid.
dummy1.appendChild(doc.createElementNS(FreeformProjectType.NS_GENERAL_1, "name")). // NOI18N
- appendChild(doc.createTextNode(findText(findElement(data, "name", NAMESPACE)))); // NOI18N
+ appendChild(doc.createTextNode(XMLUtil.findText(XMLUtil.findElement(data, "name", NAMESPACE)))); // NOI18N
helper.putPrimaryConfigurationData(dummy1, true);
helper.createAuxiliaryConfiguration().putConfigurationFragment(data, true);
}
diff --git a/ant.freeform/src/org/netbeans/modules/ant/freeform/ui/FolderNodeFactory.java b/ant.freeform/src/org/netbeans/modules/ant/freeform/ui/FolderNodeFactory.java
--- a/ant.freeform/src/org/netbeans/modules/ant/freeform/ui/FolderNodeFactory.java
+++ b/ant.freeform/src/org/netbeans/modules/ant/freeform/ui/FolderNodeFactory.java
@@ -64,7 +64,6 @@
import org.netbeans.api.queries.VisibilityQuery;
import org.netbeans.modules.ant.freeform.FreeformProject;
import org.netbeans.modules.ant.freeform.FreeformProjectType;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.modules.ant.freeform.spi.ProjectNature;
import org.netbeans.spi.project.support.ant.AntProjectEvent;
import org.netbeans.spi.project.support.ant.AntProjectListener;
@@ -91,6 +90,7 @@
import org.openide.util.RequestProcessor;
import org.openide.util.actions.SystemAction;
import org.openide.util.lookup.Lookups;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -136,10 +136,10 @@
private void updateKeys(boolean fromListener) {
Element genldata = p.getPrimaryConfigurationData();
- Element viewEl = Util.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element viewEl = XMLUtil.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
if (viewEl != null) {
- Element itemsEl = Util.findElement(viewEl, "items", FreeformProjectType.NS_GENERAL); // NOI18N
- keys = Util.findSubElements(itemsEl);
+ Element itemsEl = XMLUtil.findElement(viewEl, "items", FreeformProjectType.NS_GENERAL); // NOI18N
+ keys = XMLUtil.findSubElements(itemsEl);
} else {
keys = Collections.emptyList();
}
@@ -182,8 +182,8 @@
public Node node(Element itemEl) {
- Element locationEl = Util.findElement(itemEl, "location", FreeformProjectType.NS_GENERAL); // NOI18N
- String location = Util.findText(locationEl);
+ Element locationEl = XMLUtil.findElement(itemEl, "location", FreeformProjectType.NS_GENERAL); // NOI18N
+ String location = XMLUtil.findText(locationEl);
String locationEval = p.evaluator().evaluate(location);
if (locationEval == null) {
return null;
@@ -194,9 +194,9 @@
return null;
}
String label;
- Element labelEl = Util.findElement(itemEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element labelEl = XMLUtil.findElement(itemEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
if (labelEl != null) {
- label = Util.findText(labelEl);
+ label = XMLUtil.findText(labelEl);
} else {
label = null;
}
@@ -206,18 +206,18 @@
return null;
}
String includes = null;
- Element includesEl = Util.findElement(itemEl, "includes", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element includesEl = XMLUtil.findElement(itemEl, "includes", FreeformProjectType.NS_GENERAL); // NOI18N
if (includesEl != null) {
- includes = p.evaluator().evaluate(Util.findText(includesEl));
+ includes = p.evaluator().evaluate(XMLUtil.findText(includesEl));
if (includes.matches("\\$\\{[^}]+\\}")) { // NOI18N
// Clearly intended to mean "include everything".
includes = null;
}
}
String excludes = null;
- Element excludesEl = Util.findElement(itemEl, "excludes", FreeformProjectType.NS_GENERAL); // NOI18N
+ Element excludesEl = XMLUtil.findElement(itemEl, "excludes", FreeformProjectType.NS_GENERAL); // NOI18N
if (excludesEl != null) {
- excludes = p.evaluator().evaluate(Util.findText(excludesEl));
+ excludes = p.evaluator().evaluate(XMLUtil.findText(excludesEl));
}
String style = itemEl.getAttribute("style"); // NOI18N
for (ProjectNature nature : Lookup.getDefault().lookupAll(ProjectNature.class)) {
diff --git a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ActionsTest.java b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ActionsTest.java
--- a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ActionsTest.java
+++ b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ActionsTest.java
@@ -200,6 +200,7 @@
}
public void testLogicalViewActions() throws Exception {
+ System.out.println("Starting failing test");
Action[] actions = lvp.createLogicalView().getActions(false);
assertNotNull("have some context actions", actions);
ResourceBundle bundle = NbBundle.getBundle(Actions.class);
diff --git a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ArtifactProviderTest.java b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ArtifactProviderTest.java
--- a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ArtifactProviderTest.java
+++ b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ArtifactProviderTest.java
@@ -49,6 +49,7 @@
import org.netbeans.api.project.ant.AntArtifactQuery;
import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -137,7 +138,7 @@
//assert ProjectManager.mutex().isWriteAccess();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- for (Element exportEl : Util.findSubElements(data)) {
+ for (Element exportEl : XMLUtil.findSubElements(data)) {
if (!exportEl.getLocalName().equals("export")) { // NOI18N
continue;
}
@@ -165,9 +166,9 @@
el.appendChild(doc.createTextNode(export.cleanTarget)); // NOI18N
exportEl.appendChild(el);
}
- Element later = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL);
+ Element later = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL);
if (later == null) {
- later = Util.findElement(data, "subprojects", FreeformProjectType.NS_GENERAL);
+ later = XMLUtil.findElement(data, "subprojects", FreeformProjectType.NS_GENERAL);
}
data.insertBefore(exportEl, later);
}
diff --git a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformProjectGeneratorTest.java b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformProjectGeneratorTest.java
--- a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformProjectGeneratorTest.java
+++ b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformProjectGeneratorTest.java
@@ -62,6 +62,7 @@
import org.openide.filesystems.FileObject;
import org.openide.modules.ModuleInfo;
import org.openide.util.Lookup;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -227,14 +228,14 @@
FreeformProjectGenerator.putTargetMappings(helper, mappings);
// ProjectManager.getDefault().saveAllProjects();
Element el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
assertEquals(2, subElements.size());
// compare first target mapping
Element el2 = subElements.get(0);
assertElement(el2, "action", null, "name", "first-targetName");
- List l1 = Util.findSubElements(el2);
+ List l1 = XMLUtil.findSubElements(el2);
assertEquals(7, l1.size());
assertElementArray(l1,
new String[]{"script", "target", "target", "target", "property", "property", "context"},
@@ -244,16 +245,16 @@
el2 = l1.get(5);
assertElement(el2, "property", "v2", "name", "k2");
el2 = l1.get(6);
- List l2 = Util.findSubElements(el2);
+ List l2 = XMLUtil.findSubElements(el2);
assertEquals(5, l2.size());
assertElementArray(l2,
new String[]{"property", "folder", "pattern", "format", "arity"},
new String[]{"someProperty1", "someFolder1", "somePattern1", "relative-path", null});
- assertNotNull("have ", Util.findElement(l2.get(4), "one-file-only", FreeformProjectType.NS_GENERAL));
+ assertNotNull("have ", XMLUtil.findElement(l2.get(4), "one-file-only", FreeformProjectType.NS_GENERAL));
// compare second target mapping
el2 = subElements.get(1);
assertElement(el2, "action", null, "name", "second-targetName");
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(7, l1.size());
assertElementArray(l1,
new String[]{"script", "target", "target", "target", "property", "property", "context"},
@@ -263,14 +264,14 @@
el2 = l1.get(5);
assertElement(el2, "property", "second-v2", "name", "second-k2");
el2 = l1.get(6);
- l2 = Util.findSubElements(el2);
+ l2 = XMLUtil.findSubElements(el2);
assertEquals(4, l2.size());
assertElementArray(l2,
new String[]{"property", "folder", "format", "arity"},
new String[]{"second-someProperty1", "second-someFolder1", "java-name", null});
- Element sepFilesEl = Util.findElement(l2.get(3), "separated-files", FreeformProjectType.NS_GENERAL);
+ Element sepFilesEl = XMLUtil.findElement(l2.get(3), "separated-files", FreeformProjectType.NS_GENERAL);
assertNotNull("have ", sepFilesEl);
- assertEquals("right separator", "someSeparator1", Util.findText(sepFilesEl));
+ assertEquals("right separator", "someSeparator1", XMLUtil.findText(sepFilesEl));
ProjectManager.getDefault().saveAllProjects();
// test updating
@@ -289,14 +290,14 @@
FreeformProjectGenerator.putTargetMappings(helper, mappings);
// ProjectManager.getDefault().saveAllProjects();
el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(1, subElements.size());
// compare first target mapping
el2 = subElements.get(0);
assertElement(el2, "action", null, "name", "foo");
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(5, l1.size());
assertElementArray(l1,
new String[]{"script", "target", "target", "property", "property"},
@@ -319,14 +320,14 @@
FreeformProjectGenerator.putTargetMappings(helper, mappings);
// ProjectManager.getDefault().saveAllProjects();
el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(1, subElements.size());
// compare first target mapping
el2 = subElements.get(0);
assertElement(el2, "action", null, "name", "foo");
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(5, l1.size());
assertElementArray(l1,
new String[]{"script", "target", "target", "property", "property"},
@@ -361,11 +362,11 @@
FreeformProjectGenerator.putContextMenuAction(helper, mappings);
// ProjectManager.getDefault().saveAllProjects();
Element el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "view", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "view", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- el = Util.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
assertEquals(2, subElements.size());
assertElementArray(subElements,
new String[]{"ide-action", "ide-action"},
@@ -386,11 +387,11 @@
FreeformProjectGenerator.putContextMenuAction(helper, mappings);
// ProjectManager.getDefault().saveAllProjects();
el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "view", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "view", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- el = Util.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(4, subElements.size());
assertElementArray(subElements,
new String[]{"ide-action", "ide-action", "ide-action", "ide-action"},
@@ -437,18 +438,18 @@
FreeformProjectGenerator.putCustomContextMenuActions(helper, customActions);
// ProjectManager.getDefault().saveAllProjects();
Element el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "view", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "view", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- el = Util.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
assertEquals(2, subElements.size());
assertElementArray(subElements,
new String[]{"action", "action"},
new String[]{null, null});
// compare first custom action
Element el2 = subElements.get(0);
- List l1 = Util.findSubElements(el2);
+ List l1 = XMLUtil.findSubElements(el2);
assertEquals(6, l1.size());
assertElementArray(l1,
new String[]{"script", "label", "target", "target", "property", "property"},
@@ -459,7 +460,7 @@
assertElement(el2, "property", "v2", "name", "k2");
// compare second custom action
el2 = subElements.get(1);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(6, l1.size());
assertElementArray(l1,
new String[]{"script", "label", "target", "target", "property", "property"},
@@ -482,25 +483,25 @@
FreeformProjectGenerator.putCustomContextMenuActions(helper, customActions);
// ProjectManager.getDefault().saveAllProjects();
el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "view", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "view", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- el = Util.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
+ el = XMLUtil.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
assertNotNull("Target mapping were not saved correctly", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(2, subElements.size());
assertElementArray(subElements,
new String[]{"action", "action"},
new String[]{null, null});
// compare first custom action
el2 = subElements.get(0);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(1, l1.size());
assertElementArray(l1,
new String[]{"label"},
new String[]{"fooLabel"});
// compare second custom action
el2 = subElements.get(1);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(1, l1.size());
assertElementArray(l1,
new String[]{"label"},
@@ -518,7 +519,7 @@
String message = "Element "+element+" does not match [name="+expectedName+",value="+expectedValue+"]"; // NOI18N
assertEquals(message, expectedName, element.getLocalName());
if (expectedValue != null) {
- assertEquals(message, expectedValue, Util.findText(element));
+ assertEquals(message, expectedValue, XMLUtil.findText(element));
}
}
@@ -546,7 +547,7 @@
expectedValue+", attr="+expectedAttrName+", attrvalue="+expectedAttrValue+"]"; // NOI18N
assertEquals(message, expectedName, element.getLocalName());
if (expectedValue != null) {
- assertEquals(message, expectedValue, Util.findText(element));
+ assertEquals(message, expectedValue, XMLUtil.findText(element));
}
String val = element.getAttribute(expectedAttrName);
assertEquals(expectedAttrValue, val);
diff --git a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformSourcesTest.java b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformSourcesTest.java
--- a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformSourcesTest.java
+++ b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformSourcesTest.java
@@ -58,6 +58,7 @@
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -110,12 +111,12 @@
TestCL l = new TestCL();
s.addChangeListener(l);
Element data = extsrcroot.getPrimaryConfigurationData();
- Element folders = Util.findElement(data, "folders", FreeformProjectType.NS_GENERAL);
+ Element folders = XMLUtil.findElement(data, "folders", FreeformProjectType.NS_GENERAL);
assertNotNull("have ", folders);
- List/**/ sourceFolders = Util.findSubElements(folders);
+ List sourceFolders = XMLUtil.findSubElements(folders);
assertEquals("have 2 s", 2, sourceFolders.size());
Element sourceFolder = (Element) sourceFolders.get(1);
- Element location = Util.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
+ Element location = XMLUtil.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
assertNotNull("have ", location);
NodeList nl = location.getChildNodes();
assertEquals("one child (text)", 1, nl.getLength());
@@ -146,7 +147,7 @@
FileUtil.createData(new File(d, "s/ignored/file"));
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element sf = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), Util.findElement(data, "view", Util.NAMESPACE)).
+ Element sf = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), XMLUtil.findElement(data, "view", Util.NAMESPACE)).
appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources"));
sf.appendChild(doc.createElementNS(Util.NAMESPACE, "type")).appendChild(doc.createTextNode("stuff"));
diff --git a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/UnboundTargetAlertTest.java b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/UnboundTargetAlertTest.java
--- a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/UnboundTargetAlertTest.java
+++ b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/UnboundTargetAlertTest.java
@@ -52,6 +52,7 @@
import org.netbeans.modules.ant.freeform.FreeformProjectType;
import org.netbeans.modules.ant.freeform.TestBase;
import org.netbeans.modules.ant.freeform.spi.support.Util;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -98,12 +99,12 @@
assertEquals(null, lastMapping.context);
// Also check the context menu.
Element data = prj.getPrimaryConfigurationData();
- Element view = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL);
+ Element view = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL);
assertNotNull(view);
- Element contextMenu = Util.findElement(view, "context-menu", FreeformProjectType.NS_GENERAL);
+ Element contextMenu = XMLUtil.findElement(view, "context-menu", FreeformProjectType.NS_GENERAL);
assertNotNull(contextMenu);
Set actionNames = new TreeSet();
- for (Element action : Util.findSubElements(contextMenu)) {
+ for (Element action : XMLUtil.findSubElements(contextMenu)) {
if (action.getLocalName().equals("ide-action")) {
actionNames.add(action.getAttribute("name"));
}
diff --git a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/ViewTest.java b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/ViewTest.java
--- a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/ViewTest.java
+++ b/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/ViewTest.java
@@ -70,6 +70,7 @@
import org.openide.nodes.NodeReorderEvent;
import org.w3c.dom.Document;
import org.openide.util.Lookup;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -120,19 +121,19 @@
TestNL l = new TestNL();
root.addNodeListener(l);
Element data = extsrcroot.getPrimaryConfigurationData();
- Element view = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL);
+ Element view = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL);
assertNotNull("have ", view);
- Element items = Util.findElement(view, "items", FreeformProjectType.NS_GENERAL);
+ Element items = XMLUtil.findElement(view, "items", FreeformProjectType.NS_GENERAL);
assertNotNull("have ", items);
- Element sourceFolder = Util.findElement(items, "source-folder", FreeformProjectType.NS_GENERAL);
+ Element sourceFolder = XMLUtil.findElement(items, "source-folder", FreeformProjectType.NS_GENERAL);
assertNotNull("have ", sourceFolder);
- Element location = Util.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
+ Element location = XMLUtil.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
assertNotNull("have ", location);
NodeList nl = location.getChildNodes();
assertEquals("one child", 1, nl.getLength());
location.removeChild(nl.item(0));
location.appendChild(location.getOwnerDocument().createTextNode("../src2"));
- Element sourceFile = Util.findElement(items, "source-file", FreeformProjectType.NS_GENERAL);
+ Element sourceFile = XMLUtil.findElement(items, "source-file", FreeformProjectType.NS_GENERAL);
assertNotNull("have ", sourceFile);
items.removeChild(sourceFile);
extsrcroot.putPrimaryConfigurationData(data);
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java
@@ -87,6 +87,7 @@
import org.openide.util.RequestProcessor;
import org.openide.util.Utilities;
import org.openide.util.WeakListeners;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -603,18 +604,18 @@
*/
private String computeModuleClasspath(ModuleList ml) {
Element data = project.getPrimaryConfigurationData();
- Element moduleDependencies = Util.findElement(data,
+ Element moduleDependencies = XMLUtil.findElement(data,
"module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
assert moduleDependencies != null : "Malformed metadata in " + project;
StringBuffer cp = new StringBuffer();
- for (Element dep : Util.findSubElements(moduleDependencies)) {
- if (Util.findElement(dep, "compile-dependency", // NOI18N
+ for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
+ if (XMLUtil.findElement(dep, "compile-dependency", // NOI18N
NbModuleProject.NAMESPACE_SHARED) == null) {
continue;
}
- Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
+ Element cnbEl = XMLUtil.findElement(dep, "code-name-base", // NOI18N
NbModuleProject.NAMESPACE_SHARED);
- String cnb = Util.findText(cnbEl);
+ String cnb = XMLUtil.findText(cnbEl);
ModuleEntry module = ml.getEntry(cnb);
if (module == null) {
Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + FileUtil.getFileDisplayName(project.getProjectDirectory()));
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java
@@ -131,6 +131,7 @@
import org.openide.util.Exceptions;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
+import org.openide.xml.XMLUtil;
/**
* A NetBeans module project.
@@ -221,8 +222,8 @@
.displayName(NbBundle.getMessage(NbModuleProject.class, "LBL_javahelp_packages")).add();
}
for (Map.Entry entry : getExtraCompilationUnits().entrySet()) {
- Element pkgrootEl = Util.findElement(entry.getValue(), "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
- String pkgrootS = Util.findText(pkgrootEl);
+ Element pkgrootEl = XMLUtil.findElement(entry.getValue(), "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ String pkgrootS = XMLUtil.findText(pkgrootEl);
sourcesHelper.sourceRoot(pkgrootS).type(JavaProjectConstants.SOURCES_TYPE_JAVA)
.displayName(/* XXX should schema incl. display name? */entry.getKey().getNameExt()).add();
}
@@ -340,7 +341,7 @@
AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
Element data = ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true);
if (data != null) {
- return Util.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
+ return XMLUtil.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
} else {
return helper.getPrimaryConfigurationData(true);
}
@@ -357,7 +358,7 @@
public Void run() {
AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
if (ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true) != null) {
- ac.putConfigurationFragment(Util.translateXML(data, NbModuleProject.NAMESPACE_SHARED_2), true);
+ ac.putConfigurationFragment(XMLUtil.translateXML(data, NbModuleProject.NAMESPACE_SHARED_2), true);
} else {
helper.putPrimaryConfigurationData(data, true);
}
@@ -373,9 +374,9 @@
private NbModuleProvider.NbModuleType getModuleType() {
Element data = getPrimaryConfigurationData();
- if (Util.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
+ if (XMLUtil.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
return NbModuleProvider.SUITE_COMPONENT;
- } else if (Util.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
+ } else if (XMLUtil.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
return NbModuleProvider.STANDALONE;
} else {
return NbModuleProvider.NETBEANS_ORG;
@@ -471,9 +472,9 @@
public String getCodeNameBase() {
Element config = getPrimaryConfigurationData();
- Element cnb = Util.findElement(config, "code-name-base", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element cnb = XMLUtil.findElement(config, "code-name-base", NbModuleProject.NAMESPACE_SHARED); // NOI18N
if (cnb != null) {
- return Util.findText(cnb);
+ return XMLUtil.findText(cnb);
} else {
return null;
}
@@ -623,12 +624,12 @@
return true;
}
Element config = getPrimaryConfigurationData();
- Element pubPkgs = Util.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element pubPkgs = XMLUtil.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
if (pubPkgs == null) {
// Try too.
- pubPkgs = Util.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ pubPkgs = XMLUtil.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
}
- return pubPkgs != null && !Util.findSubElements(pubPkgs).isEmpty();
+ return pubPkgs != null && !XMLUtil.findSubElements(pubPkgs).isEmpty();
}
public List supportedTestTypes() {
@@ -655,10 +656,10 @@
public Map getExtraCompilationUnits() {
if (extraCompilationUnits == null) {
extraCompilationUnits = new HashMap();
- for (Element ecu : Util.findSubElements(getPrimaryConfigurationData())) {
+ for (Element ecu : XMLUtil.findSubElements(getPrimaryConfigurationData())) {
if (ecu.getLocalName().equals("extra-compilation-unit")) { // NOI18N
- Element pkgrootEl = Util.findElement(ecu, "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
- String pkgrootS = Util.findText(pkgrootEl);
+ Element pkgrootEl = XMLUtil.findElement(ecu, "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ String pkgrootS = XMLUtil.findText(pkgrootEl);
String pkgrootEval = evaluator().evaluate(pkgrootS);
FileObject pkgroot = getHelper().resolveFileObject(pkgrootEval);
if (pkgroot == null) {
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/ProjectXMLManager.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/ProjectXMLManager.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ProjectXMLManager.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ProjectXMLManager.java
@@ -218,9 +218,9 @@
} else {
ml = ModuleList.getModuleList(prjDirF);
}
- for (Element depEl : Util.findSubElements(moduleDependencies)) {
+ for (Element depEl : XMLUtil.findSubElements(moduleDependencies)) {
Element cnbEl = findElement(depEl, ProjectXMLManager.CODE_NAME_BASE);
- String _cnb = Util.findText(cnbEl);
+ String _cnb = XMLUtil.findText(cnbEl);
ModuleDependency depToAdd = getModuleDependency(_cnb, ml, depEl);
if (depToAdd == null) {
continue;
@@ -255,13 +255,13 @@
Element relVerEl = findElement(runDepEl, ProjectXMLManager.RELEASE_VERSION);
String relVer = null;
if (relVerEl != null) {
- relVer = Util.findText(relVerEl);
+ relVer = XMLUtil.findText(relVerEl);
}
Element specVerEl = findElement(runDepEl, ProjectXMLManager.SPECIFICATION_VERSION);
String specVer = null;
if (specVerEl != null) {
- specVer = Util.findText(specVerEl);
+ specVer = XMLUtil.findText(specVerEl);
}
Element compDepEl = findElement(depEl, ProjectXMLManager.COMPILE_DEPENDENCY);
@@ -287,9 +287,9 @@
} else {
ml = ModuleList.getModuleList(prjDirF);
}
- for (Element dep : Util.findSubElements(moduleDependencies)) {
+ for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
- String depCnb = Util.findText(cnbEl);
+ String depCnb = XMLUtil.findText(cnbEl);
if (depCnb.equals(cnb)) {
return getModuleDependency(cnb, ml, dep);
}
@@ -301,9 +301,9 @@
public void removeDependency(String cnbToRemove) {
Element _confData = getConfData();
Element moduleDependencies = findModuleDependencies(_confData);
- for (Element dep : Util.findSubElements(moduleDependencies)) {
+ for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
- String _cnb = Util.findText(cnbEl);
+ String _cnb = XMLUtil.findText(cnbEl);
if (cnbToRemove.equals(_cnb)) {
moduleDependencies.removeChild(dep);
}
@@ -330,9 +330,9 @@
public void removeDependenciesByCNB(Collection cnbsToDelete) {
Element _confData = getConfData();
Element moduleDependencies = findModuleDependencies(_confData);
- for (Element dep : Util.findSubElements(moduleDependencies)) {
+ for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
- String _cnb = Util.findText(cnbEl);
+ String _cnb = XMLUtil.findText(cnbEl);
if (cnbsToDelete.remove(_cnb)) {
moduleDependencies.removeChild(dep);
}
@@ -350,11 +350,11 @@
public void editDependency(ModuleDependency origDep, ModuleDependency newDep) {
Element _confData = getConfData();
Element moduleDependencies = findModuleDependencies(_confData);
- List currentDeps = Util.findSubElements(moduleDependencies);
+ List currentDeps = XMLUtil.findSubElements(moduleDependencies);
for (Iterator it = currentDeps.iterator(); it.hasNext();) {
Element dep = it.next();
Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
- String _cnb = Util.findText(cnbEl);
+ String _cnb = XMLUtil.findText(cnbEl);
if (_cnb.equals(origDep.getModuleEntry().getCodeNameBase())) {
moduleDependencies.removeChild(dep);
Element nextDep = it.hasNext() ? it.next() : null;
@@ -474,21 +474,21 @@
Element _confData = getConfData();
Element testModuleDependenciesEl = findTestDependenciesElement(_confData);
Element testTypeRemoveEl = null;
- for (Element type : Util.findSubElements(testModuleDependenciesEl)) {
+ for (Element type : XMLUtil.findSubElements(testModuleDependenciesEl)) {
Element nameEl = findElement(type, TEST_TYPE_NAME);
- String nameOfType = Util.findText(nameEl);
+ String nameOfType = XMLUtil.findText(nameEl);
if (testType.equals(nameOfType)) {
testTypeRemoveEl = type;
}
}
//found such a test type
if (testTypeRemoveEl != null) {
- for (Element el : Util.findSubElements(testTypeRemoveEl)) {
+ for (Element el : XMLUtil.findSubElements(testTypeRemoveEl)) {
Element cnbEl = findElement(el, TEST_DEPENDENCY_CNB);
if (cnbEl == null) {
continue; //name node, continue
}
- String _cnb = Util.findText(cnbEl);
+ String _cnb = XMLUtil.findText(cnbEl);
if (cnbToRemove.equals(_cnb)) {
// found test dependency with desired CNB
testTypeRemoveEl.removeChild(el);
@@ -542,7 +542,7 @@
}
Element testTypeEl = null;
//iterate through test types to determine if testType exist
- for (Element tt : Util.findSubElements(testModuleDependenciesEl)) {
+ for (Element tt : XMLUtil.findSubElements(testModuleDependenciesEl)) {
Node nameNode = findElement(tt, "name"); // NOI18N
assert nameNode != null : "should be some child with name";
//Node nameNode = tt.getFirstChild();
@@ -638,24 +638,24 @@
Map> testDeps = new HashMap>();
if (testDepsEl != null) {
- for (Element typeEl : Util.findSubElements(testDepsEl)) {
+ for (Element typeEl : XMLUtil.findSubElements(testDepsEl)) {
Element testTypeEl = findElement(typeEl, TEST_TYPE_NAME);
String testType = null;
if (testTypeEl != null) {
- testType = Util.findText(testTypeEl);
+ testType = XMLUtil.findText(testTypeEl);
}
if (testType == null) {
testType = TestModuleDependency.UNIT; // default variant
}
Set directTestDeps = new TreeSet();
- for (Element depEl : Util.findSubElements(typeEl)) {
+ for (Element depEl : XMLUtil.findSubElements(typeEl)) {
if (depEl.getTagName().equals(TEST_DEPENDENCY)) {
// parse test dep
Element cnbEl = findElement(depEl, TEST_DEPENDENCY_CNB);
boolean test = findElement(depEl, TEST_DEPENDENCY_TEST) != null;
String _cnb = null;
if (cnbEl != null) {
- _cnb = Util.findText(cnbEl);
+ _cnb = XMLUtil.findText(cnbEl);
}
boolean recursive = findElement(depEl, TEST_DEPENDENCY_RECURSIVE) != null;
boolean compile = findElement(depEl, TEST_DEPENDENCY_COMPILE) != null;
@@ -806,12 +806,12 @@
return Collections.unmodifiableMap(cpExtensions);
}
Map cps = new HashMap();
- for (Element cpExtEl : Util.findSubElements(getConfData())) {
+ for (Element cpExtEl : XMLUtil.findSubElements(getConfData())) {
if (CLASS_PATH_EXTENSION.equals(cpExtEl.getTagName())) {
Element binOrigEl = findElement(cpExtEl, BINARY_ORIGIN);
Element runtimePathEl = findElement(cpExtEl, CLASS_PATH_RUNTIME_PATH);
if (binOrigEl != null && runtimePathEl != null) {
- cps.put(Util.findText(runtimePathEl), Util.findText(binOrigEl));
+ cps.put(XMLUtil.findText(runtimePathEl), XMLUtil.findText(binOrigEl));
}
}
}
@@ -822,7 +822,7 @@
public String getCodeNameBase() {
if (cnb == null) {
Element cnbEl = findElement(getConfData(), ProjectXMLManager.CODE_NAME_BASE);
- cnb = Util.findText(cnbEl);
+ cnb = XMLUtil.findText(cnbEl);
}
return cnb;
}
@@ -875,7 +875,7 @@
}
private static Element findElement(Element parentEl, String elementName) {
- return Util.findElement(parentEl, elementName, NbModuleProject.NAMESPACE_SHARED);
+ return XMLUtil.findElement(parentEl, elementName, NbModuleProject.NAMESPACE_SHARED);
}
/** Package-private for unit tests only. */
@@ -922,11 +922,11 @@
*/
private static Set findAllPackages(Element parent) {
Set packages = new HashSet();
- for (Element pkgEl : Util.findSubElements(parent)) {
+ for (Element pkgEl : XMLUtil.findSubElements(parent)) {
if (PACKAGE.equals(pkgEl.getTagName())) {
- packages.add(new ManifestManager.PackageExport(Util.findText(pkgEl), false));
+ packages.add(new ManifestManager.PackageExport(XMLUtil.findText(pkgEl), false));
} else if (SUBPACKAGES.equals(pkgEl.getTagName())) {
- packages.add(new ManifestManager.PackageExport(Util.findText(pkgEl), true));
+ packages.add(new ManifestManager.PackageExport(XMLUtil.findText(pkgEl), true));
}
}
return packages;
@@ -958,9 +958,9 @@
Element friendsEl = findFriendsElement(confData);
if (friendsEl != null) {
Set friends = new TreeSet();
- for (Element friendEl : Util.findSubElements(friendsEl)) {
+ for (Element friendEl : XMLUtil.findSubElements(friendsEl)) {
if (FRIEND.equals(friendEl.getTagName())) {
- friends.add(Util.findText(friendEl));
+ friends.add(XMLUtil.findText(friendEl));
}
}
return friends.toArray(new String[friends.size()]);
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/Util.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/Util.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/Util.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/Util.java
@@ -125,106 +125,9 @@
private static final String SFS_VALID_PATH_RE = "(\\p{Alnum}|\\/|_)+"; // NOI18N
// COPIED FROM org.netbeans.modules.project.ant:
- // (except for namespace == null support in findElement)
+ // (**EXCEPT** except for namespace == null support in findElement)
// (and support for comments in findSubElements)
- /**
- * Search for an XML element in the direct children of a parent.
- * DOM provides a similar method but it does a recursive search
- * which we do not want. It also gives a node list and we want
- * only one result.
- * @param parent a parent element
- * @param name the intended local name
- * @param namespace the intended namespace (or null)
- * @return the first child element with that name, or null if none
- */
- public static Element findElement(Element parent, String name, String namespace) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element)l.item(i);
- if ((namespace == null && name.equals(el.getTagName())) ||
- (namespace != null && name.equals(el.getLocalName()) &&
- namespace.equals(el.getNamespaceURI()))) {
- return el;
- }
- }
- }
- return null;
- }
-
- /**
- * Extract nested text from an element.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent element
- * @return the nested text, or null if none was found
- */
- public static String findText(Element parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- /**
- * Find all direct child elements of an element.
- * More useful than {@link Element#getElementsByTagNameNS} because it does
- * not recurse into recursive child elements.
- * Children which are all-whitespace text nodes or comments are ignored; others cause
- * an exception to be thrown.
- * @param parent a parent element in a DOM tree
- * @return a list of direct child elements (may be empty)
- * @throws IllegalArgumentException if there are non-element children besides whitespace
- */
- public static List findSubElements(Element parent) throws IllegalArgumentException {
- NodeList l = parent.getChildNodes();
- List elements = new ArrayList(l.getLength());
- for (int i = 0; i < l.getLength(); i++) {
- Node n = l.item(i);
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- elements.add((Element)n);
- } else if (n.getNodeType() == Node.TEXT_NODE) {
- String text = ((Text)n).getNodeValue();
- if (text.trim().length() > 0) {
- throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
- }
- } else if (n.getNodeType() == Node.COMMENT_NODE) {
- // OK, ignore
- } else {
- throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
- }
- }
- return elements;
- }
-
- /**
- * Convert an XML fragment from one namespace to another.
- */
- public static Element translateXML(Element from, String namespace) {
- Element to = from.getOwnerDocument().createElementNS(namespace, from.getLocalName());
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i = 0; i < length; i++) {
- Node node = nl.item(i);
- Node newNode;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- newNode = translateXML((Element) node, namespace);
- } else {
- newNode = node.cloneNode(true);
- }
- to.appendChild(newNode);
- }
- NamedNodeMap m = from.getAttributes();
- for (int i = 0; i < m.getLength(); i++) {
- Node attr = m.item(i);
- to.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- return to;
- }
/**
* Pass to {@link XPath#setNamespaceContext} to bind {@code nbm:} to the /3 namespace.
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/AccessibilityQueryImpl.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/AccessibilityQueryImpl.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/AccessibilityQueryImpl.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/AccessibilityQueryImpl.java
@@ -48,6 +48,7 @@
import org.openide.ErrorManager;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -69,17 +70,17 @@
if (path != null) {
String name = path.replace('/', '.');
Element config = project.getPrimaryConfigurationData();
- Element pubPkgs = Util.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element pubPkgs = XMLUtil.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
if (pubPkgs == null) {
// Try too.
- pubPkgs = Util.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ pubPkgs = XMLUtil.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
}
if (pubPkgs != null) {
- Iterator it = Util.findSubElements(pubPkgs).iterator();
+ Iterator it = XMLUtil.findSubElements(pubPkgs).iterator();
while (it.hasNext()) {
Element pubPkg = (Element) it.next();
boolean sub = "subpackages".equals(pubPkg.getLocalName()); // NOI18N
- String pubPkgS = Util.findText(pubPkg);
+ String pubPkgS = XMLUtil.findText(pubPkg);
if (name.equals(pubPkgS) || (sub && name.startsWith(pubPkgS + '.'))) {
return true;
}
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java
@@ -63,7 +63,6 @@
import org.netbeans.spi.java.classpath.ClassPathProvider;
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
import org.netbeans.modules.apisupport.project.NbModuleProject;
-import org.netbeans.modules.apisupport.project.Util;
import org.netbeans.spi.java.classpath.PathResourceImplementation;
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
import org.netbeans.spi.project.support.ant.AntProjectEvent;
@@ -74,6 +73,7 @@
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileUtil;
import org.openide.util.WeakListeners;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
public final class ClassPathProviderImpl implements ClassPathProvider {
@@ -296,9 +296,9 @@
for (Map.Entry entry : project.getExtraCompilationUnits().entrySet()) {
final FileObject pkgroot = entry.getKey();
Element pkgrootEl = entry.getValue();
- Element classpathEl = Util.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element classpathEl = XMLUtil.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
assert classpathEl != null : "no in " + pkgrootEl;
- final String classpathS = Util.findText(classpathEl);
+ final String classpathS = XMLUtil.findText(classpathEl);
if (classpathS == null) {
extraCompilationUnitsCompile.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
extraCompilationUnitsExecute.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
@@ -333,9 +333,9 @@
}
public void configurationXmlChanged(AntProjectEvent ev) {
Element pkgrootEl = project.getExtraCompilationUnits().get(pkgroot);
- Element classpathEl = Util.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element classpathEl = XMLUtil.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
assert classpathEl != null : "no in " + pkgrootEl;
- cpS = Util.findText(classpathEl);
+ cpS = XMLUtil.findText(classpathEl);
pcs.firePropertyChange(PROP_RESOURCES, null, null);
}
public void propertiesChanged(AntProjectEvent ev) {}
@@ -344,11 +344,11 @@
extraCompilationUnitsCompile.put(pkgroot, ClassPathFactory.createClassPath(ecuCompile));
// Add dirs and JARs for ClassPath.EXECUTE.
List extraEntries = new ArrayList();
- for (Element kid : Util.findSubElements(pkgrootEl)) {
+ for (Element kid : XMLUtil.findSubElements(pkgrootEl)) {
if (!kid.getLocalName().equals("built-to")) { // NOI18N
continue;
}
- String rawtext = Util.findText(kid);
+ String rawtext = XMLUtil.findText(kid);
assert rawtext != null : "Null content for in " + project;
String text = project.evaluator().evaluate(rawtext);
if (text == null) {
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java
@@ -409,13 +409,13 @@
is.close();
}
Element docel = doc.getDocumentElement();
- Element type = Util.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
+ Element type = XMLUtil.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
String cnb = null;
- if (Util.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
- Element cfg = Util.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
- Element data = Util.findElement(cfg, "data", null); // NOI18N
+ if (XMLUtil.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
+ Element cfg = XMLUtil.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
+ Element data = XMLUtil.findElement(cfg, "data", null); // NOI18N
if (data != null) {
- cnb = Util.findText(Util.findElement(data, "code-name-base", null)); // NOI18N
+ cnb = XMLUtil.findText(XMLUtil.findElement(data, "code-name-base", null)); // NOI18N
}
}
return cnb;
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImpl.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImpl.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImpl.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImpl.java
@@ -50,11 +50,11 @@
import javax.swing.event.ChangeListener;
import org.netbeans.api.java.queries.SourceForBinaryQuery;
import org.netbeans.modules.apisupport.project.NbModuleProject;
-import org.netbeans.modules.apisupport.project.Util;
import org.netbeans.modules.apisupport.project.universe.TestEntry;
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -136,11 +136,11 @@
if (res == null) {
// Check extra compilation units.
ECUS: for (Map.Entry entry : project.getExtraCompilationUnits().entrySet()) {
- for (Element kid : Util.findSubElements(entry.getValue())) {
+ for (Element kid : XMLUtil.findSubElements(entry.getValue())) {
if (!kid.getLocalName().equals("built-to")) { // NOI18N
continue;
}
- String rawtext = Util.findText(kid);
+ String rawtext = XMLUtil.findText(kid);
assert rawtext != null : "Null content for in " + project;
String text = project.evaluator().evaluate(rawtext);
if (text == null) {
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java
@@ -63,6 +63,7 @@
import org.openide.ErrorManager;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -89,19 +90,19 @@
return Collections.emptySet();
}
Element data = project.getPrimaryConfigurationData();
- Element moduleDependencies = Util.findElement(data,
+ Element moduleDependencies = XMLUtil.findElement(data,
"module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
assert moduleDependencies != null : "Malformed metadata in " + project;
- for (Element dep : Util.findSubElements(moduleDependencies)) {
+ for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
/* Probably better to open runtime deps too. TBD.
- if (Util.findElement(dep, "build-prerequisite", // NOI18N
+ if (XMLUtil.findElement(dep, "build-prerequisite", // NOI18N
NbModuleProject.NAMESPACE_SHARED) == null) {
continue;
}
*/
- Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
+ Element cnbEl = XMLUtil.findElement(dep, "code-name-base", // NOI18N
NbModuleProject.NAMESPACE_SHARED);
- String cnb = Util.findText(cnbEl);
+ String cnb = XMLUtil.findText(cnbEl);
ModuleEntry module = ml.getEntry(cnb);
if (module == null) {
Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + project);
@@ -129,15 +130,15 @@
}
}
// #63824: consider also artifacts found in ${cp.extra} and/or s
- for (Element cpext : Util.findSubElements(data)) {
+ for (Element cpext : XMLUtil.findSubElements(data)) {
if (!cpext.getTagName().equals("class-path-extension")) { // NOI18N
continue;
}
- Element binorig = Util.findElement(cpext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element binorig = XMLUtil.findElement(cpext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
if (binorig == null) {
continue;
}
- String text = Util.findText(binorig);
+ String text = XMLUtil.findText(binorig);
String eval = project.evaluator().evaluate(text);
if (eval == null) {
continue;
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java
@@ -89,6 +89,7 @@
import org.openide.util.Lookup;
import org.openide.util.Mutex;
import org.openide.util.lookup.Lookups;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -242,8 +243,8 @@
}
private String getSimpleName() {
- Element nameEl = Util.findElement(helper.getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
- String text = (nameEl != null) ? Util.findText(nameEl) : null;
+ Element nameEl = XMLUtil.findElement(helper.getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
+ String text = (nameEl != null) ? XMLUtil.findText(nameEl) : null;
return (text != null) ? text : "???"; // NOI18N
}
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/BasicBrandingModel.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/BasicBrandingModel.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/BasicBrandingModel.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/BasicBrandingModel.java
@@ -56,7 +56,6 @@
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.annotations.common.NullAllowed;
import org.netbeans.api.project.Project;
-import org.netbeans.modules.apisupport.project.Util;
import org.netbeans.modules.apisupport.project.suite.BrandingSupport;
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BrandedFile;
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BundleKey;
@@ -67,6 +66,7 @@
import org.openide.filesystems.FileUtil;
import org.openide.util.ChangeSupport;
import org.openide.util.NbBundle;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -406,8 +406,8 @@
res = getProjectDirectoryFile().getName();
return res;
}
- Element nameEl = Util.findElement(suiteProps.getProject().getHelper().getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
- String text = (nameEl != null) ? Util.findText(nameEl) : null;
+ Element nameEl = XMLUtil.findElement(suiteProps.getProject().getHelper().getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
+ String text = (nameEl != null) ? XMLUtil.findText(nameEl) : null;
return (text != null) ? text : "???"; // NOI18N
}
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibraries.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibraries.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibraries.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibraries.java
@@ -1467,23 +1467,23 @@
dependencies = new HashSet();
// Cannot use ProjectXMLManager since we need to report also deps on nonexistent modules.
Element dataE = project.getPrimaryConfigurationData();
- Element depsE = Util.findElement(dataE, "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element depsE = XMLUtil.findElement(dataE, "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
assert depsE != null : "Malformed metadata in " + project;
- for (Element dep : Util.findSubElements(depsE)) {
- Element run = Util.findElement(dep, "run-dependency", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ for (Element dep : XMLUtil.findSubElements(depsE)) {
+ Element run = XMLUtil.findElement(dep, "run-dependency", NbModuleProject.NAMESPACE_SHARED); // NOI18N
if (run == null) {
continue;
}
- String text = Util.findText(Util.findElement(dep, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
- Element relverE = Util.findElement(run, "release-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ String text = XMLUtil.findText(XMLUtil.findElement(dep, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
+ Element relverE = XMLUtil.findElement(run, "release-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
if (relverE != null) {
- text += '/' + Util.findText(relverE);
+ text += '/' + XMLUtil.findText(relverE);
}
- Element specverE = Util.findElement(run, "specification-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element specverE = XMLUtil.findElement(run, "specification-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
if (specverE != null) {
- text += " > " + Util.findText(specverE);
+ text += " > " + XMLUtil.findText(specverE);
} else {
- Element implver = Util.findElement(run, "implementation-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element implver = XMLUtil.findElement(run, "implementation-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
if (implver != null) {
// Will special-case '*' as an impl version to mean "match anything".
text += " = *"; // NOI18N
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/AbstractEntryWithSources.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/AbstractEntryWithSources.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/AbstractEntryWithSources.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/AbstractEntryWithSources.java
@@ -54,6 +54,7 @@
import org.openide.ErrorManager;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
abstract class AbstractEntryWithSources extends AbstractEntry {
@@ -136,17 +137,17 @@
return new String[0];
}
Element data = project.getPrimaryConfigurationData();
- Element moduleDependencies = Util.findElement(data,
+ Element moduleDependencies = XMLUtil.findElement(data,
"module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
assert moduleDependencies != null : "Malformed metadata in " + project;
- for (Element dep : Util.findSubElements(moduleDependencies)) {
- if (Util.findElement(dep, "run-dependency", // NOI18N
+ for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
+ if (XMLUtil.findElement(dep, "run-dependency", // NOI18N
NbModuleProject.NAMESPACE_SHARED) == null) {
continue;
}
- Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
+ Element cnbEl = XMLUtil.findElement(dep, "code-name-base", // NOI18N
NbModuleProject.NAMESPACE_SHARED);
- String cnb = Util.findText(cnbEl);
+ String cnb = XMLUtil.findText(cnbEl);
deps.add(cnb);
}
return deps.toArray(new String[deps.size()]);
diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java
@@ -201,8 +201,8 @@
if (data == null) {
throw new IOException("Not an NBM project in " + basedir); // NOI18N
}
- boolean suiteComponent = Util.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
- boolean standalone = Util.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
+ boolean suiteComponent = XMLUtil.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
+ boolean standalone = XMLUtil.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
assert !(suiteComponent && standalone) : basedir;
if (suiteComponent) {
PropertyEvaluator eval = parseProperties(basedir, null, NbModuleType.SUITE_COMPONENT, "irrelevant"); // NOI18N
@@ -528,23 +528,23 @@
}
assert root != null ^ type != NbModuleType.NETBEANS_ORG;
assert path != null ^ type != NbModuleType.NETBEANS_ORG;
- String cnb = Util.findText(Util.findElement(data, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
+ String cnb = XMLUtil.findText(XMLUtil.findElement(data, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
PropertyEvaluator eval = parseProperties(basedir, root, type, cnb);
String module = eval.getProperty("module.jar"); // NOI18N
// Cf. ParseProjectXml.computeClasspath:
StringBuffer cpextra = new StringBuffer();
- for (Element ext : Util.findSubElements(data)) {
+ for (Element ext : XMLUtil.findSubElements(data)) {
if (!ext.getLocalName().equals("class-path-extension")) { // NOI18N
continue;
}
- Element binaryOrigin = Util.findElement(ext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element binaryOrigin = XMLUtil.findElement(ext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
String text;
if (binaryOrigin != null) {
- text = Util.findText(binaryOrigin);
+ text = XMLUtil.findText(binaryOrigin);
} else {
- Element runtimeRelativePath = Util.findElement(ext, "runtime-relative-path", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element runtimeRelativePath = XMLUtil.findElement(ext, "runtime-relative-path", NbModuleProject.NAMESPACE_SHARED); // NOI18N
assert runtimeRelativePath != null : "Malformed in " + basedir;
- String reltext = Util.findText(runtimeRelativePath);
+ String reltext = XMLUtil.findText(runtimeRelativePath);
// XXX assumes that module.jar is not overridden independently of module.jar.dir:
text = "${cluster}/${module.jar.dir}/" + reltext; // NOI18N
}
@@ -967,9 +967,9 @@
} catch (SAXException e) {
throw (IOException) new IOException(e.toString()).initCause(e);
}
- for (Element moduleVersion : Util.findSubElements(doc.getDocumentElement())) {
+ for (Element moduleVersion : XMLUtil.findSubElements(doc.getDocumentElement())) {
if (moduleVersion.getTagName().equals("module_version") && moduleVersion.getAttribute("last").equals("true")) { // NOI18N
- for (Element fileEl : Util.findSubElements(moduleVersion)) {
+ for (Element fileEl : XMLUtil.findSubElements(moduleVersion)) {
if (fileEl.getTagName().equals("file")) { // NOI18N
String name = fileEl.getAttribute("name"); // NOI18N
File f = new File(cluster, name.replace('/', File.separatorChar));
@@ -1007,18 +1007,18 @@
throw (IOException) new IOException(projectXml + ": " + e.toString()).initCause(e); // NOI18N
}
Element docel = doc.getDocumentElement();
- Element type = Util.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
- if (!Util.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
+ Element type = XMLUtil.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
+ if (!XMLUtil.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
return null;
}
- Element cfg = Util.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
- Element data = Util.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED); // NOI18N
+ Element cfg = XMLUtil.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
+ Element data = XMLUtil.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED); // NOI18N
if (data != null) {
return data;
} else {
- data = Util.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED_2); // NOI18N
+ data = XMLUtil.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED_2); // NOI18N
if (data != null) {
- return Util.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
+ return XMLUtil.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
} else {
return null;
}
diff --git a/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ProjectXMLManagerTest.java b/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ProjectXMLManagerTest.java
--- a/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ProjectXMLManagerTest.java
+++ b/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ProjectXMLManagerTest.java
@@ -303,8 +303,8 @@
Document doc = XMLUtil.parse(new InputSource(projectXML.toURI().toString()),
false, true, null, null);
Element project = doc.getDocumentElement();
- Element config = Util.findElement(project, "configuration", null); // NOI18N
- data = Util.findElement(config, "data", NbModuleProject.NAMESPACE_SHARED);
+ Element config = XMLUtil.findElement(project, "configuration", null); // NOI18N
+ data = XMLUtil.findElement(config, "data", NbModuleProject.NAMESPACE_SHARED);
} catch (IOException e) {
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
} catch (SAXException e) {
diff --git a/j2ee.archive/src/org/netbeans/modules/j2ee/archive/project/UpdateHelper.java b/j2ee.archive/src/org/netbeans/modules/j2ee/archive/project/UpdateHelper.java
--- a/j2ee.archive/src/org/netbeans/modules/j2ee/archive/project/UpdateHelper.java
+++ b/j2ee.archive/src/org/netbeans/modules/j2ee/archive/project/UpdateHelper.java
@@ -61,6 +61,7 @@
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
+import org.openide.xml.XMLUtil;
/**
@@ -277,7 +278,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,DATA); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, ArchiveProjectType.PROJECT_CONFIGURATION_NS);
Element sourceRoots = doc.createElementNS(ArchiveProjectType.PROJECT_CONFIGURATION_NS,"source-roots"); //NOI18N
Element root = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,"root"); //NOI18N
root.setAttribute ("id","src.dir"); //NOI18N
@@ -294,7 +295,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,DATA); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, ArchiveProjectType.PROJECT_CONFIGURATION_NS);
cachedElement = updateMinAntVersion (newRoot, doc);
}
}
@@ -317,38 +318,6 @@
return cachedProperties;
}
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(ArchiveProjectType.PROJECT_CONFIGURATION_NS,oldElement.getTagName());
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,newElement);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
public static final String MINIMUM_ANT_VERSION = "1.6.5"; // NOI18N
private static Element updateMinAntVersion (final Element root, final Document doc) {
diff --git a/j2ee.clientproject/nbproject/project.xml b/j2ee.clientproject/nbproject/project.xml
--- a/j2ee.clientproject/nbproject/project.xml
+++ b/j2ee.clientproject/nbproject/project.xml
@@ -399,11 +399,44 @@
unit
+ org.netbeans.libs.junit4
+
+
+
org.netbeans.modules.j2ee.clientproject
+ org.netbeans.modules.j2ee.sun.ddui
+
+
+ org.netbeans.modules.j2eeserver
+
+
+
+ org.netbeans.modules.java.project
+
+
+ org.netbeans.modules.masterfs
+
+
+ org.netbeans.modules.nbjunit
+
+
+
+
+ org.netbeans.modules.projectui
+
+
+
+
+ org.netbeans.modules.websvc.core
+
+
+ org.netbeans.modules.websvc.projectapi
+
+
org.openide.util
@@ -413,30 +446,6 @@
-
- org.netbeans.modules.projectui
-
-
-
-
- org.netbeans.modules.j2eeserver
-
-
-
- org.netbeans.modules.j2ee.sun.ddui
-
-
- org.netbeans.modules.java.project
-
-
- org.netbeans.modules.masterfs
-
-
- org.netbeans.modules.websvc.core
-
-
- org.netbeans.modules.websvc.projectapi
-
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java
@@ -53,6 +53,7 @@
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.NbBundle;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -147,7 +148,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE);
Element sourceRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
Element root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
root.setAttribute ("id","src.dir"); //NOI18N
@@ -164,7 +165,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE);
cachedElement = updateMinAntVersion (newRoot, doc);
}
}
@@ -187,39 +188,6 @@
return cachedProperties;
}
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,newElement);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
private static Element updateMinAntVersion (final Element root, final Document doc) {
NodeList list = root.getElementsByTagNameNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
if (list.getLength() == 1) {
diff --git a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathSupportCallbackImpl.java b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathSupportCallbackImpl.java
--- a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathSupportCallbackImpl.java
+++ b/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathSupportCallbackImpl.java
@@ -51,11 +51,11 @@
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
*
@@ -91,7 +91,7 @@
for ( int i = 0; i < libs.getLength(); i++ ) {
Element item = (Element)libs.item( i );
// appclient is different from other j2ee projects - it stores reference without ${ and }
- String ref = "${"+findText( item )+"}";
+ String ref = "${"+XMLUtil.findText( item )+"}";
libraries.add(ref); // NOI18N
String dirs = item.getAttribute(ATTR_DIRS);
if (Util.DESTINATION_DIRECTORY_ROOT.equals(dirs) ||
@@ -140,23 +140,6 @@
return libraryElement;
}
- /**
- * Extracts the first nested text from an element.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent element
- * @return the nested text, or null if none was found
- */
- private static String findText( Element parent ) {
- NodeList l = parent.getChildNodes();
- for ( int i = 0; i < l.getLength(); i++ ) {
- if ( l.item(i).getNodeType() == Node.TEXT_NODE ) {
- Text text = (Text)l.item( i );
- return text.getNodeValue();
- }
- }
- return null;
- }
-
public void readAdditionalProperties(List- items, String projectXMLElement) {
Map destination = new HashMap();
List l = getIncludedLibraries(antProjectHelper, projectXMLElement, destination);
diff --git a/j2ee.earproject/nbproject/project.xml b/j2ee.earproject/nbproject/project.xml
--- a/j2ee.earproject/nbproject/project.xml
+++ b/j2ee.earproject/nbproject/project.xml
@@ -363,11 +363,48 @@
unit
+ org.netbeans.libs.junit4
+
+
+
org.netbeans.modules.j2ee.earproject
+ org.netbeans.modules.j2ee.sun.dd
+
+
+ org.netbeans.modules.j2ee.sun.ddui
+
+
+ org.netbeans.modules.j2eeserver
+
+
+
+ org.netbeans.modules.masterfs
+
+
+ org.netbeans.modules.nbjunit
+
+
+
+
+ org.netbeans.modules.projectui
+
+
+
+
+ org.netbeans.modules.projectuiapi
+
+
+
+ org.netbeans.modules.web.core
+
+
+ org.netbeans.modules.web.core.syntax
+
+
org.openide.util
@@ -377,34 +414,6 @@
-
- org.netbeans.modules.projectui
-
-
-
-
- org.netbeans.modules.j2eeserver
-
-
-
- org.netbeans.modules.j2ee.sun.dd
-
-
- org.netbeans.modules.j2ee.sun.ddui
-
-
- org.netbeans.modules.masterfs
-
-
- org.netbeans.modules.projectuiapi
-
-
-
- org.netbeans.modules.web.core
-
-
- org.netbeans.modules.web.core.syntax
-
diff --git a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/UpdateProjectImpl.java b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/UpdateProjectImpl.java
--- a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/UpdateProjectImpl.java
+++ b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/UpdateProjectImpl.java
@@ -60,12 +60,10 @@
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
-import org.w3c.dom.Comment;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
@@ -159,7 +157,7 @@
if(oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS(EarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument(doc, oldRoot, newRoot);
+ XMLUtil.copyDocument(oldRoot, newRoot, EarProjectType.PROJECT_CONFIGURATION_NAMESPACE);
//update to
// NodeList contList = newRoot.getElementsByTagNameNS(ns, "web-module-libraries");
@@ -173,7 +171,7 @@
Element library = (Element) libList.item(i);
Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
//remove ${ and } from the beginning and end
- String webFileText = findText(webFile);
+ String webFileText = XMLUtil.findText(webFile);
webFileText = webFileText.substring(2, webFileText.length() - 1);
if (webFileText.startsWith("libs.")) {
String libName = webFileText.substring(5, webFileText.indexOf(".classpath")); //NOI18N
@@ -209,57 +207,6 @@
return cachedElement;
}
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(EarProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,(Element)newNode);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
- /**
- * Extract nested text from a node.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent node
- * @return the nested text, or null if none was found
- */
- private static String findText(Node parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
-
public EditableProperties getUpdatedProjectProperties() {
return helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
}
diff --git a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/classpath/ClassPathSupportCallbackImpl.java b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/classpath/ClassPathSupportCallbackImpl.java
--- a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/classpath/ClassPathSupportCallbackImpl.java
+++ b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/classpath/ClassPathSupportCallbackImpl.java
@@ -41,20 +41,18 @@
package org.netbeans.modules.j2ee.earproject.classpath;
-import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
-import org.netbeans.modules.j2ee.common.project.ui.J2EEProjectProperties;
import org.netbeans.modules.j2ee.earproject.EarProjectType;
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
* Defines the various class paths for a web project.
@@ -135,8 +133,8 @@
Element library = (Element) ch.item(i);
Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
NodeList pathInEarElements = library.getElementsByTagNameNS(ns, TAG_PATH_IN_EAR);
- earIncludesMap.put(findText(webFile), pathInEarElements.getLength() > 0 ?
- findText(pathInEarElements.item(0)) : null);
+ earIncludesMap.put(XMLUtil.findText(webFile), pathInEarElements.getLength() > 0 ?
+ XMLUtil.findText(pathInEarElements.item(0)) : null);
}
}
}
@@ -144,15 +142,5 @@
return earIncludesMap;
}
- private static String findText(Node parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
}
diff --git a/j2ee.ejbjarproject/nbproject/project.xml b/j2ee.ejbjarproject/nbproject/project.xml
--- a/j2ee.ejbjarproject/nbproject/project.xml
+++ b/j2ee.ejbjarproject/nbproject/project.xml
@@ -474,6 +474,10 @@
unit
+ org.netbeans.libs.junit4
+
+
+
org.netbeans.modules.j2ee.ejbjarproject
@@ -482,6 +486,11 @@
org.netbeans.modules.masterfs
+ org.netbeans.modules.nbjunit
+
+
+
+
org.netbeans.modules.projectui
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java
@@ -172,6 +172,7 @@
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileSystem.AtomicAction;
import org.openide.util.Exceptions;
+import org.openide.xml.XMLUtil;
/**
* Represents one ejb module project
@@ -627,7 +628,7 @@
if (element != null) {
Document doc = element.getOwnerDocument();
Element newRoot = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, element, newRoot);
+ XMLUtil.copyDocument (element, newRoot, EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE);
Element srcRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "source-roots"); //NOI18N
Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
root.setAttribute ("id","src.dir"); //NOI18N
@@ -643,33 +644,6 @@
}
}
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- copyDocument(doc,oldElement,(Element)newNode);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
public void fileAttributeChanged (org.openide.filesystems.FileAttributeEvent fe) {
}
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateProjectImpl.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateProjectImpl.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateProjectImpl.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateProjectImpl.java
@@ -59,13 +59,11 @@
import org.openide.filesystems.FileUtil;
import org.openide.util.Mutex;
import org.openide.util.NbBundle;
-import org.w3c.dom.Comment;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
*
@@ -191,7 +189,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE);
if(version == 1) {
//1=>2 upgrade
Element sourceRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
@@ -211,7 +209,7 @@
for (int i = 0; i < libList.getLength(); i++) {
if (libList.item(i).getNodeType() == Node.ELEMENT_NODE) {
Element library = (Element) libList.item(i);
- String fileText = findText(library);
+ String fileText = XMLUtil.findText(library);
if (fileText.startsWith ("libs.")) {
String libName = fileText.substring(6, fileText.indexOf(".classpath")); //NOI18N
List/**/ roots = LibraryManager.getDefault().getLibrary(libName).getContent("classpath"); //NOI18N
@@ -253,40 +251,6 @@
return helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
}
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- //copy attributes
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,(Element)newNode);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
private static Element updateMinAntVersion (final Element root, final Document doc) {
NodeList list = root.getElementsByTagNameNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
if (list.getLength() == 1) {
@@ -301,23 +265,6 @@
return root;
}
- /**
- * Extract nested text from a node.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent node
- * @return the nested text, or null if none was found
- */
- private static String findText(Node parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
private boolean showUpdateDialog() {
return DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Confirmation (NbBundle.getMessage(UpdateProjectImpl.class,"TXT_ProjectUpdate",BUILD_NUMBER),
diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/ClassPathSupportCallbackImpl.java b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/ClassPathSupportCallbackImpl.java
--- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/ClassPathSupportCallbackImpl.java
+++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/ClassPathSupportCallbackImpl.java
@@ -42,9 +42,7 @@
package org.netbeans.modules.j2ee.ejbjarproject.classpath;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.netbeans.modules.j2ee.common.Util;
@@ -55,9 +53,9 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectType;
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
+import org.openide.xml.XMLUtil;
/**
*
@@ -95,7 +93,7 @@
for ( int i = 0; i < libs.getLength(); i++ ) {
Element item = (Element)libs.item( i );
// ejbjar is different from other j2ee projects - it stores reference without ${ and }
- String ref = "${"+findText( item )+"}";
+ String ref = "${"+XMLUtil.findText( item )+"}";
libraries.add(ref); // NOI18N
String dirs = item.getAttribute(ATTR_DIRS);
if (Util.DESTINATION_DIRECTORY_ROOT.equals(dirs) ||
@@ -125,7 +123,7 @@
Document doc = data.getOwnerDocument();
for (ClassPathSupport.Item item : classpath) {
if("true".equals(item.getAdditionalProperty(INCLUDE_IN_DEPLOYMENT))) { // NOI18N
- appendChildElement(data,
+ XMLUtil.appendChildElement(data,
createLibraryElement(antProjectHelper, doc, item, includedLibrariesElement),
ejbjarElemOrder);
}
@@ -134,62 +132,6 @@
antProjectHelper.putPrimaryConfigurationData( data, true );
}
- /**
- * Find all direct child elements of an element.
- * More useful than {@link Element#getElementsByTagNameNS} because it does
- * not recurse into recursive child elements.
- * Children which are all-whitespace text nodes are ignored; others cause
- * an exception to be thrown.
- * @param parent a parent element in a DOM tree
- * @return a list of direct child elements (may be empty)
- * @throws IllegalArgumentException if there are non-element children besides whitespace
- */
- private static List findSubElements(Element parent) throws IllegalArgumentException {
- NodeList l = parent.getChildNodes();
- List elements = new ArrayList(l.getLength());
- for (int i = 0; i < l.getLength(); i++) {
- Node n = l.item(i);
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- elements.add((Element)n);
- } else if (n.getNodeType() == Node.TEXT_NODE) {
- String text = ((Text)n).getNodeValue();
- if (text.trim().length() > 0) {
- throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
- }
- } else if (n.getNodeType() == Node.COMMENT_NODE) {
- // skip
- } else {
- throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
- }
- }
- return elements;
- }
-
- /**
- * Append child element to the correct position according to given
- * order.
- * @param parent parent to which the child will be added
- * @param el element to be added
- * @param order order of the elements which must be followed
- */
- private static void appendChildElement(Element parent, Element el, String[] order) {
- Element insertBefore = null;
- List l = Arrays.asList(order);
- int index = l.indexOf(el.getLocalName());
- assert index != -1 : el.getLocalName()+" was not found in "+l; // NOI18N
- Iterator it = findSubElements(parent).iterator();
- while (it.hasNext()) {
- Element e = (Element)it.next();
- int index2 = l.indexOf(e.getLocalName());
- assert index2 != -1 : e.getLocalName()+" was not found in "+l; // NOI18N
- if (index2 > index) {
- insertBefore = e;
- break;
- }
- }
- parent.insertBefore(el, insertBefore);
- }
-
private static Element createLibraryElement(AntProjectHelper antProjectHelper, Document doc, Item item, String includedLibrariesElement) {
Element libraryElement = doc.createElementNS( EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, includedLibrariesElement );
// ejbjar is different from other j2ee projects - it stores reference without ${ and }
@@ -198,24 +140,6 @@
return libraryElement;
}
- /**
- * Extracts the first nested text from an element.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent element
- * @return the nested text, or null if none was found
- */
- private static String findText( Element parent ) {
- NodeList l = parent.getChildNodes();
- for ( int i = 0; i < l.getLength(); i++ ) {
- if ( l.item(i).getNodeType() == Node.TEXT_NODE ) {
- Text text = (Text)l.item( i );
- return text.getNodeValue();
- }
- }
- return null;
- }
-
-
public void readAdditionalProperties(List
- items, String projectXMLElement) {
Map destination = new HashMap();
List l = getIncludedLibraries(helper, projectXMLElement, destination);
diff --git a/java.freeform/nbproject/project.xml b/java.freeform/nbproject/project.xml
--- a/java.freeform/nbproject/project.xml
+++ b/java.freeform/nbproject/project.xml
@@ -200,7 +200,7 @@
- 8.0
+ 8.3
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/Classpaths.java b/java.freeform/src/org/netbeans/modules/java/freeform/Classpaths.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/Classpaths.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/Classpaths.java
@@ -89,6 +89,7 @@
import org.openide.util.Mutex;
import org.openide.util.Utilities;
import org.openide.util.WeakListeners;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -193,7 +194,7 @@
if (java == null) {
return null;
}
- List compilationUnits = Util.findSubElements(java);
+ List compilationUnits = XMLUtil.findSubElements(java);
it = compilationUnits.iterator();
while (it.hasNext()) {
Element compilationUnitEl = (Element)it.next();
@@ -258,7 +259,7 @@
if (java == null) {
return;
}
- for (Element compilationUnitEl : Util.findSubElements(java)) {
+ for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
// For each compilation unit, find the package roots first.
List packageRoots = findPackageRoots(helper, evaluator, compilationUnitEl);
@@ -337,13 +338,13 @@
static List findPackageRootNames(Element compilationUnitEl) {
List names = new ArrayList();
- Iterator it = Util.findSubElements(compilationUnitEl).iterator();
+ Iterator it = XMLUtil.findSubElements(compilationUnitEl).iterator();
while (it.hasNext()) {
Element e = (Element) it.next();
if (!e.getLocalName().equals("package-root")) { // NOI18N
continue;
}
- String location = Util.findText(e);
+ String location = XMLUtil.findText(e);
names.add(location);
}
return names;
@@ -421,7 +422,7 @@
}
private List createCompileClasspath(Element compilationUnitEl) {
- for (Element e : Util.findSubElements(compilationUnitEl)) {
+ for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("compile")) { // NOI18N
return createClasspath(e);
}
@@ -434,7 +435,7 @@
* Create a classpath from a <classpath> element.
*/
private List createClasspath(Element classpathEl) {
- String cp = Util.findText(classpathEl);
+ String cp = XMLUtil.findText(classpathEl);
if (cp == null) {
cp = "";
}
@@ -456,7 +457,7 @@
}
private List createExecuteClasspath(List packageRoots, Element compilationUnitEl) {
- for (Element e : Util.findSubElements(compilationUnitEl)) {
+ for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("execute")) { // NOI18N
return createClasspath(e);
}
@@ -466,12 +467,12 @@
List urls = new ArrayList();
urls.addAll(createCompileClasspath(compilationUnitEl));
boolean foundBuiltTos = false;
- for (Element builtTo : Util.findSubElements(compilationUnitEl)) {
+ for (Element builtTo : XMLUtil.findSubElements(compilationUnitEl)) {
if (!builtTo.getLocalName().equals("built-to")) { // NOI18N
continue;
}
foundBuiltTos = true;
- String rawtext = Util.findText(builtTo);
+ String rawtext = XMLUtil.findText(builtTo);
assert rawtext != null : "Must have nonempty text inside ";
String text = evaluator.evaluate(rawtext);
if (text == null) {
@@ -486,7 +487,7 @@
}
private List createProcessorClasspath(Element compilationUnitEl) {
- for (Element e : Util.findSubElements(compilationUnitEl)) {
+ for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("processor")) { // NOI18N
return createClasspath(e);
}
@@ -496,7 +497,7 @@
}
private List createBootClasspath(Element compilationUnitEl) {
- for (Element e : Util.findSubElements(compilationUnitEl)) {
+ for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("boot")) { // NOI18N
return createClasspath(e);
}
@@ -571,7 +572,7 @@
if (java == null) {
return null;
}
- List compilationUnits = Util.findSubElements(java);
+ List compilationUnits = XMLUtil.findSubElements(java);
Iterator it = compilationUnits.iterator();
while (it.hasNext()) {
Element compilationUnitEl = (Element)it.next();
@@ -680,28 +681,28 @@
rootFolder = null;
}
Element genldata = Util.getPrimaryConfigurationData(helper);
- Element foldersE = Util.findElement(genldata, "folders", Util.NAMESPACE); // NOI18N
+ Element foldersE = XMLUtil.findElement(genldata, "folders", Util.NAMESPACE); // NOI18N
if (foldersE != null) {
- for (Element folderE : Util.findSubElements(foldersE)) {
+ for (Element folderE : XMLUtil.findSubElements(foldersE)) {
if (folderE.getLocalName().equals("source-folder")) {
- Element typeE = Util.findElement(folderE, "type", Util.NAMESPACE); // NOI18N
+ Element typeE = XMLUtil.findElement(folderE, "type", Util.NAMESPACE); // NOI18N
if (typeE != null) {
- String type = Util.findText(typeE);
+ String type = XMLUtil.findText(typeE);
if (type.equals(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
- Element locationE = Util.findElement(folderE, "location", Util.NAMESPACE); // NOI18N
- String location = evaluator.evaluate(Util.findText(locationE));
+ Element locationE = XMLUtil.findElement(folderE, "location", Util.NAMESPACE); // NOI18N
+ String location = evaluator.evaluate(XMLUtil.findText(locationE));
if (location != null && helper.resolveFile(location).equals(rootFolder)) {
- Element includesE = Util.findElement(folderE, "includes", Util.NAMESPACE); // NOI18N
+ Element includesE = XMLUtil.findElement(folderE, "includes", Util.NAMESPACE); // NOI18N
if (includesE != null) {
- incl = evaluator.evaluate(Util.findText(includesE));
+ incl = evaluator.evaluate(XMLUtil.findText(includesE));
if (incl != null && incl.matches("\\$\\{[^}]+\\}")) { // NOI18N
// Clearly intended to mean "include everything".
incl = null;
}
}
- Element excludesE = Util.findElement(folderE, "excludes", Util.NAMESPACE); // NOI18N
+ Element excludesE = XMLUtil.findElement(folderE, "excludes", Util.NAMESPACE); // NOI18N
if (excludesE != null) {
- excl = evaluator.evaluate(Util.findText(excludesE));
+ excl = evaluator.evaluate(XMLUtil.findText(excludesE));
}
}
}
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/JavaActions.java b/java.freeform/src/org/netbeans/modules/java/freeform/JavaActions.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/JavaActions.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/JavaActions.java
@@ -506,19 +506,19 @@
antProject.setAttribute("basedir", /* ".." times count('/', FILE_SCRIPT_PATH) */".."); // NOI18N
// Look for in project.xml and make corresponding definitions in the Ant script.
Element data = Util.getPrimaryConfigurationData(helper);
- Element properties = Util.findElement(data, "properties", Util.NAMESPACE);
+ Element properties = XMLUtil.findElement(data, "properties", Util.NAMESPACE);
if (properties != null) {
- for (Element el : Util.findSubElements(properties)) {
+ for (Element el : XMLUtil.findSubElements(properties)) {
Element nue = antProject.getOwnerDocument().createElement("property"); // NOI18N
if (el.getLocalName().equals("property")) { // NOI18N
String name = el.getAttribute("name"); // NOI18N
assert name != null;
- String text = Util.findText(el);
+ String text = XMLUtil.findText(el);
assert text != null;
nue.setAttribute("name", name);
nue.setAttribute("value", text);
} else if (el.getLocalName().equals("property-file")) { // NOI18N
- String text = Util.findText(el);
+ String text = XMLUtil.findText(el);
assert text != null;
nue.setAttribute("file", text);
} else {
@@ -615,7 +615,7 @@
if (java == null) {
return Collections.emptyList();
}
- return Util.findSubElements(java);
+ return XMLUtil.findSubElements(java);
}
/**
@@ -684,9 +684,9 @@
*/
private Element findCompilationUnit(String sources) {
for (Element compilationUnitEl : compilationUnits()) {
- for (Element packageRoot : Util.findSubElements(compilationUnitEl)) {
+ for (Element packageRoot : XMLUtil.findSubElements(compilationUnitEl)) {
if (packageRoot.getLocalName().equals("package-root")) { // NOI18N
- if (Util.findText(packageRoot).equals(sources)) {
+ if (XMLUtil.findText(packageRoot).equals(sources)) {
return compilationUnitEl;
}
}
@@ -714,9 +714,9 @@
*/
private String findClassesOutputDir(Element compilationUnitEl) {
// Look for an appropriate .
- for (Element builtTo : Util.findSubElements(compilationUnitEl)) {
+ for (Element builtTo : XMLUtil.findSubElements(compilationUnitEl)) {
if (builtTo.getLocalName().equals("built-to")) { // NOI18N
- String rawtext = Util.findText(builtTo);
+ String rawtext = XMLUtil.findText(builtTo);
// Check that it is not an archive.
String evaltext = evaluator.evaluate(rawtext);
if (evaltext != null) {
@@ -745,9 +745,9 @@
String findSourceLevel(String sources) {
Element compilationUnitEl = findCompilationUnit(sources);
if (compilationUnitEl != null) {
- Element sourceLevel = Util.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
+ Element sourceLevel = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
if (sourceLevel != null) {
- return Util.findText(sourceLevel);
+ return XMLUtil.findText(sourceLevel);
}
}
return null;
@@ -761,11 +761,11 @@
String findCUClasspath(String sources, String moud) {
Element compilationUnitEl = findCompilationUnit(sources);
if (compilationUnitEl != null) {
- for (Element classpath : Util.findSubElements(compilationUnitEl)) {
+ for (Element classpath : XMLUtil.findSubElements(compilationUnitEl)) {
if (classpath.getLocalName().equals("classpath")) { // NOI18N
String mode = classpath.getAttribute("mode"); // NOI18N
if (mode.equals(moud)) {
- return Util.findText(classpath);
+ return XMLUtil.findText(classpath);
}
}
}
@@ -810,11 +810,11 @@
// XXX cannot use FreeformProjectGenerator since that is currently not a public support SPI from ant/freeform
// XXX should this try to find an existing binding? probably not, since it is assumed that if there was one, we would never get here to begin with
Element data = Util.getPrimaryConfigurationData(helper);
- Element ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
+ Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
if (ideActions == null) {
//fix for #58442:
ideActions = data.getOwnerDocument().createElementNS(Util.NAMESPACE, "ide-actions"); // NOI18N
- Util.appendChildElement(data, ideActions, rootElementsOrder);
+ XMLUtil.appendChildElement(data, ideActions, rootElementsOrder);
}
Document doc = data.getOwnerDocument();
Element action = doc.createElementNS(Util.NAMESPACE, "action"); // NOI18N
@@ -854,9 +854,9 @@
} else {
// Add a context menu item, since it applies to the project as a whole.
// Assume there is already a defined, which is quite likely.
- Element view = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
+ Element view = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
if (view != null) {
- Element contextMenu = Util.findElement(view, "context-menu", Util.NAMESPACE); // NOI18N
+ Element contextMenu = XMLUtil.findElement(view, "context-menu", Util.NAMESPACE); // NOI18N
if (contextMenu != null) {
Element ideAction = doc.createElementNS(Util.NAMESPACE, "ide-action"); // NOI18N
ideAction.setAttribute("name", command); // NOI18N
@@ -994,7 +994,7 @@
return null;
}
}
- for (Element target : Util.findSubElements(doc.getDocumentElement())) {
+ for (Element target : XMLUtil.findSubElements(doc.getDocumentElement())) {
if (target.getLocalName().equals("target") && targetName.equals(target.getAttribute("name"))) { // NOI18N
return target;
}
@@ -1010,23 +1010,23 @@
*/
String[] findCommandBinding(String command) {
Element data = Util.getPrimaryConfigurationData(helper);
- Element ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
+ Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
if (ideActions == null) {
return null;
}
String scriptName = "build.xml"; // NOI18N
- for (Element action : Util.findSubElements(ideActions)) {
+ for (Element action : XMLUtil.findSubElements(ideActions)) {
assert action.getLocalName().equals("action");
if (action.getAttribute("name").equals(command)) {
- Element script = Util.findElement(action, "script", Util.NAMESPACE); // NOI18N
+ Element script = XMLUtil.findElement(action, "script", Util.NAMESPACE); // NOI18N
if (script != null) {
- scriptName = Util.findText(script);
+ scriptName = XMLUtil.findText(script);
}
List scriptPlusTargetNames = new ArrayList();
scriptPlusTargetNames.add(scriptName);
- for (Element target : Util.findSubElements(action)) {
+ for (Element target : XMLUtil.findSubElements(action)) {
if (target.getLocalName().equals("target")) { // NOI18N
- scriptPlusTargetNames.add(Util.findText(target));
+ scriptPlusTargetNames.add(XMLUtil.findText(target));
}
}
if (scriptName.equals(JdkConfiguration.NBJDK_XML) && scriptPlusTargetNames.size() > 1) {
@@ -1069,7 +1069,7 @@
Element targetUsesTaskExactlyOnce(Element target, String taskName) {
// XXX should maybe also look for any other usage of the task in the same script in case there is none in the mentioned target
Element foundTask = null;
- for (Element task : Util.findSubElements(target)) {
+ for (Element task : XMLUtil.findSubElements(target)) {
if (task.getLocalName().equals(taskName)) {
if (foundTask != null) {
// Duplicate.
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/JavaFreeformFileBuiltQuery.java b/java.freeform/src/org/netbeans/modules/java/freeform/JavaFreeformFileBuiltQuery.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/JavaFreeformFileBuiltQuery.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/JavaFreeformFileBuiltQuery.java
@@ -47,7 +47,6 @@
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.queries.FileBuiltQuery.Status;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.support.ant.AntProjectEvent;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
@@ -58,6 +57,7 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Mutex;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -99,7 +99,7 @@
List to = new ArrayList();
if (java != null) {
- List compilationUnits = Util.findSubElements(java);
+ List compilationUnits = XMLUtil.findSubElements(java);
Iterator it = compilationUnits.iterator();
while (it.hasNext()) {
Element compilationUnitEl = (Element)it.next();
@@ -188,11 +188,11 @@
static List findBuiltToNames(Element compilationUnitEl) {
List names = new ArrayList();
- for (Element e : Util.findSubElements(compilationUnitEl)) {
+ for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
if (!e.getLocalName().equals("built-to")) { // NOI18N
continue;
}
- String location = Util.findText(e);
+ String location = XMLUtil.findText(e);
names.add(location);
}
return names;
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectGenerator.java b/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectGenerator.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectGenerator.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectGenerator.java
@@ -60,6 +60,7 @@
import org.openide.filesystems.FileUtil;
import org.openide.modules.SpecificationVersion;
import org.openide.util.Exceptions;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -113,38 +114,38 @@
//assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
List list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
- Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
+ Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
if (foldersEl == null) {
return list;
}
- for (Element sourceFolderEl : Util.findSubElements(foldersEl)) {
+ for (Element sourceFolderEl : XMLUtil.findSubElements(foldersEl)) {
if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
continue;
}
SourceFolder sf = new SourceFolder();
- Element el = Util.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
+ Element el = XMLUtil.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.label = Util.findText(el);
+ sf.label = XMLUtil.findText(el);
}
- el = Util.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
+ el = XMLUtil.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.type = Util.findText(el);
+ sf.type = XMLUtil.findText(el);
}
- el = Util.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
+ el = XMLUtil.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.location = Util.findText(el);
+ sf.location = XMLUtil.findText(el);
}
- el = Util.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
+ el = XMLUtil.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.includes = Util.findText(el);
+ sf.includes = XMLUtil.findText(el);
}
- el = Util.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
+ el = XMLUtil.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.excludes = Util.findText(el);
+ sf.excludes = XMLUtil.findText(el);
}
- el = Util.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
+ el = XMLUtil.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.encoding = Util.findText(el);
+ sf.encoding = XMLUtil.findText(el);
}
if (type == null || type.equals(sf.type)) {
if (sf.label == null || sf.label.length() == 0) {
@@ -173,21 +174,21 @@
//assert ProjectManager.mutex().isWriteAccess();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
+ Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
if (foldersEl == null) {
foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
- Util.appendChildElement(data, foldersEl, rootElementsOrder);
+ XMLUtil.appendChildElement(data, foldersEl, rootElementsOrder);
} else {
- for (Element sourceFolderEl : Util.findSubElements(foldersEl)) {
+ for (Element sourceFolderEl : XMLUtil.findSubElements(foldersEl)) {
if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
continue;
}
if (type == null) {
foldersEl.removeChild(sourceFolderEl);
} else {
- Element typeEl = Util.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
+ Element typeEl = XMLUtil.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
if (typeEl != null) {
- String typeElValue = Util.findText(typeEl);
+ String typeElValue = XMLUtil.findText(typeEl);
if (type.equals(typeElValue)) {
foldersEl.removeChild(sourceFolderEl);
}
@@ -232,7 +233,7 @@
el.appendChild(doc.createTextNode(sf.encoding)); // NOI18N
sourceFolderEl.appendChild(el);
}
- Util.appendChildElement(foldersEl, sourceFolderEl, folderElementsOrder);
+ XMLUtil.appendChildElement(foldersEl, sourceFolderEl, folderElementsOrder);
}
Util.putPrimaryConfigurationData(helper, data);
}
@@ -249,36 +250,36 @@
//assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
List list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
- Element viewEl = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
+ Element viewEl = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
if (viewEl == null) {
return list;
}
- Element itemsEl = Util.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
+ Element itemsEl = XMLUtil.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
if (itemsEl == null) {
return list;
}
- for (Element sourceFolderEl : Util.findSubElements(itemsEl)) {
+ for (Element sourceFolderEl : XMLUtil.findSubElements(itemsEl)) {
if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
continue;
}
SourceFolder sf = new SourceFolder();
sf.style = sourceFolderEl.getAttribute("style"); // NOI18N
assert sf.style != null && sf.style.length() > 0 : "Bad style attr on in " + helper; // NOI18N
- Element el = Util.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
+ Element el = XMLUtil.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.label = Util.findText(el);
+ sf.label = XMLUtil.findText(el);
}
- el = Util.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
+ el = XMLUtil.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.location = Util.findText(el);
+ sf.location = XMLUtil.findText(el);
}
- el = Util.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
+ el = XMLUtil.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.includes = Util.findText(el);
+ sf.includes = XMLUtil.findText(el);
}
- el = Util.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
+ el = XMLUtil.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
if (el != null) {
- sf.excludes = Util.findText(el);
+ sf.excludes = XMLUtil.findText(el);
}
if (style == null || style.equals(sf.style)) {
list.add(sf);
@@ -303,17 +304,17 @@
ArrayList list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element viewEl = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
+ Element viewEl = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
if (viewEl == null) {
viewEl = doc.createElementNS(Util.NAMESPACE, "view"); // NOI18N
- Util.appendChildElement(data, viewEl, rootElementsOrder);
+ XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
}
- Element itemsEl = Util.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
+ Element itemsEl = XMLUtil.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
if (itemsEl == null) {
itemsEl = doc.createElementNS(Util.NAMESPACE, "items"); // NOI18N
- Util.appendChildElement(viewEl, itemsEl, viewElementsOrder);
+ XMLUtil.appendChildElement(viewEl, itemsEl, viewElementsOrder);
}
- List sourceViews = Util.findSubElements(itemsEl);
+ List sourceViews = XMLUtil.findSubElements(itemsEl);
Iterator it = sourceViews.iterator();
while (it.hasNext()) {
Element sourceViewEl = (Element)it.next();
@@ -355,7 +356,7 @@
el.appendChild(doc.createTextNode(sf.excludes)); // NOI18N
sourceFolderEl.appendChild(el);
}
- Util.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
+ XMLUtil.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
}
Util.putPrimaryConfigurationData(helper, data);
}
@@ -390,20 +391,20 @@
if (data == null) {
return list;
}
- for (Element cuEl : Util.findSubElements(data)) {
+ for (Element cuEl : XMLUtil.findSubElements(data)) {
JavaCompilationUnit cu = new JavaCompilationUnit();
List outputs = new ArrayList();
List javadoc = new ArrayList();
List cps = new ArrayList();
List packageRoots = new ArrayList();
- for (Element el : Util.findSubElements(cuEl)) {
+ for (Element el : XMLUtil.findSubElements(cuEl)) {
if (el.getLocalName().equals("package-root")) { // NOI18N
- packageRoots.add(Util.findText(el));
+ packageRoots.add(XMLUtil.findText(el));
continue;
}
if (el.getLocalName().equals("classpath")) { // NOI18N
JavaCompilationUnit.CP cp = new JavaCompilationUnit.CP();
- cp.classpath = Util.findText(el);
+ cp.classpath = XMLUtil.findText(el);
cp.mode = el.getAttribute("mode"); // NOI18N
if (cp.mode != null && cp.classpath != null) {
cps.add(cp);
@@ -411,15 +412,15 @@
continue;
}
if (el.getLocalName().equals("built-to")) { // NOI18N
- outputs.add(Util.findText(el));
+ outputs.add(XMLUtil.findText(el));
continue;
}
if (el.getLocalName().equals("javadoc-built-to")) { // NOI18N
- javadoc.add(Util.findText(el));
+ javadoc.add(XMLUtil.findText(el));
continue;
}
if (el.getLocalName().equals("source-level")) { // NOI18N
- cu.sourceLevel = Util.findText(el);
+ cu.sourceLevel = XMLUtil.findText(el);
}
if (el.getLocalName().equals("unit-tests")) { // NOI18N
cu.isTests = true;
@@ -503,7 +504,7 @@
}
}
Document doc = data.getOwnerDocument();
- for (Element cuEl : Util.findSubElements(data)) {
+ for (Element cuEl : XMLUtil.findSubElements(data)) {
data.removeChild(cuEl);
}
for (JavaCompilationUnit cu : compUnits) {
@@ -656,7 +657,7 @@
ArrayList list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Iterator it = Util.findSubElements(data).iterator();
+ Iterator it = XMLUtil.findSubElements(data).iterator();
while (it.hasNext()) {
Element exportEl = (Element)it.next();
if (!exportEl.getLocalName().equals("export")) { // NOI18N
@@ -688,7 +689,7 @@
el.appendChild(doc.createTextNode(export.cleanTarget)); // NOI18N
exportEl.appendChild(el);
}
- Util.appendChildElement(data, exportEl, rootElementsOrder);
+ XMLUtil.appendChildElement(data, exportEl, rootElementsOrder);
}
Util.putPrimaryConfigurationData(helper, data);
}
@@ -736,12 +737,12 @@
ArrayList list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element subproject = Util.findElement(data, "subprojects", Util.NAMESPACE); // NOI18N
+ Element subproject = XMLUtil.findElement(data, "subprojects", Util.NAMESPACE); // NOI18N
if (subproject != null) {
data.removeChild(subproject);
}
subproject = doc.createElementNS(Util.NAMESPACE, "subprojects"); // NOI18N
- Util.appendChildElement(data, subproject, rootElementsOrder);
+ XMLUtil.appendChildElement(data, subproject, rootElementsOrder);
Iterator it = subprojects.iterator();
while (it.hasNext()) {
@@ -819,12 +820,12 @@
private static void putBuildElement(AntProjectHelper helper, List buildFolders, String elemName) {
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
+ Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
if (foldersEl == null) {
foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
- Util.appendChildElement(data, foldersEl, rootElementsOrder);
+ XMLUtil.appendChildElement(data, foldersEl, rootElementsOrder);
} else {
- List folders = Util.findSubElements(foldersEl);
+ List folders = XMLUtil.findSubElements(foldersEl);
Iterator it = folders.iterator();
while (it.hasNext()) {
Element buildFolderEl = (Element)it.next();
@@ -841,7 +842,7 @@
Element locationEl = doc.createElementNS(Util.NAMESPACE, "location"); // NOI18N
locationEl.appendChild(doc.createTextNode(location));
buildFolderEl.appendChild(locationEl);
- Util.appendChildElement(foldersEl, buildFolderEl, folderElementsOrder);
+ XMLUtil.appendChildElement(foldersEl, buildFolderEl, folderElementsOrder);
}
Util.putPrimaryConfigurationData(helper, data);
}
@@ -900,47 +901,47 @@
//assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
List list = new ArrayList();
Element genldata = Util.getPrimaryConfigurationData(helper);
- Element actionsEl = Util.findElement(genldata, "ide-actions", Util.NAMESPACE); // NOI18N
+ Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", Util.NAMESPACE); // NOI18N
if (actionsEl == null) {
return list;
}
- for (Element actionEl : Util.findSubElements(actionsEl)) {
+ for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
TargetMapping tm = new TargetMapping();
tm.name = actionEl.getAttribute("name"); // NOI18N
List targetNames = new ArrayList();
EditableProperties props = new EditableProperties(false);
- for (Element subEl : Util.findSubElements(actionEl)) {
+ for (Element subEl : XMLUtil.findSubElements(actionEl)) {
if (subEl.getLocalName().equals("target")) { // NOI18N
- targetNames.add(Util.findText(subEl));
+ targetNames.add(XMLUtil.findText(subEl));
continue;
}
if (subEl.getLocalName().equals("script")) { // NOI18N
- tm.script = Util.findText(subEl);
+ tm.script = XMLUtil.findText(subEl);
continue;
}
if (subEl.getLocalName().equals("context")) { // NOI18N
TargetMapping.Context ctx = new TargetMapping.Context();
- for (Element contextSubEl : Util.findSubElements(subEl)) {
+ for (Element contextSubEl : XMLUtil.findSubElements(subEl)) {
if (contextSubEl.getLocalName().equals("property")) { // NOI18N
- ctx.property = Util.findText(contextSubEl);
+ ctx.property = XMLUtil.findText(contextSubEl);
continue;
}
if (contextSubEl.getLocalName().equals("format")) { // NOI18N
- ctx.format = Util.findText(contextSubEl);
+ ctx.format = XMLUtil.findText(contextSubEl);
continue;
}
if (contextSubEl.getLocalName().equals("folder")) { // NOI18N
- ctx.folder = Util.findText(contextSubEl);
+ ctx.folder = XMLUtil.findText(contextSubEl);
continue;
}
if (contextSubEl.getLocalName().equals("pattern")) { // NOI18N
- ctx.pattern = Util.findText(contextSubEl);
+ ctx.pattern = XMLUtil.findText(contextSubEl);
continue;
}
if (contextSubEl.getLocalName().equals("arity")) { // NOI18N
- Element sepFilesEl = Util.findElement(contextSubEl, "separated-files", Util.NAMESPACE); // NOI18N
+ Element sepFilesEl = XMLUtil.findElement(contextSubEl, "separated-files", Util.NAMESPACE); // NOI18N
if (sepFilesEl != null) {
- ctx.separator = Util.findText(sepFilesEl);
+ ctx.separator = XMLUtil.findText(sepFilesEl);
}
continue;
}
@@ -994,7 +995,7 @@
private static void readProperty(Element propertyElement, EditableProperties props) {
String key = propertyElement.getAttribute("name"); // NOI18N
- String value = Util.findText(propertyElement);
+ String value = XMLUtil.findText(propertyElement);
props.setProperty(key, value);
}
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/JavadocQuery.java b/java.freeform/src/org/netbeans/modules/java/freeform/JavadocQuery.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/JavadocQuery.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/JavadocQuery.java
@@ -47,12 +47,12 @@
import java.util.List;
import javax.swing.event.ChangeListener;
import org.netbeans.api.java.queries.JavadocForBinaryQuery;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.openide.filesystems.FileUtil;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -74,12 +74,12 @@
public JavadocForBinaryQuery.Result findJavadoc(URL binaryRoot) {
Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
if (data != null) {
- for (Element cu : Util.findSubElements(data)) {
+ for (Element cu : XMLUtil.findSubElements(data)) {
assert cu.getLocalName().equals("compilation-unit") : cu;
boolean rightCU = false;
- for (Element builtTo : Util.findSubElements(cu)) {
+ for (Element builtTo : XMLUtil.findSubElements(cu)) {
if (builtTo.getLocalName().equals("built-to")) { // NOI18N
- String rawtext = Util.findText(builtTo);
+ String rawtext = XMLUtil.findText(builtTo);
assert rawtext != null;
String evaltext = eval.evaluate(rawtext);
if (evaltext != null) {
@@ -95,9 +95,9 @@
}
if (rightCU) {
List resultURLs = new ArrayList();
- for (Element javadocTo : Util.findSubElements(cu)) {
+ for (Element javadocTo : XMLUtil.findSubElements(cu)) {
if (javadocTo.getLocalName().equals("javadoc-built-to")) { // NOI18N
- String rawtext = Util.findText(javadocTo);
+ String rawtext = XMLUtil.findText(javadocTo);
assert rawtext != null;
String evaltext = eval.evaluate(rawtext);
if (evaltext != null) {
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/SourceForBinaryQueryImpl.java b/java.freeform/src/org/netbeans/modules/java/freeform/SourceForBinaryQueryImpl.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/SourceForBinaryQueryImpl.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/SourceForBinaryQueryImpl.java
@@ -50,7 +50,6 @@
import javax.swing.event.ChangeListener;
import org.netbeans.api.java.queries.SourceForBinaryQuery;
import org.netbeans.api.project.ProjectManager;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.support.ant.AntProjectEvent;
@@ -60,6 +59,7 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Mutex;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -100,7 +100,7 @@
if (java == null) {
return null;
}
- for (Element compilationUnit : Util.findSubElements(java)) {
+ for (Element compilationUnit : XMLUtil.findSubElements(java)) {
assert compilationUnit.getLocalName().equals("compilation-unit") : compilationUnit;
List binaries = findBinaries(compilationUnit);
if (!binaries.isEmpty()) {
@@ -137,11 +137,11 @@
*/
private List findBinaries(Element compilationUnitEl) {
List binaries = new ArrayList();
- for (Element builtToEl : Util.findSubElements(compilationUnitEl)) {
+ for (Element builtToEl : XMLUtil.findSubElements(compilationUnitEl)) {
if (!builtToEl.getLocalName().equals("built-to")) { // NOI18N
continue;
}
- String text = Util.findText(builtToEl);
+ String text = XMLUtil.findText(builtToEl);
String textEval = evaluator.evaluate(text);
if (textEval == null) {
continue;
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/SourceLevelQueryImpl.java b/java.freeform/src/org/netbeans/modules/java/freeform/SourceLevelQueryImpl.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/SourceLevelQueryImpl.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/SourceLevelQueryImpl.java
@@ -45,7 +45,6 @@
import java.util.Map;
import java.util.WeakHashMap;
import org.netbeans.api.project.ProjectManager;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
@@ -54,6 +53,7 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Mutex;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -102,7 +102,7 @@
if (java == null) {
return null;
}
- for (Element compilationUnitEl : Util.findSubElements(java)) {
+ for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
List packageRoots = Classpaths.findPackageRoots(helper, evaluator, compilationUnitEl);
for (FileObject root : packageRoots) {
@@ -133,9 +133,9 @@
* Get the source level indicated in a compilation unit (or null if none is indicated).
*/
private String getLevel(Element compilationUnitEl) {
- Element sourceLevelEl = Util.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
+ Element sourceLevelEl = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
if (sourceLevelEl != null) {
- return Util.findText(sourceLevelEl);
+ return XMLUtil.findText(sourceLevelEl);
} else {
return null;
}
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/TestQuery.java b/java.freeform/src/org/netbeans/modules/java/freeform/TestQuery.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/TestQuery.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/TestQuery.java
@@ -46,7 +46,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
@@ -54,6 +53,7 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileUtil;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -117,12 +117,12 @@
List tests = new ArrayList();
Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
if (data != null) {
- for (Element cu : Util.findSubElements(data)) {
+ for (Element cu : XMLUtil.findSubElements(data)) {
assert cu.getLocalName().equals("compilation-unit") : cu;
- boolean isTests = Util.findElement(cu, "unit-tests", JavaProjectNature.NS_JAVA_3) != null; // NOI18N
- for (Element pr : Util.findSubElements(cu)) {
+ boolean isTests = XMLUtil.findElement(cu, "unit-tests", JavaProjectNature.NS_JAVA_3) != null; // NOI18N
+ for (Element pr : XMLUtil.findSubElements(cu)) {
if (pr.getLocalName().equals("package-root")) { // NOI18N
- String rawtext = Util.findText(pr);
+ String rawtext = XMLUtil.findText(pr);
assert rawtext != null;
String evaltext = eval.evaluate(rawtext);
if (evaltext != null) {
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/UsageLogger.java b/java.freeform/src/org/netbeans/modules/java/freeform/UsageLogger.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/UsageLogger.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/UsageLogger.java
@@ -50,7 +50,6 @@
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.modules.ant.freeform.spi.ProjectAccessor;
import org.netbeans.modules.ant.freeform.spi.ProjectConstants;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
@@ -60,6 +59,7 @@
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
/**
@@ -108,18 +108,18 @@
Set classpathEntries = new HashSet();
Element java = JavaProjectGenerator.getJavaCompilationUnits(aux);
if (java != null) {
- for (Element compilationUnitEl : Util.findSubElements(java)) {
+ for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
compilationUnits++;
int builtTos = 0;
int roots = 0;
- for (Element other : Util.findSubElements(compilationUnitEl)) {
+ for (Element other : XMLUtil.findSubElements(compilationUnitEl)) {
String name = other.getLocalName();
if (name.equals("package-root")) { // NOI18N
roots++;
} else if (name.equals("built-to")) { // NOI18N
builtTos++;
} else if (name.equals("classpath")) { // NOI18N
- String text = Util.findText(other);
+ String text = XMLUtil.findText(other);
if (text != null) {
String textEval = eval.evaluate(text);
if (textEval != null) {
diff --git a/java.freeform/src/org/netbeans/modules/java/freeform/jdkselection/JdkConfiguration.java b/java.freeform/src/org/netbeans/modules/java/freeform/jdkselection/JdkConfiguration.java
--- a/java.freeform/src/org/netbeans/modules/java/freeform/jdkselection/JdkConfiguration.java
+++ b/java.freeform/src/org/netbeans/modules/java/freeform/jdkselection/JdkConfiguration.java
@@ -53,7 +53,6 @@
import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.modules.ant.freeform.spi.support.Util;
-import org.netbeans.modules.java.freeform.JavaProjectGenerator;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
@@ -163,17 +162,17 @@
Element projectE = nbjdkDoc.getDocumentElement();
Set targetsCreated = new HashSet();
// XXX remove any definition of ${ant.script}, which will by now be obsolete
- Element ideActionsE = Util.findElement(generalDataE, "ide-actions", Util.NAMESPACE);
+ Element ideActionsE = XMLUtil.findElement(generalDataE, "ide-actions", Util.NAMESPACE);
if (ideActionsE != null) {
- for (Element actionE : Util.findSubElements(ideActionsE)) {
+ for (Element actionE : XMLUtil.findSubElements(ideActionsE)) {
rebindAction(actionE, projectE, targetsCreated);
}
}
- Element viewE = Util.findElement(generalDataE, "ide-actions", Util.NAMESPACE);
+ Element viewE = XMLUtil.findElement(generalDataE, "ide-actions", Util.NAMESPACE);
if (viewE != null) {
- Element contextMenuE = Util.findElement(viewE, "context-menu", Util.NAMESPACE);
+ Element contextMenuE = XMLUtil.findElement(viewE, "context-menu", Util.NAMESPACE);
if (contextMenuE != null) {
- for (Element actionE : Util.findSubElements(contextMenuE)) {
+ for (Element actionE : XMLUtil.findSubElements(contextMenuE)) {
if (!actionE.getLocalName().equals("action")) {
continue; // ignore here
}
@@ -187,10 +186,10 @@
}
private void rebindAction(Element actionE, Element projectE, Set targetsCreated) {
- Element scriptE = Util.findElement(actionE, "script", Util.NAMESPACE); // NOI18N
+ Element scriptE = XMLUtil.findElement(actionE, "script", Util.NAMESPACE); // NOI18N
String script;
if (scriptE != null) {
- script = Util.findText(scriptE);
+ script = XMLUtil.findText(scriptE);
actionE.removeChild(scriptE);
} else {
script = "build.xml"; // NOI18N
@@ -199,11 +198,11 @@
scriptE.appendChild(actionE.getOwnerDocument().createTextNode(NBJDK_XML));
actionE.insertBefore(scriptE, actionE.getFirstChild());
List targetNames = new ArrayList();
- for (Element targetE : Util.findSubElements(actionE)) {
+ for (Element targetE : XMLUtil.findSubElements(actionE)) {
if (!targetE.getLocalName().equals("target")) { // NOI18N
continue;
}
- targetNames.add(Util.findText(targetE));
+ targetNames.add(XMLUtil.findText(targetE));
}
if (targetNames.isEmpty()) {
targetNames.add(null);
diff --git a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/ClasspathsTest.java b/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/ClasspathsTest.java
--- a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/ClasspathsTest.java
+++ b/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/ClasspathsTest.java
@@ -77,6 +77,7 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Mutex;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -456,7 +457,7 @@
FileUtil.createData(new File(d, "s/ignored/file"));
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element sf = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), Util.findElement(data, "view", Util.NAMESPACE)).
+ Element sf = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), XMLUtil.findElement(data, "view", Util.NAMESPACE)).
appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources"));
sf.appendChild(doc.createElementNS(Util.NAMESPACE, "type")).appendChild(doc.createTextNode(JavaProjectConstants.SOURCES_TYPE_JAVA));
@@ -547,7 +548,7 @@
data.getElementsByTagName("properties").item(0).
appendChild(doc.createElementNS(Util.NAMESPACE, "property-file")).
appendChild(doc.createTextNode("config.properties"));
- Element folders = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), Util.findElement(data, "view", Util.NAMESPACE));
+ Element folders = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), XMLUtil.findElement(data, "view", Util.NAMESPACE));
Element sf = (Element) folders.appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources #1"));
sf.appendChild(doc.createElementNS(Util.NAMESPACE, "type")).appendChild(doc.createTextNode(JavaProjectConstants.SOURCES_TYPE_JAVA));
diff --git a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaActionsTest.java b/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaActionsTest.java
--- a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaActionsTest.java
+++ b/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaActionsTest.java
@@ -51,7 +51,6 @@
import java.util.Locale;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.modules.ant.freeform.FreeformProject;
-import org.netbeans.modules.ant.freeform.FreeformProjectType;
import org.netbeans.modules.ant.freeform.TestBase;
import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.spi.project.ActionProvider;
@@ -88,13 +87,13 @@
prj = copyProject(simple);
// Remove existing context-sensitive bindings to make a clean slate.
Element data = prj.getPrimaryConfigurationData();
- Element ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
+ Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
assertNotNull(ideActions);
- Iterator actionsIt = Util.findSubElements(ideActions).iterator();
+ Iterator actionsIt = XMLUtil.findSubElements(ideActions).iterator();
while (actionsIt.hasNext()) {
Element action = actionsIt.next();
assertEquals("action", action.getLocalName());
- if (Util.findElement(action, "context", Util.NAMESPACE) != null) {
+ if (XMLUtil.findElement(action, "context", Util.NAMESPACE) != null) {
ideActions.removeChild(action);
}
}
@@ -209,9 +208,9 @@
ja.addBinding("some.action", "special.xml", "special-target", "selection", "${some.src.dir}", "\\.java$", "relative-path", ",");
Element data = prj.getPrimaryConfigurationData();
assertNotNull(data);
- Element ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
+ Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
assertNotNull(ideActions);
- List actions = Util.findSubElements(ideActions);
+ List actions = XMLUtil.findSubElements(ideActions);
Element lastAction = actions.get(actions.size() - 1);
String expectedXml =
"\n" +
@@ -231,8 +230,8 @@
assertEquals(expectedXml, xmlToString(lastAction));
ja.addBinding("some.other.action", "special.xml", "special-target", "selection", "${some.src.dir}", null, "relative-path", null);
data = prj.getPrimaryConfigurationData();
- ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
- actions = Util.findSubElements(ideActions);
+ ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
+ actions = XMLUtil.findSubElements(ideActions);
lastAction = actions.get(actions.size() - 1);
expectedXml =
"\n" +
@@ -252,8 +251,8 @@
// Non-context-sensitive bindings have no but need to add a view item.
ja.addBinding("general.action", "special.xml", "special-target", null, null, null, null, null);
data = prj.getPrimaryConfigurationData();
- ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
- actions = Util.findSubElements(ideActions);
+ ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
+ actions = XMLUtil.findSubElements(ideActions);
lastAction = actions.get(actions.size() - 1);
expectedXml =
"\n" +
@@ -262,12 +261,12 @@
" special-target\n" +
"\n";
assertEquals(expectedXml, xmlToString(lastAction));
- Element view = Util.findElement(data, "view", Util.NAMESPACE);
+ Element view = XMLUtil.findElement(data, "view", Util.NAMESPACE);
assertNotNull(view);
- Element contextMenu = Util.findElement(view, "context-menu", Util.NAMESPACE);
+ Element contextMenu = XMLUtil.findElement(view, "context-menu", Util.NAMESPACE);
assertNotNull(contextMenu);
// Currently (no FPG to help) it is always added as the last item.
- List contextMenuActions = Util.findSubElements(contextMenu);
+ List contextMenuActions = XMLUtil.findSubElements(contextMenu);
Element lastContextMenuAction = contextMenuActions.get(contextMenuActions.size() - 1);
expectedXml =
"\n" +
@@ -276,13 +275,13 @@
//test #58442:
data = prj.getPrimaryConfigurationData();
- ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
+ ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
data.removeChild(ideActions);
ja.addBinding("some.other.action", "special.xml", "special-target", "selection", "${some.src.dir}", null, "relative-path", null);
data = prj.getPrimaryConfigurationData();
- ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
- actions = Util.findSubElements(ideActions);
+ ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
+ actions = XMLUtil.findSubElements(ideActions);
lastAction = actions.get(actions.size() - 1);
expectedXml =
"\n" +
@@ -460,7 +459,7 @@
assertEquals("Correct code generated for external script", expectedXml, xmlToString(root));
// And also with locations defined as special properties in various ways...
Element data = prj.getPrimaryConfigurationData();
- Element properties = Util.findElement(data, "properties", Util.NAMESPACE);
+ Element properties = XMLUtil.findElement(data, "properties", Util.NAMESPACE);
assertNotNull(properties);
Element property = data.getOwnerDocument().createElementNS(Util.NAMESPACE, "property");
property.setAttribute("name", "external.xml");
diff --git a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaProjectGeneratorTest.java b/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaProjectGeneratorTest.java
--- a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaProjectGeneratorTest.java
+++ b/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaProjectGeneratorTest.java
@@ -77,6 +77,7 @@
import org.netbeans.spi.project.support.ant.PropertyUtils;
import org.openide.modules.ModuleInfo;
import org.openide.util.Lookup;
+import org.openide.xml.XMLUtil;
/**
* Tests for JavaProjectGenerator.
@@ -212,25 +213,25 @@
// check that all elements are written in expected order
Element el = Util.getPrimaryConfigurationData(helper);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
assertEquals(7, subElements.size());
assertElementArray(subElements,
new String[]{"name", "properties", "folders", "ide-actions", "export", "view", "subprojects"},
new String[]{null, null, null, null, null, null, null});
Element el2 = (Element)subElements.get(5);
- subElements = Util.findSubElements(el2);
+ subElements = XMLUtil.findSubElements(el2);
assertEquals(2, subElements.size());
assertElementArray(subElements,
new String[]{"items", "context-menu"},
new String[]{null, null});
Element el3 = (Element)subElements.get(0);
- List subEls = Util.findSubElements(el3);
+ List subEls = XMLUtil.findSubElements(el3);
assertEquals(2, subEls.size());
assertElementArray(subEls,
new String[]{"source-folder", "source-file"},
new String[]{null, null});
el3 = (Element)subElements.get(1);
- subEls = Util.findSubElements(el3);
+ subEls = XMLUtil.findSubElements(el3);
assertEquals(2, subEls.size());
assertElementArray(subEls,
new String[]{"ide-action", "action"},
@@ -259,25 +260,25 @@
FreeformProjectGenerator.putTargetMappings(helper, mappings);
// ProjectManager.getDefault().saveAllProjects();
el = Util.getPrimaryConfigurationData(helper);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(7, subElements.size());
assertElementArray(subElements,
new String[]{"name", "properties", "folders", "ide-actions", "export", "view", "subprojects"},
new String[]{null, null, null, null, null, null, null});
el2 = (Element)subElements.get(5);
- subElements = Util.findSubElements(el2);
+ subElements = XMLUtil.findSubElements(el2);
assertEquals(2, subElements.size());
assertElementArray(subElements,
new String[]{"items", "context-menu"},
new String[]{null, null});
el3 = (Element)subElements.get(0);
- subEls = Util.findSubElements(el3);
+ subEls = XMLUtil.findSubElements(el3);
assertEquals(2, subEls.size());
assertElementArray(subEls,
new String[]{"source-folder", "source-file"},
new String[]{null, null});
el3 = (Element)subElements.get(1);
- subEls = Util.findSubElements(el3);
+ subEls = XMLUtil.findSubElements(el3);
assertEquals(2, subEls.size());
assertElementArray(subEls,
new String[]{"ide-action", "action"},
@@ -296,7 +297,7 @@
String message = "Element "+element+" does not match [name="+expectedName+",value="+expectedValue+"]"; // NOI18N
assertEquals(message, expectedName, element.getLocalName());
if (expectedValue != null) {
- assertEquals(message, expectedValue, Util.findText(element));
+ assertEquals(message, expectedValue, XMLUtil.findText(element));
}
}
@@ -324,7 +325,7 @@
expectedValue+", attr="+expectedAttrName+", attrvalue="+expectedAttrValue+"]"; // NOI18N
assertEquals(message, expectedName, element.getLocalName());
if (expectedValue != null) {
- assertEquals(message, expectedValue, Util.findText(element));
+ assertEquals(message, expectedValue, XMLUtil.findText(element));
}
String val = element.getAttribute(expectedAttrName);
assertEquals(expectedAttrValue, val);
@@ -434,14 +435,14 @@
JavaProjectGenerator.putSourceFolders(helper, folders, null);
// ProjectManager.getDefault().saveAllProjects();
Element el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "folders", Util.NAMESPACE);
+ el = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
assertNotNull("Source folders were not saved correctly", el);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
assertEquals(2, subElements.size());
// compare first source folder
Element el2 = (Element)subElements.get(0);
assertElement(el2, "source-folder", null);
- List l1 = Util.findSubElements(el2);
+ List l1 = XMLUtil.findSubElements(el2);
assertEquals(3, l1.size());
assertElementArray(l1,
new String[]{"label", "type", "location"},
@@ -449,7 +450,7 @@
// compare second source folder
el2 = (Element)subElements.get(1);
assertElement(el2, "source-folder", null);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(3, l1.size());
assertElementArray(l1,
new String[]{"label", "type", "location"},
@@ -467,14 +468,14 @@
JavaProjectGenerator.putSourceFolders(helper, folders, "type2");
ProjectManager.getDefault().saveAllProjects();
el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "folders", Util.NAMESPACE);
+ el = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
assertNotNull("Source folders were not saved correctly", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(2, subElements.size());
// compare first source folder
el2 = (Element)subElements.get(0);
assertElement(el2, "source-folder", null);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(3, l1.size());
assertElementArray(l1,
new String[]{"label", "type", "location"},
@@ -482,7 +483,7 @@
// compare second source folder
el2 = (Element)subElements.get(1);
assertElement(el2, "source-folder", null);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(3, l1.size());
assertElementArray(l1,
new String[]{"label", "type", "location"},
@@ -582,17 +583,17 @@
JavaProjectGenerator.putSourceViews(helper, folders, null);
ProjectManager.getDefault().saveAllProjects();
Element el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "view", Util.NAMESPACE);
+ el = XMLUtil.findElement(el, "view", Util.NAMESPACE);
assertNotNull("View folders were not saved correctly", el);
- el = Util.findElement(el, "items", Util.NAMESPACE);
+ el = XMLUtil.findElement(el, "items", Util.NAMESPACE);
assertNotNull("View folders were not saved correctly", el);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
// there will be three sublements: is added for build.xml during project.creation
assertEquals(3, subElements.size());
// compare first source view
Element el2 = (Element)subElements.get(0);
assertElement(el2, "source-folder", null, "style", "tree");
- List l1 = Util.findSubElements(el2);
+ List l1 = XMLUtil.findSubElements(el2);
assertEquals(2, l1.size());
assertElementArray(l1,
new String[]{"label", "location"},
@@ -600,7 +601,7 @@
// compare second source view
el2 = (Element)subElements.get(1);
assertElement(el2, "source-folder", null, "style", "packages");
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(2, l1.size());
assertElementArray(l1,
new String[]{"label", "location"},
@@ -618,17 +619,17 @@
JavaProjectGenerator.putSourceViews(helper, folders, "packages");
ProjectManager.getDefault().saveAllProjects();
el = Util.getPrimaryConfigurationData(helper);
- el = Util.findElement(el, "view", Util.NAMESPACE);
+ el = XMLUtil.findElement(el, "view", Util.NAMESPACE);
assertNotNull("Source views were not saved correctly", el);
- el = Util.findElement(el, "items", Util.NAMESPACE);
+ el = XMLUtil.findElement(el, "items", Util.NAMESPACE);
assertNotNull("View folders were not saved correctly", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
// there will be three sublements: is added for build.xml during project.creation
assertEquals("3 elements in " + subElements, 3, subElements.size());
// compare first source view
el2 = (Element)subElements.get(0);
assertElement(el2, "source-folder", null, "style", "tree");
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(2, l1.size());
assertElementArray(l1,
new String[]{"label", "location"},
@@ -636,7 +637,7 @@
// compare second source view
el2 = (Element)subElements.get(1);
assertElement(el2, "source-folder", null, "style", "packages");
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(2, l1.size());
assertElementArray(l1,
new String[]{"label", "location"},
@@ -758,12 +759,12 @@
// ProjectManager.getDefault().saveAllProjects();
Element el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
assertNotNull("Java compilation units were not saved correctly", el);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
assertEquals(2, subElements.size());
// compare first compilation unit
Element el2 = (Element)subElements.get(0);
assertElement(el2, "compilation-unit", null);
- List l1 = Util.findSubElements(el2);
+ List l1 = XMLUtil.findSubElements(el2);
assertEquals(7, l1.size());
assertElementArray(l1,
new String[]{"package-root", "package-root", "classpath", "classpath", "built-to", "built-to", "source-level"},
@@ -775,7 +776,7 @@
// compare second compilation unit
el2 = (Element)subElements.get(1);
assertElement(el2, "compilation-unit", null);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(7, l1.size());
assertElementArray(l1,
new String[]{"package-root", "package-root", "classpath", "classpath", "built-to", "built-to", "source-level"},
@@ -797,12 +798,12 @@
// ProjectManager.getDefault().saveAllProjects();
el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
assertNotNull("Java compilation units were not saved correctly", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(1, subElements.size());
// compare first compilation unit
el2 = (Element)subElements.get(0);
assertElement(el2, "compilation-unit", null);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(1, l1.size());
assertElementArray(l1,
new String[]{"package-root"},
@@ -827,12 +828,12 @@
// Check that the correct /1 data was saved.
Element el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
assertNotNull("Java compilation units were saved in /1", el);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
assertEquals(1, subElements.size());
// compare the compilation unit
Element el2 = (Element) subElements.get(0);
assertElement(el2, "compilation-unit", null);
- assertElementArray(Util.findSubElements(el2),
+ assertElementArray(XMLUtil.findSubElements(el2),
new String[] {"package-root"},
new String[] {"pkgroot1"});
ProjectManager.getDefault().saveAllProjects();
@@ -849,12 +850,12 @@
assertNull("No /1 data", el);
el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
assertNotNull("Have /2 data", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(1, subElements.size());
// compare the compilation unit
el2 = (Element) subElements.get(0);
assertElement(el2, "compilation-unit", null);
- assertElementArray(Util.findSubElements(el2),
+ assertElementArray(XMLUtil.findSubElements(el2),
new String[] {"package-root", "unit-tests"},
new String[] {"pkgroot1", null});
ProjectManager.getDefault().saveAllProjects();
@@ -874,12 +875,12 @@
assertNull("No /1 data", el);
el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
assertNotNull("Have /2 data", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(1, subElements.size());
// compare the compilation unit
el2 = (Element) subElements.get(0);
assertElement(el2, "compilation-unit", null);
- assertElementArray(Util.findSubElements(el2),
+ assertElementArray(XMLUtil.findSubElements(el2),
new String[] {"package-root", "javadoc-built-to", "javadoc-built-to"},
new String[] {"pkgroot1", "javadoc1", "javadoc2"});
ProjectManager.getDefault().saveAllProjects();
@@ -1000,7 +1001,7 @@
JavaProjectGenerator.putExports(helper, exports);
Element el = Util.getPrimaryConfigurationData(helper);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
// 4, i.e. name, two exports and one view of build.xml file
assertEquals(5, subElements.size());
// compare first compilation unit
@@ -1010,7 +1011,7 @@
assertElement(el2, "properties", null);
el2 = (Element)subElements.get(2);
assertElement(el2, "export", null);
- List l1 = Util.findSubElements(el2);
+ List l1 = XMLUtil.findSubElements(el2);
assertEquals(5, l1.size());
assertElementArray(l1,
new String[]{"type", "location", "script", "build-target", "clean-target"},
@@ -1018,7 +1019,7 @@
// compare second compilation unit
el2 = (Element)subElements.get(3);
assertElement(el2, "export", null);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(3, l1.size());
assertElementArray(l1,
new String[]{"type", "location", "build-target"},
@@ -1038,7 +1039,7 @@
JavaProjectGenerator.putExports(helper, exports);
el = Util.getPrimaryConfigurationData(helper);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
// 3, i.e. name, export and one view of build.xml file
assertEquals(4, subElements.size());
// compare first compilation unit
@@ -1048,7 +1049,7 @@
assertElement(el2, "properties", null);
el2 = (Element)subElements.get(2);
assertElement(el2, "export", null);
- l1 = Util.findSubElements(el2);
+ l1 = XMLUtil.findSubElements(el2);
assertEquals(3, l1.size());
assertElementArray(l1,
new String[]{"type", "location", "build-target"},
@@ -1123,9 +1124,9 @@
JavaProjectGenerator.putSubprojects(helper, subprojects);
Element el = Util.getPrimaryConfigurationData(helper);
- Element subprojectsEl = Util.findElement(el, "subprojects", Util.NAMESPACE);
+ Element subprojectsEl = XMLUtil.findElement(el, "subprojects", Util.NAMESPACE);
assertNotNull(" element exists", subprojectsEl);
- List subElements = Util.findSubElements(subprojectsEl);
+ List subElements = XMLUtil.findSubElements(subprojectsEl);
assertEquals("project depends on two subprojects", 2, subElements.size());
Element el2 = (Element)subElements.get(0);
assertElement(el2, "project", "/some/path/projA");
@@ -1140,16 +1141,16 @@
subprojects.add("/projC");
JavaProjectGenerator.putSubprojects(helper, subprojects);
el = Util.getPrimaryConfigurationData(helper);
- subprojectsEl = Util.findElement(el, "subprojects", Util.NAMESPACE);
- subElements = Util.findSubElements(subprojectsEl);
+ subprojectsEl = XMLUtil.findElement(el, "subprojects", Util.NAMESPACE);
+ subElements = XMLUtil.findSubElements(subprojectsEl);
assertEquals("project depends on one subproject", 1, subElements.size());
el2 = (Element)subElements.get(0);
assertElement(el2, "project", "/projC");
subprojects = new ArrayList();
JavaProjectGenerator.putSubprojects(helper, subprojects);
el = Util.getPrimaryConfigurationData(helper);
- subprojectsEl = Util.findElement(el, "subprojects", Util.NAMESPACE);
- subElements = Util.findSubElements(subprojectsEl);
+ subprojectsEl = XMLUtil.findElement(el, "subprojects", Util.NAMESPACE);
+ subElements = XMLUtil.findSubElements(subprojectsEl);
assertEquals("project depends on one subproject", 0, subElements.size());
ProjectManager.getDefault().saveAllProjects();
@@ -1212,18 +1213,18 @@
JavaProjectGenerator.putBuildFolders(helper, buildFolders);
Element el = Util.getPrimaryConfigurationData(helper);
- Element foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
+ Element foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
assertNotNull(" element exists", foldersEl);
- List subElements = Util.findSubElements(foldersEl);
+ List subElements = XMLUtil.findSubElements(foldersEl);
assertEquals("project has two build-folders", 2, subElements.size());
Element el2 = (Element)subElements.get(0);
assertElement(el2, "build-folder", null);
- assertEquals("build-folder has one subelement", 1, Util.findSubElements(el2).size());
- assertElement((Element)Util.findSubElements(el2).get(0), "location", "/some/path/projA");
+ assertEquals("build-folder has one subelement", 1, XMLUtil.findSubElements(el2).size());
+ assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "/some/path/projA");
el2 = (Element)subElements.get(1);
assertElement(el2, "build-folder", null);
- assertEquals("build-folder has one subelement", 1, Util.findSubElements(el2).size());
- assertElement((Element)Util.findSubElements(el2).get(0), "location", "C:\\dev\\projB");
+ assertEquals("build-folder has one subelement", 1, XMLUtil.findSubElements(el2).size());
+ assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "C:\\dev\\projB");
ProjectManager.getDefault().saveAllProjects();
@@ -1233,18 +1234,18 @@
buildFolders.add("/projC");
JavaProjectGenerator.putBuildFolders(helper, buildFolders);
el = Util.getPrimaryConfigurationData(helper);
- foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
- subElements = Util.findSubElements(foldersEl);
+ foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
+ subElements = XMLUtil.findSubElements(foldersEl);
assertEquals("project has one build-folder", 1, subElements.size());
el2 = (Element)subElements.get(0);
assertElement(el2, "build-folder", null);
- assertEquals("build-folder has one subelement", 1, Util.findSubElements(el2).size());
- assertElement((Element)Util.findSubElements(el2).get(0), "location", "/projC");
+ assertEquals("build-folder has one subelement", 1, XMLUtil.findSubElements(el2).size());
+ assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "/projC");
buildFolders = new ArrayList();
JavaProjectGenerator.putBuildFolders(helper, buildFolders);
el = Util.getPrimaryConfigurationData(helper);
- foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
- subElements = Util.findSubElements(foldersEl);
+ foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
+ subElements = XMLUtil.findSubElements(foldersEl);
assertEquals("project has no build-folder", 0, subElements.size());
ProjectManager.getDefault().saveAllProjects();
@@ -1264,18 +1265,18 @@
JavaProjectGenerator.putBuildFiles(helper, buildFiles);
Element el = Util.getPrimaryConfigurationData(helper);
- Element foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
+ Element foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
assertNotNull(" element exists", foldersEl);
- List subElements = Util.findSubElements(foldersEl);
+ List subElements = XMLUtil.findSubElements(foldersEl);
assertEquals("project has two build-files", 2, subElements.size());
Element el2 = (Element)subElements.get(0);
assertElement(el2, "build-file", null);
- assertEquals("build-file has one subelement", 1, Util.findSubElements(el2).size());
- assertElement((Element)Util.findSubElements(el2).get(0), "location", "/some/path/projA/archive.jar");
+ assertEquals("build-file has one subelement", 1, XMLUtil.findSubElements(el2).size());
+ assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "/some/path/projA/archive.jar");
el2 = (Element)subElements.get(1);
assertElement(el2, "build-file", null);
- assertEquals("build-file has one subelement", 1, Util.findSubElements(el2).size());
- assertElement((Element)Util.findSubElements(el2).get(0), "location", "C:\\dev\\projB\\library.jar");
+ assertEquals("build-file has one subelement", 1, XMLUtil.findSubElements(el2).size());
+ assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "C:\\dev\\projB\\library.jar");
ProjectManager.getDefault().saveAllProjects();
@@ -1284,19 +1285,19 @@
buildFiles.add("/projC/dist/projC.jar");
JavaProjectGenerator.putBuildFiles(helper, buildFiles);
el = Util.getPrimaryConfigurationData(helper);
- foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
- subElements = Util.findSubElements(foldersEl);
+ foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
+ subElements = XMLUtil.findSubElements(foldersEl);
assertEquals("project has one build-file", 1, subElements.size());
el2 = (Element)subElements.get(0);
assertElement(el2, "build-file", null);
- assertEquals("build-file has one subelement", 1, Util.findSubElements(el2).size());
- assertElement((Element)Util.findSubElements(el2).get(0), "location", "/projC/dist/projC.jar");
+ assertEquals("build-file has one subelement", 1, XMLUtil.findSubElements(el2).size());
+ assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "/projC/dist/projC.jar");
buildFiles = new ArrayList();
JavaProjectGenerator.putBuildFiles(helper, buildFiles);
el = Util.getPrimaryConfigurationData(helper);
- foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
- subElements = Util.findSubElements(foldersEl);
+ foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
+ subElements = XMLUtil.findSubElements(foldersEl);
assertEquals("project has no build-file", 0, subElements.size());
ProjectManager.getDefault().saveAllProjects();
diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/UpdateProjectImpl.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/UpdateProjectImpl.java
--- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/UpdateProjectImpl.java
+++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/UpdateProjectImpl.java
@@ -53,13 +53,11 @@
import org.openide.NotifyDescriptor;
import org.openide.util.Mutex;
import org.openide.util.NbBundle;
-import org.w3c.dom.Comment;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
*
@@ -153,7 +151,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE);
Element sourceRoots = doc.createElementNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
Element root = doc.createElementNS (J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); //NOI18N
root.setAttribute ("id","src.dir"); //NOI18N
@@ -170,7 +168,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE);
cachedElement = newRoot;
}
}
@@ -204,39 +202,6 @@
}
}
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,newElement);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
private static void deleteMinAntVersion(final Element root) {
NodeList list = root.getElementsByTagNameNS (J2SEProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
if (list.getLength() == 1) {
diff --git a/java.source/test/unit/src/org/netbeans/modules/java/source/usages/TestSupport.java b/java.source/test/unit/src/org/netbeans/modules/java/source/usages/TestSupport.java
--- a/java.source/test/unit/src/org/netbeans/modules/java/source/usages/TestSupport.java
+++ b/java.source/test/unit/src/org/netbeans/modules/java/source/usages/TestSupport.java
@@ -190,7 +190,7 @@
assert false : "Shared not implemented";
}
Element root = xml.getDocumentElement ();
- Element data = findElement (root, elementName, namespace);
+ Element data = XMLUtil.findElement (root, elementName, namespace);
if (data != null) {
return (Element) data.cloneNode (true);
} else {
@@ -205,7 +205,7 @@
}
Element root = xml.getDocumentElement ();
- Element existing = findElement (root, fragment.getLocalName (), fragment.getNamespaceURI ());
+ Element existing = XMLUtil.findElement (root, fragment.getLocalName (), fragment.getNamespaceURI ());
// XXX first compare to existing and return if the same
if (existing != null) {
root.removeChild (existing);
@@ -236,7 +236,7 @@
}
Element root = xml.getDocumentElement ();
- Element data = findElement (root, elementName, namespace);
+ Element data = XMLUtil.findElement (root, elementName, namespace);
if (data != null) {
root.removeChild (data);
return true;
@@ -245,24 +245,4 @@
}
}
}
-
- // copied from org.netbeans.modules.project.ant.Util
- private static Element findElement(Element parent, String name, String namespace) {
- Element result = null;
- NodeList l = parent.getChildNodes();
- int len = l.getLength();
- for (int i = 0; i < len; i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element)l.item(i);
- if (name.equals(el.getLocalName()) && namespace.equals(el.getNamespaceURI())) {
- if (result == null) {
- result = el;
- } else {
- return null;
- }
- }
- }
- }
- return result;
- }
}
diff --git a/maven/src/org/netbeans/modules/maven/M2AuxilaryConfigImpl.java b/maven/src/org/netbeans/modules/maven/M2AuxilaryConfigImpl.java
--- a/maven/src/org/netbeans/modules/maven/M2AuxilaryConfigImpl.java
+++ b/maven/src/org/netbeans/modules/maven/M2AuxilaryConfigImpl.java
@@ -65,8 +65,6 @@
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -142,7 +140,7 @@
if (shared) {
//first check the document schedule for persistence
if (scheduledDocument != null) {
- Element el = findElement(scheduledDocument.getDocumentElement(), elementName, namespace);
+ Element el = XMLUtil.findElement(scheduledDocument.getDocumentElement(), elementName, namespace);
if (el != null) {
el = (Element) el.cloneNode(true);
}
@@ -159,7 +157,7 @@
//TODO shall be have some kind of caching here to prevent frequent IO?
doc = XMLUtil.parse(new InputSource(in), false, true, null, null);
cachedDoc = doc;
- return findElement(doc.getDocumentElement(), elementName, namespace);
+ return XMLUtil.findElement(doc.getDocumentElement(), elementName, namespace);
} catch (SAXException ex) {
ProblemReporterImpl impl = project.getProblemReporter();
if (!impl.hasReportWithId(BROKEN_NBCONFIG)) {
@@ -189,7 +187,7 @@
} else {
//reuse cached value if available;
if (cachedDoc != null) {
- return findElement(cachedDoc.getDocumentElement(), elementName, namespace);
+ return XMLUtil.findElement(cachedDoc.getDocumentElement(), elementName, namespace);
}
}
} else {
@@ -203,7 +201,7 @@
Document doc;
try {
doc = XMLUtil.parse(new InputSource(new StringReader(str)), false, true, null, null);
- return findElement(doc.getDocumentElement(), elementName, namespace);
+ return XMLUtil.findElement(doc.getDocumentElement(), elementName, namespace);
} catch (SAXException ex) {
ex.printStackTrace();
} catch (IOException ex) {
@@ -254,7 +252,7 @@
}
}
if (doc != null) {
- Element el = findElement(doc.getDocumentElement(), fragment.getNodeName(), fragment.getNamespaceURI());
+ Element el = XMLUtil.findElement(doc.getDocumentElement(), fragment.getNodeName(), fragment.getNamespaceURI());
if (el != null) {
doc.getDocumentElement().removeChild(el);
}
@@ -319,7 +317,7 @@
}
}
if (doc != null) {
- Element el = findElement(doc.getDocumentElement(), elementName, namespace);
+ Element el = XMLUtil.findElement(doc.getDocumentElement(), elementName, namespace);
if (el != null) {
doc.getDocumentElement().removeChild(el);
}
@@ -341,25 +339,6 @@
return true;
}
- private static Element findElement(Element parent, String name, String namespace) {
- Element result = null;
- NodeList l = parent.getChildNodes();
- int len = l.getLength();
- for (int i = 0; i < len; i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element) l.item(i);
- if (name.equals(el.getLocalName()) && ((namespace == el.getNamespaceURI()) /*check both namespaces are null*/ || (namespace != null && namespace.equals(el.getNamespaceURI())))) {
- if (result == null) {
- result = el;
- } else {
- return null;
- }
- }
- }
- }
- return result;
- }
-
static class OpenConfigAction extends AbstractAction {
private FileObject fo;
diff --git a/o.n.bluej/nbproject/project.xml b/o.n.bluej/nbproject/project.xml
--- a/o.n.bluej/nbproject/project.xml
+++ b/o.n.bluej/nbproject/project.xml
@@ -213,7 +213,7 @@
- 8.0
+ 8.3
diff --git a/o.n.bluej/src/org/netbeans/bluej/UpdateHelper.java b/o.n.bluej/src/org/netbeans/bluej/UpdateHelper.java
--- a/o.n.bluej/src/org/netbeans/bluej/UpdateHelper.java
+++ b/o.n.bluej/src/org/netbeans/bluej/UpdateHelper.java
@@ -61,6 +61,7 @@
import org.netbeans.spi.project.support.ant.AntProjectHelper;
import org.netbeans.spi.project.support.ant.EditableProperties;
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
+import org.openide.xml.XMLUtil;
/**
@@ -267,7 +268,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (BluejProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); // NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, BluejProjectType.PROJECT_CONFIGURATION_NAMESPACE);
Element sourceRoots = doc.createElementNS(BluejProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); // NOI18N
Element root = doc.createElementNS (BluejProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); // NOI18N
root.setAttribute ("id","src.dir"); // NOI18N
@@ -284,7 +285,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (BluejProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); // NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, BluejProjectType.PROJECT_CONFIGURATION_NAMESPACE);
cachedElement = updateMinAntVersion (newRoot, doc);
}
}
@@ -307,39 +308,6 @@
return cachedProperties;
}
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(BluejProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,newElement);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
static final String MINIMUM_ANT_VERSION = "1.6.5"; // NOI18N
private static Element updateMinAntVersion (final Element root, final Document doc) {
diff --git a/openide.loaders/src/org/openide/loaders/XMLDataObject.java b/openide.loaders/src/org/openide/loaders/XMLDataObject.java
--- a/openide.loaders/src/org/openide/loaders/XMLDataObject.java
+++ b/openide.loaders/src/org/openide/loaders/XMLDataObject.java
@@ -609,12 +609,7 @@
@Deprecated
public static Document parse (URL url, ErrorHandler eh, boolean validate) throws IOException, SAXException {
- DocumentBuilder builder = XMLDataObjectImpl.makeBuilder(validate);
- builder.setErrorHandler(eh);
- builder.setEntityResolver(getChainingEntityResolver());
-
- return builder.parse (new InputSource(url.toExternalForm()));
-
+ return XMLUtil.parse (new InputSource(url.toExternalForm()),validate, false, eh, getChainingEntityResolver());
}
/** Creates SAX parse that can be used to parse XML files.
diff --git a/profiler.nbmodule/src/org/netbeans/modules/profiler/nbmodule/NbModuleProjectTypeProfiler.java b/profiler.nbmodule/src/org/netbeans/modules/profiler/nbmodule/NbModuleProjectTypeProfiler.java
--- a/profiler.nbmodule/src/org/netbeans/modules/profiler/nbmodule/NbModuleProjectTypeProfiler.java
+++ b/profiler.nbmodule/src/org/netbeans/modules/profiler/nbmodule/NbModuleProjectTypeProfiler.java
@@ -60,8 +60,7 @@
import org.netbeans.lib.profiler.common.Profiler;
import org.netbeans.lib.profiler.common.integration.IntegrationUtils;
import org.netbeans.modules.profiler.projectsupport.utilities.SourceUtils;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+import org.openide.xml.XMLUtil;
/**
@@ -258,41 +257,12 @@
}
// Module is a NB module suite component, not a NB source module
- if (findElement(e, "suite-component", namespace) != null) return false; // NOI18N
+ if (XMLUtil.findElement(e, "suite-component", namespace) != null) return false; // NOI18N
// Module is a NB module suite component, not a NB source module
- if (findElement(e, "standalone", namespace) != null) return false; // NOI18N
+ if (XMLUtil.findElement(e, "standalone", namespace) != null) return false; // NOI18N
// Module is a NB source module (neither suite component nor standalone)
return true;
}
-
- // COPIED FROM org.netbeans.modules.project.ant:
- // (except for namespace == null support in findElement)
- // (and support for comments in findSubElements)
-
- /**
- * Search for an XML element in the direct children of a parent.
- * DOM provides a similar method but it does a recursive search
- * which we do not want. It also gives a node list and we want
- * only one result.
- * @param parent a parent element
- * @param name the intended local name
- * @param namespace the intended namespace (or null)
- * @return the first child element with that name, or null if none
- */
- private static Element findElement(Element parent, String name, String namespace) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element)l.item(i);
- if ((namespace == null && name.equals(el.getTagName())) ||
- (namespace != null && name.equals(el.getLocalName()) &&
- namespace.equals(el.getNamespaceURI()))) {
- return el;
- }
- }
- }
- return null;
- }
}
diff --git a/project.ant/nbproject/project.xml b/project.ant/nbproject/project.xml
--- a/project.ant/nbproject/project.xml
+++ b/project.ant/nbproject/project.xml
@@ -157,7 +157,7 @@
- 8.0
+ 8.3
diff --git a/project.ant/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingleton.java b/project.ant/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingleton.java
--- a/project.ant/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingleton.java
+++ b/project.ant/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingleton.java
@@ -190,9 +190,9 @@
try {
Document projectXml = loadProjectXml(projectDiskFile);
if (projectXml != null) {
- Element typeEl = Util.findElement(projectXml.getDocumentElement(), "type", PROJECT_NS); // NOI18N
+ Element typeEl = XMLUtil.findElement(projectXml.getDocumentElement(), "type", PROJECT_NS); // NOI18N
if (typeEl != null) {
- String type = Util.findText(typeEl);
+ String type = XMLUtil.findText(typeEl);
if (type != null) {
AntBasedProjectType provider = findAntBasedProjectType(type);
if (provider != null) {
@@ -236,12 +236,12 @@
LOG.log(Level.FINE, "could not load {0}", projectDiskFile);
return null;
}
- Element typeEl = Util.findElement(projectXml.getDocumentElement(), "type", PROJECT_NS); // NOI18N
+ Element typeEl = XMLUtil.findElement(projectXml.getDocumentElement(), "type", PROJECT_NS); // NOI18N
if (typeEl == null) {
LOG.log(Level.FINE, "no in {0}", projectDiskFile);
return null;
}
- String type = Util.findText(typeEl);
+ String type = XMLUtil.findText(typeEl);
if (type == null) {
LOG.log(Level.FINE, "no text in {0}", projectDiskFile);
return null;
diff --git a/project.ant/src/org/netbeans/modules/project/ant/ProjectLibraryProvider.java b/project.ant/src/org/netbeans/modules/project/ant/ProjectLibraryProvider.java
--- a/project.ant/src/org/netbeans/modules/project/ant/ProjectLibraryProvider.java
+++ b/project.ant/src/org/netbeans/modules/project/ant/ProjectLibraryProvider.java
@@ -436,9 +436,9 @@
public static String getLibrariesLocationText(AuxiliaryConfiguration aux) {
Element libraries = aux.getConfigurationFragment(EL_LIBRARIES, NAMESPACE, true);
if (libraries != null) {
- for (Element definitions : Util.findSubElements(libraries)) {
+ for (Element definitions : XMLUtil.findSubElements(libraries)) {
assert definitions.getLocalName().equals(EL_DEFINITIONS) : definitions;
- String text = Util.findText(definitions);
+ String text = XMLUtil.findText(definitions);
assert text != null : aux;
return text;
}
@@ -1012,7 +1012,7 @@
if (libraries == null) {
libraries = XMLUtil.createDocument("dummy", null, null, null).createElementNS(NAMESPACE, EL_LIBRARIES); // NOI18N
} else {
- List elements = Util.findSubElements(libraries);
+ List elements = XMLUtil.findSubElements(libraries);
if (elements.size() == 1) {
libraries.removeChild(elements.get(0));
}
diff --git a/project.ant/src/org/netbeans/modules/project/ant/ProjectXMLCatalogReader.java b/project.ant/src/org/netbeans/modules/project/ant/ProjectXMLCatalogReader.java
--- a/project.ant/src/org/netbeans/modules/project/ant/ProjectXMLCatalogReader.java
+++ b/project.ant/src/org/netbeans/modules/project/ant/ProjectXMLCatalogReader.java
@@ -68,7 +68,6 @@
import org.openide.util.NbCollections;
import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@@ -251,7 +250,7 @@
try {
String ns2 = ns.substring(0, slash + 1) + Integer.toString(Integer.parseInt(ns.substring(slash + 1)) + 1);
if (_resolveURI(ns2) != null) {
- Element data2 = translateXML(data, ns2);
+ Element data2 = XMLUtil.translateXML(data, ns2);
data.getParentNode().replaceChild(data2, data);
try {
validate(attempt);
@@ -315,26 +314,4 @@
return null;
}
- private static Element translateXML(Element from, String namespace) { // XXX use #136595
- Element to = from.getOwnerDocument().createElementNS(namespace, from.getLocalName());
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i = 0; i < length; i++) {
- Node node = nl.item(i);
- Node newNode;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- newNode = translateXML((Element) node, namespace);
- } else {
- newNode = node.cloneNode(true);
- }
- to.appendChild(newNode);
- }
- NamedNodeMap m = from.getAttributes();
- for (int i = 0; i < m.getLength(); i++) {
- Node attr = m.item(i);
- to.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- return to;
- }
-
}
diff --git a/project.ant/src/org/netbeans/modules/project/ant/Util.java b/project.ant/src/org/netbeans/modules/project/ant/Util.java
--- a/project.ant/src/org/netbeans/modules/project/ant/Util.java
+++ b/project.ant/src/org/netbeans/modules/project/ant/Util.java
@@ -41,15 +41,9 @@
package org.netbeans.modules.project.ant;
-import java.util.ArrayList;
-import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.util.Exceptions;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -63,83 +57,6 @@
private Util() {}
/**
- * Search for an XML element in the direct children of a parent.
- * DOM provides a similar method but it does a recursive search
- * which we do not want. It also gives a node list and we want
- * only one result.
- * @param parent a parent element
- * @param name the intended local name
- * @param namespace the intended namespace
- * @return the one child element with that name, or null if none or more than one
- */
- public static Element findElement(Element parent, String name, String namespace) {
- Element result = null;
- NodeList l = parent.getChildNodes();
- int len = l.getLength();
- for (int i = 0; i < len; i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element)l.item(i);
- if (namespace.equals(el.getNamespaceURI()) && name.equals(el.getLocalName())) {
- if (result == null) {
- result = el;
- } else {
- return null;
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Extract nested text from an element.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent element
- * @return the nested text, or null if none was found
- */
- public static String findText(Element parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- /**
- * Find all direct child elements of an element.
- * More useful than {@link Element#getElementsByTagNameNS} because it does
- * not recurse into recursive child elements.
- * Children which are all-whitespace text nodes are ignored; others cause
- * an exception to be thrown.
- * @param parent a parent element in a DOM tree
- * @return a list of direct child elements (may be empty)
- * @throws IllegalArgumentException if there are non-element children besides whitespace
- */
- public static List findSubElements(Element parent) throws IllegalArgumentException {
- NodeList l = parent.getChildNodes();
- List elements = new ArrayList(l.getLength());
- for (int i = 0; i < l.getLength(); i++) {
- Node n = l.item(i);
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- elements.add((Element)n);
- } else if (n.getNodeType() == Node.TEXT_NODE) {
- String text = ((Text)n).getNodeValue();
- if (text.trim().length() > 0) {
- throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
- }
- } else if (n.getNodeType() == Node.COMMENT_NODE) {
- // skip
- } else {
- throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
- }
- }
- return elements;
- }
-
- /**
* Create an XML error handler that rethrows errors and fatal errors and logs warnings.
* @return a standard error handler
*/
diff --git a/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java b/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java
--- a/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java
+++ b/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java
@@ -416,7 +416,7 @@
Document doc = getConfigurationXml(shared);
if (shared) {
Element project = doc.getDocumentElement();
- Element config = Util.findElement(project, "configuration", PROJECT_NS); // NOI18N
+ Element config = XMLUtil.findElement(project, "configuration", PROJECT_NS); // NOI18N
assert config != null;
return config;
} else {
@@ -888,7 +888,7 @@
public Element run() {
synchronized (modifiedMetadataPaths) {
Element root = getConfigurationDataRoot(shared);
- Element data = Util.findElement(root, elementName, namespace);
+ Element data = XMLUtil.findElement(root, elementName, namespace);
if (data != null) {
return cloneSafely(data);
} else {
@@ -926,7 +926,7 @@
public Void run() {
synchronized (modifiedMetadataPaths) {
Element root = getConfigurationDataRoot(shared);
- Element existing = Util.findElement(root, fragment.getLocalName(), fragment.getNamespaceURI());
+ Element existing = XMLUtil.findElement(root, fragment.getLocalName(), fragment.getNamespaceURI());
// XXX first compare to existing and return if the same
if (existing != null) {
root.removeChild(existing);
@@ -968,7 +968,7 @@
public Boolean run() {
synchronized (modifiedMetadataPaths) {
Element root = getConfigurationDataRoot(shared);
- Element data = Util.findElement(root, elementName, namespace);
+ Element data = XMLUtil.findElement(root, elementName, namespace);
if (data != null) {
root.removeChild(data);
modifying(shared ? PROJECT_XML_PATH : PRIVATE_XML_PATH);
diff --git a/project.ant/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java b/project.ant/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java
--- a/project.ant/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java
+++ b/project.ant/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java
@@ -70,7 +70,6 @@
import org.netbeans.api.queries.CollocationQuery;
import org.netbeans.modules.project.ant.AntBasedProjectFactorySingleton;
import org.netbeans.modules.project.ant.ProjectLibraryProvider;
-import org.netbeans.modules.project.ant.Util;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.SubprojectProvider;
import org.openide.ErrorManager;
@@ -569,7 +568,7 @@
// Linear search; always keeping references sorted first by foreign project
// name, then by target name.
Element nextRefEl = null;
- Iterator it = Util.findSubElements(references).iterator();
+ Iterator it = XMLUtil.findSubElements(references).iterator();
while (it.hasNext()) {
Element testRefEl = it.next();
RawReference testRef = RawReference.create(testRefEl);
@@ -816,7 +815,7 @@
private static boolean removeRawReferenceElement(String foreignProjectName, String id, Element references, boolean escaped) throws IllegalArgumentException {
// As with addRawReference, do a linear search through.
- for (Element testRefEl : Util.findSubElements(references)) {
+ for (Element testRefEl : XMLUtil.findSubElements(references)) {
RawReference testRef = RawReference.create(testRefEl);
String refID = testRef.getID();
String refName = testRef.getForeignProjectName();
@@ -869,7 +868,7 @@
}
private static RawReference[] getRawReferences(Element references) throws IllegalArgumentException {
- List subEls = Util.findSubElements(references);
+ List subEls = XMLUtil.findSubElements(references);
List refs = new ArrayList(subEls.size());
for (Element subEl : subEls) {
refs.add(RawReference.create(subEl));
@@ -911,7 +910,7 @@
}
private static RawReference getRawReference(String foreignProjectName, String id, Element references, boolean escaped) throws IllegalArgumentException {
- for (Element subEl : Util.findSubElements(references)) {
+ for (Element subEl : XMLUtil.findSubElements(references)) {
RawReference ref = RawReference.create(subEl);
String refID = ref.getID();
String refName = ref.getForeignProjectName();
@@ -1693,7 +1692,7 @@
if (idx == -1) {
throw new IllegalArgumentException("bad subelement name: " + elName); // NOI18N
}
- String val = Util.findText(el);
+ String val = XMLUtil.findText(el);
if (val == null) {
throw new IllegalArgumentException("empty subelement: " + el); // NOI18N
}
@@ -1711,7 +1710,7 @@
if (!REF_NAME.equals(xml.getLocalName()) || !REFS_NS2.equals(xml.getNamespaceURI())) {
throw new IllegalArgumentException("bad element name: " + xml); // NOI18N
}
- List nl = Util.findSubElements(xml);
+ List nl = XMLUtil.findSubElements(xml);
if (nl.size() < 6) {
throw new IllegalArgumentException("missing or extra data: " + xml); // NOI18N
}
@@ -1726,7 +1725,7 @@
if (idx == -1) {
throw new IllegalArgumentException("bad subelement name: " + elName); // NOI18N
}
- String val = Util.findText(el);
+ String val = XMLUtil.findText(el);
if (val == null) {
throw new IllegalArgumentException("empty subelement: " + el); // NOI18N
}
@@ -1744,9 +1743,9 @@
if (!"properties".equals(el.getLocalName())) { // NOI18N
throw new IllegalArgumentException("bad subelement. expected 'properties': " + el); // NOI18N
}
- for (Element el2 : Util.findSubElements(el)) {
+ for (Element el2 : XMLUtil.findSubElements(el)) {
String key = el2.getAttribute("name");
- String value = Util.findText(el2);
+ String value = XMLUtil.findText(el2);
// #53553: NPE
if (value == null) {
value = ""; // NOI18N
diff --git a/project.ant/test/unit/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingletonTest.java b/project.ant/test/unit/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingletonTest.java
--- a/project.ant/test/unit/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingletonTest.java
+++ b/project.ant/test/unit/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingletonTest.java
@@ -58,6 +58,7 @@
import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups;
import org.openide.util.test.MockLookup;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
public class AntBasedProjectFactorySingletonTest extends NbTestCase {
@@ -238,7 +239,7 @@
}
private static String namesOfChildren(Element e) {
StringBuilder b = new StringBuilder();
- for (Element kid : Util.findSubElements(e)) {
+ for (Element kid : XMLUtil.findSubElements(e)) {
if (b.length() > 0) {
b.append(' ');
}
diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java
--- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java
+++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java
@@ -225,9 +225,9 @@
private String getText(String elementName) {
Element data = helper.getPrimaryConfigurationData(true);
- Element el = Util.findElement(data, elementName, "urn:test:shared");
+ Element el = XMLUtil.findElement(data, elementName, "urn:test:shared");
if (el != null) {
- String text = Util.findText(el);
+ String text = XMLUtil.findText(el);
if (text != null) {
return text;
}
diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntProjectHelperTest.java b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntProjectHelperTest.java
--- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntProjectHelperTest.java
+++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntProjectHelperTest.java
@@ -54,7 +54,6 @@
import org.netbeans.junit.NbTestCase;
import org.netbeans.junit.RandomlyFails;
import org.netbeans.modules.project.ant.ProjectLibraryProvider;
-import org.netbeans.modules.project.ant.Util;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.CacheDirectoryProvider;
import org.openide.filesystems.FileObject;
@@ -156,12 +155,12 @@
Element data = h.getPrimaryConfigurationData(true);
assertEquals("correct element name", "data", data.getLocalName());
assertEquals("correct element namespace", "urn:test:shared", data.getNamespaceURI());
- Element stuff = Util.findElement(data, "shared-stuff", "urn:test:shared");
+ Element stuff = XMLUtil.findElement(data, "shared-stuff", "urn:test:shared");
assertNotNull("had nested stuff in it", stuff);
data = h.getPrimaryConfigurationData(false);
assertEquals("correct element name", "data", data.getLocalName());
assertEquals("correct element namespace", "urn:test:private", data.getNamespaceURI());
- stuff = Util.findElement(data, "private-stuff", "urn:test:private");
+ stuff = XMLUtil.findElement(data, "private-stuff", "urn:test:private");
assertNotNull("had nested stuff in it", stuff);
}
@@ -181,7 +180,7 @@
}
assertEquals("correct element name", "data", data.getLocalName());
assertEquals("correct element namespace", "urn:test:shared", data.getNamespaceURI());
- Element stuff = Util.findElement(data, "shared-stuff", "urn:test:shared");
+ Element stuff = XMLUtil.findElement(data, "shared-stuff", "urn:test:shared");
/* This now retains the former contents:
assertNull("had no stuff in it", stuff);
*/
@@ -192,13 +191,13 @@
pm.saveProject(p);
Document doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PROJECT_XML_PATH);
Element root = doc.getDocumentElement();
- Element type = Util.findElement(root, "type", AntProjectHelper.PROJECT_NS);
- assertEquals("correct restored type", "test", Util.findText(type));
- Element config = Util.findElement(root, "configuration", AntProjectHelper.PROJECT_NS);
+ Element type = XMLUtil.findElement(root, "type", AntProjectHelper.PROJECT_NS);
+ assertEquals("correct restored type", "test", XMLUtil.findText(type));
+ Element config = XMLUtil.findElement(root, "configuration", AntProjectHelper.PROJECT_NS);
assertNotNull("have ", config);
- data = Util.findElement(config, "data", "urn:test:shared");
+ data = XMLUtil.findElement(config, "data", "urn:test:shared");
assertNotNull("have ", data);
- Element details = Util.findElement(data, "details", "urn:test:shared");
+ Element details = XMLUtil.findElement(data, "details", "urn:test:shared");
assertNotNull("have ", details);
}
@@ -463,7 +462,7 @@
public void testPutPrimaryConfigurationData() throws Exception {
h.addAntProjectListener(l);
Element data = h.getPrimaryConfigurationData(true);
- assertNotNull(" is there to start", Util.findElement(data, "shared-stuff", "urn:test:shared"));
+ assertNotNull(" is there to start", XMLUtil.findElement(data, "shared-stuff", "urn:test:shared"));
assertTrue("project is not initially modified", !pm.isModified(p));
assertEquals("gPCD fires no events", 0, l.events().length);
assertNotNull("config data has an owner document", data.getOwnerDocument());
@@ -471,7 +470,7 @@
data.appendChild(nue);
assertTrue("project is not modified after uncommitted change", !pm.isModified(p));
assertEquals("no events fired after uncommitted change", 0, l.events().length);
- assertEquals("after uncommitted change gPCD does not yet have new ", null, Util.findElement(h.getPrimaryConfigurationData(true), "misc", "urn:test:shared"));
+ assertEquals("after uncommitted change gPCD does not yet have new ", null, XMLUtil.findElement(h.getPrimaryConfigurationData(true), "misc", "urn:test:shared"));
h.putPrimaryConfigurationData(data, true);
assertTrue("project is modified after committed change", pm.isModified(p));
AntProjectEvent[] evs = l.events();
@@ -479,28 +478,28 @@
assertEquals("correct helper", h, evs[0].getHelper());
assertEquals("correct path", AntProjectHelper.PROJECT_XML_PATH, evs[0].getPath());
assertTrue("expected change", evs[0].isExpected());
- nue = Util.findElement(h.getPrimaryConfigurationData(true), "misc", "urn:test:shared");
+ nue = XMLUtil.findElement(h.getPrimaryConfigurationData(true), "misc", "urn:test:shared");
assertNotNull("after committed change gPCD has new ", nue);
assertEquals("new element name is correct", "misc", nue.getLocalName());
assertEquals("new element namespace is correct", "urn:test:shared", nue.getNamespaceURI());
Document doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PROJECT_XML_PATH);
- Element configuration = Util.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
+ Element configuration = XMLUtil.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
assertNotNull("still has on disk", configuration);
- data = Util.findElement(configuration, "data", "urn:test:shared");
+ data = XMLUtil.findElement(configuration, "data", "urn:test:shared");
assertNotNull("still has on disk", data);
- nue = Util.findElement(data, "misc", "urn:test:shared");
+ nue = XMLUtil.findElement(data, "misc", "urn:test:shared");
assertEquals(" not yet on disk", null, nue);
pm.saveProject(p);
assertTrue("project is not modified after save", !pm.isModified(p));
assertEquals("saving changes fires no new events", 0, l.events().length);
- nue = Util.findElement(h.getPrimaryConfigurationData(true), "misc", "urn:test:shared");
+ nue = XMLUtil.findElement(h.getPrimaryConfigurationData(true), "misc", "urn:test:shared");
assertNotNull("after save gPCD still has new ", nue);
doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PROJECT_XML_PATH);
- configuration = Util.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
+ configuration = XMLUtil.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
assertNotNull("still has on disk", configuration);
- data = Util.findElement(configuration, "data", "urn:test:shared");
+ data = XMLUtil.findElement(configuration, "data", "urn:test:shared");
assertNotNull("still has on disk", data);
- nue = Util.findElement(data, "misc", "urn:test:shared");
+ nue = XMLUtil.findElement(data, "misc", "urn:test:shared");
assertNotNull(" now on disk", nue);
// #42147: changes made on disk should result in firing of an AntProjectEvent
ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction() {
@@ -516,12 +515,12 @@
assertFalse("unexpected change", evs[0].isExpected());
assertEquals("correct new display name", "Some New Name", ProjectUtils.getInformation(p).getDisplayName());
data = h.getPrimaryConfigurationData(true);
- Element stuff = Util.findElement(data, "other-shared-stuff", "urn:test:shared");
+ Element stuff = XMLUtil.findElement(data, "other-shared-stuff", "urn:test:shared");
assertNotNull("have now", stuff);
AuxiliaryConfiguration aux = p.getLookup().lookup(AuxiliaryConfiguration.class);
data = aux.getConfigurationFragment("data", "urn:test:shared-aux", true);
assertNotNull("have aux ", data);
- stuff = Util.findElement(data, "other-aux-shared-stuff", "urn:test:shared-aux");
+ stuff = XMLUtil.findElement(data, "other-aux-shared-stuff", "urn:test:shared-aux");
assertNotNull("have now", stuff);
// XXX try private.xml too
// XXX try modifying both XML files, or different parts of the same, and saving in a batch
@@ -551,7 +550,7 @@
assertNotNull("found shared ", data);
assertEquals("correct name", "data", data.getLocalName());
assertEquals("correct namespace", "urn:test:shared-aux", data.getNamespaceURI());
- Element stuff = Util.findElement(data, "aux-shared-stuff", "urn:test:shared-aux");
+ Element stuff = XMLUtil.findElement(data, "aux-shared-stuff", "urn:test:shared-aux");
assertNotNull("found ", stuff);
assertEquals("gCF fires no changes", 0, l.events().length);
// Check write of shared data.
@@ -567,11 +566,11 @@
pm.saveProject(p);
assertEquals("saving project fires no new changes", 0, l.events().length);
Document doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PROJECT_XML_PATH);
- Element config = Util.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
+ Element config = XMLUtil.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
assertNotNull(" still exists", config);
- data = Util.findElement(config, "data", "urn:test:shared-aux");
+ data = XMLUtil.findElement(config, "data", "urn:test:shared-aux");
assertNotNull(" still exists", data);
- stuff = Util.findElement(data, "aux-shared-stuff", "urn:test:shared-aux");
+ stuff = XMLUtil.findElement(data, "aux-shared-stuff", "urn:test:shared-aux");
assertNotNull("still have ", stuff);
assertEquals("attr written correctly", "val", stuff.getAttribute("attr"));
// Check read of private data.
@@ -579,7 +578,7 @@
assertNotNull("found shared ", data);
assertEquals("correct name", "data", data.getLocalName());
assertEquals("correct namespace", "urn:test:private-aux", data.getNamespaceURI());
- stuff = Util.findElement(data, "aux-private-stuff", "urn:test:private-aux");
+ stuff = XMLUtil.findElement(data, "aux-private-stuff", "urn:test:private-aux");
assertNotNull("found ", stuff);
assertEquals("gCF fires no changes", 0, l.events().length);
// Check write of private data.
@@ -596,9 +595,9 @@
assertEquals("saving project fires no new changes", 0, l.events().length);
doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PRIVATE_XML_PATH);
config = doc.getDocumentElement();
- data = Util.findElement(config, "data", "urn:test:private-aux");
+ data = XMLUtil.findElement(config, "data", "urn:test:private-aux");
assertNotNull(" still exists", data);
- stuff = Util.findElement(data, "aux-private-stuff", "urn:test:private-aux");
+ stuff = XMLUtil.findElement(data, "aux-private-stuff", "urn:test:private-aux");
assertNotNull("still have ", stuff);
assertEquals("attr written correctly", "val", stuff.getAttribute("attr"));
// Check that missing fragments are not returned.
@@ -625,11 +624,11 @@
data = aux.getConfigurationFragment("hello", "urn:test:whatever", true);
assertNotNull("can retrieve new frag", data);
doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PROJECT_XML_PATH);
- config = Util.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
+ config = XMLUtil.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
assertNotNull(" still exists", config);
- data = Util.findElement(config, "hello", "urn:test:whatever");
+ data = XMLUtil.findElement(config, "hello", "urn:test:whatever");
assertNotNull(" still exists", data);
- assertEquals("correct nested contents too", "stuff", Util.findText(data));
+ assertEquals("correct nested contents too", "stuff", XMLUtil.findText(data));
// Try removing a fragment.
assertFalse("project is unmodified", pm.isModified(p));
assertTrue("can remove new frag", aux.removeConfigurationFragment("hello", "urn:test:whatever", true));
@@ -637,9 +636,9 @@
assertNull("now frag is gone", aux.getConfigurationFragment("hello", "urn:test:whatever", true));
pm.saveProject(p);
doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PROJECT_XML_PATH);
- config = Util.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
+ config = XMLUtil.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
assertNotNull(" still exists", config);
- data = Util.findElement(config, "hello", "urn:test:whatever");
+ data = XMLUtil.findElement(config, "hello", "urn:test:whatever");
assertNull("now is gone", data);
assertFalse("cannot remove a frag that is not there", aux.removeConfigurationFragment("hello", "urn:test:whatever", true));
assertFalse("trying to remove a nonexistent frag does not modify project", pm.isModified(p));
@@ -659,7 +658,7 @@
aux.putConfigurationFragment(data, true);
pm.saveProject(p);
doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PROJECT_XML_PATH);
- config = Util.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
+ config = XMLUtil.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
String[] names = new String[]{"aaa-namespace", "aaaa-namespace", "bbb-name-sp", "bbb-namespace", "bbb-namespace-1", "ccc-namespace", "data-urn:test:shared", "data-urn:test:shared-aux"};
int count = 0;
NodeList list = config.getChildNodes();
@@ -684,7 +683,7 @@
assertNotNull("AuxiliaryConfiguration present", aux);
Element data = aux.getConfigurationFragment("data", "urn:test:private-aux", false);
- Element stuff = Util.findElement(data, "aux-private-stuff", "urn:test:private-aux");
+ Element stuff = XMLUtil.findElement(data, "aux-private-stuff", "urn:test:private-aux");
assertNotNull("found ", stuff);
// Check write of private data.
stuff.setAttribute("attr", "val");
@@ -710,9 +709,9 @@
//check the data are written:
Document doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PRIVATE_XML_PATH);
Element config = doc.getDocumentElement();
- data = Util.findElement(config, "data", "urn:test:private-aux");
+ data = XMLUtil.findElement(config, "data", "urn:test:private-aux");
assertNotNull(" still exists", data);
- stuff = Util.findElement(data, "aux-private-stuff", "urn:test:private-aux");
+ stuff = XMLUtil.findElement(data, "aux-private-stuff", "urn:test:private-aux");
assertNotNull("still have ", stuff);
assertEquals("attr written correctly", "val", stuff.getAttribute("attr"));
@@ -788,7 +787,7 @@
System.out.println("starting #" + x);
for (int i = 0; i < 1000; i++) {
Element data = h.getPrimaryConfigurationData(true);
- Util.findSubElements(data);
+ XMLUtil.findSubElements(data);
if (i % 100 == 0) {
System.out.println("in the middle of #" + x);
try {
diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/GeneratedFilesHelperTest.java b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/GeneratedFilesHelperTest.java
--- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/GeneratedFilesHelperTest.java
+++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/GeneratedFilesHelperTest.java
@@ -52,13 +52,13 @@
import org.netbeans.api.project.TestUtil;
import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.project.ant.AntBuildExtenderAccessor;
-import org.netbeans.modules.project.ant.Util;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.modules.SpecificationVersion;
import org.openide.util.Utilities;
import org.openide.util.test.MockLookup;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -111,7 +111,7 @@
assertNull("No build-impl.xml yet", bi);
// Modify shared data in a project.
Element primdata = h.getPrimaryConfigurationData(true);
- Element oldDisplayName = Util.findElement(primdata, "display-name", "urn:test:shared");
+ Element oldDisplayName = XMLUtil.findElement(primdata, "display-name", "urn:test:shared");
assertNotNull("had a before", oldDisplayName);
Element displayName = primdata.getOwnerDocument().createElementNS("urn:test:shared", "display-name");
displayName.appendChild(primdata.getOwnerDocument().createTextNode("New Name"));
@@ -132,7 +132,7 @@
NodeList l = doc.getElementsByTagName("description");
assertEquals("one in build-impl.xml", 1, l.getLength());
el = (Element)l.item(0);
- assertEquals("correct description", "New Name", Util.findText(el));
+ assertEquals("correct description", "New Name", XMLUtil.findText(el));
// Clear build-impl.xml to test if it is rewritten.
bi.delete();
// Now make some irrelevant change - e.g. to private.xml - and check that there is no modification.
diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ProjectGeneratorTest.java b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ProjectGeneratorTest.java
--- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ProjectGeneratorTest.java
+++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ProjectGeneratorTest.java
@@ -49,13 +49,13 @@
import org.netbeans.api.project.TestUtil;
import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.project.ant.AntBasedProjectFactorySingleton;
-import org.netbeans.modules.project.ant.Util;
import org.netbeans.api.project.ProjectInformation;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Mutex;
import org.openide.util.MutexException;
import org.openide.util.test.MockLookup;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -142,7 +142,7 @@
NodeList l = doc.getElementsByTagNameNS(AntProjectHelper.PROJECT_NS, "type");
assertEquals("one ", 1, l.getLength());
Element el = (Element)l.item(0);
- assertEquals("correct saved type", "test", Util.findText(el));
+ assertEquals("correct saved type", "test", XMLUtil.findText(el));
l = doc.getElementsByTagNameNS("urn:test:shared", "shared-stuff");
assertEquals("one ", 1, l.getLength());
doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PRIVATE_XML_PATH);
diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ReferenceHelperTest.java b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ReferenceHelperTest.java
--- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ReferenceHelperTest.java
+++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/ReferenceHelperTest.java
@@ -63,7 +63,6 @@
import org.netbeans.api.queries.CollocationQuery;
import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.project.ant.ProjectLibraryProvider;
-import org.netbeans.modules.project.ant.Util;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.SubprojectProvider;
import org.netbeans.spi.queries.CollocationQueryImplementation;
@@ -71,6 +70,7 @@
import org.openide.filesystems.FileUtil;
import org.openide.util.lookup.Lookups;
import org.openide.util.test.MockLookup;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -342,9 +342,9 @@
assertTrue("Project is still modified", pm.isModified(p));
pm.saveProject(p);
Document doc = AntBasedTestUtil.slurpXml(h, AntProjectHelper.PROJECT_XML_PATH);
- Element config = Util.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
+ Element config = XMLUtil.findElement(doc.getDocumentElement(), "configuration", AntProjectHelper.PROJECT_NS);
assertNotNull("have ", config);
- Element references = Util.findElement(config, ReferenceHelper.REFS_NAME, ReferenceHelper.REFS_NS);
+ Element references = XMLUtil.findElement(config, ReferenceHelper.REFS_NAME, ReferenceHelper.REFS_NS);
assertNotNull("have ", references);
NodeList nl = references.getElementsByTagNameNS(ReferenceHelper.REFS_NS, "reference");
assertEquals("have three s", 3, nl.getLength());
@@ -386,9 +386,9 @@
Element reference = (Element)nl.item(i);
for (int j = 0; j < 6; j++) {
String elementName = elementNames[j];
- Element element = Util.findElement(reference, elementName, ReferenceHelper.REFS_NS);
+ Element element = XMLUtil.findElement(reference, elementName, ReferenceHelper.REFS_NS);
assertNotNull("had element " + elementName + " in ref #" + i, element);
- assertEquals("correct text in " + elementName + " in ref #" + i, values[i][j], Util.findText(element));
+ assertEquals("correct text in " + elementName + " in ref #" + i, values[i][j], XMLUtil.findText(element));
}
}
}
@@ -1080,9 +1080,9 @@
Element refs = p.getLookup().lookup(AuxiliaryConfiguration.class).getConfigurationFragment(ReferenceHelper.REFS_NAME, namespace, true);
assertNotNull(refs);
List actualScriptLocations = new ArrayList();
- for (Element ref : Util.findSubElements(refs)) {
- Element script = Util.findElement(ref, "script", namespace);
- actualScriptLocations.add(Util.findText(script));
+ for (Element ref : XMLUtil.findSubElements(refs)) {
+ Element script = XMLUtil.findElement(ref, "script", namespace);
+ actualScriptLocations.add(XMLUtil.findText(script));
}
assertEquals(Arrays.asList(scriptLocations), actualScriptLocations);
}
diff --git a/projectapi/nbproject/project.xml b/projectapi/nbproject/project.xml
--- a/projectapi/nbproject/project.xml
+++ b/projectapi/nbproject/project.xml
@@ -92,7 +92,7 @@
- 8.0
+ 8.3
diff --git a/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigImpl.java b/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigImpl.java
--- a/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigImpl.java
+++ b/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigImpl.java
@@ -98,7 +98,7 @@
InputSource input = new InputSource(is);
input.setSystemId(config.getURL().toString());
Element root = XMLUtil.parse(input, false, true, /*XXX*/null, null).getDocumentElement();
- return findElement(root, elementName, namespace);
+ return XMLUtil.findElement(root, elementName, namespace);
} finally {
is.close();
}
@@ -163,7 +163,7 @@
doc = XMLUtil.createDocument("auxiliary-configuration", "http://www.netbeans.org/ns/auxiliary-configuration/1", null, null);
}
Element root = doc.getDocumentElement();
- Element oldFragment = findElement(root, elementName, namespace);
+ Element oldFragment = XMLUtil.findElement(root, elementName, namespace);
if (oldFragment != null) {
root.removeChild(oldFragment);
}
@@ -230,7 +230,7 @@
is.close();
}
Element root = doc.getDocumentElement();
- Element toRemove = findElement(root, elementName, namespace);
+ Element toRemove = XMLUtil.findElement(root, elementName, namespace);
if (toRemove != null) {
root.removeChild(toRemove);
if (root.getElementsByTagName("*").getLength() > 0) {
@@ -276,23 +276,4 @@
});
}
- private static Element findElement(Element parent, String name, String namespace) {
- Element result = null;
- NodeList l = parent.getChildNodes();
- int len = l.getLength();
- for (int i = 0; i < len; i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element) l.item(i);
- if (name.equals(el.getLocalName()) && namespace.equals(el.getNamespaceURI())) {
- if (result == null) {
- result = el;
- } else {
- return null;
- }
- }
- }
- }
- return result;
- }
-
}
diff --git a/projectimport.eclipse.core/nbproject/project.xml b/projectimport.eclipse.core/nbproject/project.xml
--- a/projectimport.eclipse.core/nbproject/project.xml
+++ b/projectimport.eclipse.core/nbproject/project.xml
@@ -192,7 +192,7 @@
- 8.0
+ 8.3
diff --git a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/DotClassPathParser.java b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/DotClassPathParser.java
--- a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/DotClassPathParser.java
+++ b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/DotClassPathParser.java
@@ -77,7 +77,7 @@
if (!"classpath".equals(classpathEl.getLocalName())) { // NOI18N
return empty();
}
- List classpathEntryEls = Util.findSubElements(classpathEl);
+ List classpathEntryEls = XMLUtil.findSubElements(classpathEl);
if (classpathEntryEls == null) {
return empty();
}
@@ -113,7 +113,7 @@
}
props.put(key, value);
}
- Element entryAttrs = Util.findElement(classpathEntry, "attributes", null); //NOI18N
+ Element entryAttrs = XMLUtil.findElement(classpathEntry, "attributes", null); //NOI18N
if (entryAttrs != null) {
/*
@@ -122,7 +122,7 @@
*/
- List attrsList = Util.findSubElements(entryAttrs);
+ List attrsList = XMLUtil.findSubElements(entryAttrs);
if (attrsList != null) {
for (Element e : attrsList) {
props.put(e.getAttribute("name"), e.getAttribute("value")); //NOI18N
diff --git a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/ProjectParser.java b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/ProjectParser.java
--- a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/ProjectParser.java
+++ b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/ProjectParser.java
@@ -75,9 +75,9 @@
throw new IllegalStateException("given file is not eclipse .project file"); // NOI18N
}
- Element naturesEl = Util.findElement(projectDescriptionEl, "natures", null); // NOI18N
+ Element naturesEl = XMLUtil.findElement(projectDescriptionEl, "natures", null); // NOI18N
if (naturesEl != null) {
- List natureEls = Util.findSubElements(naturesEl);
+ List natureEls = XMLUtil.findSubElements(naturesEl);
if (natureEls != null) {
for (Element nature : natureEls) {
natures.add(nature.getTextContent());
@@ -85,30 +85,30 @@
}
}
- Element linksEl = Util.findElement(projectDescriptionEl, "linkedResources", null); // NOI18N
+ Element linksEl = XMLUtil.findElement(projectDescriptionEl, "linkedResources", null); // NOI18N
if (linksEl != null) {
- List linkEls = Util.findSubElements(linksEl);
+ List linkEls = XMLUtil.findSubElements(linksEl);
if (linkEls != null) {
for (Element link : linkEls) {
- Element locationElement = Util.findElement(link, "location", null); // NOI18N
+ Element locationElement = XMLUtil.findElement(link, "location", null); // NOI18N
String loc;
if (locationElement == null) {
- assert Util.findElement(link, "locationURI", null) != null : Util.findSubElements(link); // NOI18N
+ assert XMLUtil.findElement(link, "locationURI", null) != null : XMLUtil.findSubElements(link); // NOI18N
// XXX external source root can be defined using IDE variable. For some reason (in Eclipse)
// these variables are stored/managed separately from variables which can be used
// in classpath. For now these variables are not transfer to NetBeans and normalized
// path will be returned instead.
- loc = resolveLink(Util.findElement(link, "locationURI", null).getTextContent(), variables); // NOI18N
+ loc = resolveLink(XMLUtil.findElement(link, "locationURI", null).getTextContent(), variables); // NOI18N
} else {
loc = locationElement.getTextContent();
}
- links.add(new Link(Util.findElement(link, "name", null).getTextContent(), // NOI18N
- "1".equals(Util.findElement(link, "type", null).getTextContent()), // NOI18N
+ links.add(new Link(XMLUtil.findElement(link, "name", null).getTextContent(), // NOI18N
+ "1".equals(XMLUtil.findElement(link, "type", null).getTextContent()), // NOI18N
loc));
}
}
}
- return Util.findElement(projectDescriptionEl, "name", null).getTextContent(); //NOI18N
+ return XMLUtil.findElement(projectDescriptionEl, "name", null).getTextContent(); //NOI18N
}
public static Facets readProjectFacets(File projectDir, Set natures) throws IOException {
@@ -132,7 +132,7 @@
}
List facets = new ArrayList();
- List elements = Util.findSubElements(root);
+ List elements = XMLUtil.findSubElements(root);
for (Element element : elements) {
if (!"installed".equals(element.getNodeName())) { // NOI18N
continue;
diff --git a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/UserLibraryParser.java b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/UserLibraryParser.java
--- a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/UserLibraryParser.java
+++ b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/UserLibraryParser.java
@@ -73,7 +73,7 @@
if (!"userlibrary".equals(root.getLocalName())) { //NOI18N
return false;
}
- for (Element el : Util.findSubElements(root)) {
+ for (Element el : XMLUtil.findSubElements(root)) {
if (!el.getNodeName().equals("archive")) { //NOI18N
continue;
}
@@ -82,11 +82,11 @@
if (src.length() > 0) {
sources.add(src);
}
- Element el2 = Util.findElement(el, "attributes", null); //NOI18N
+ Element el2 = XMLUtil.findElement(el, "attributes", null); //NOI18N
if (el2 == null) {
continue;
}
- for (Element el3 : Util.findSubElements(el2)) {
+ for (Element el3 : XMLUtil.findSubElements(el2)) {
if (el3.getNodeName().equals("attribute") && "javadoc_location".equals(el3.getAttribute("name"))) { //NOI18N
String javadoc = el3.getAttribute("value"); //NOI18N
if (javadoc != null) {
diff --git a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/Util.java b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/Util.java
--- a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/Util.java
+++ b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/Util.java
@@ -41,18 +41,12 @@
package org.netbeans.modules.projectimport.eclipse.core;
-import java.util.ArrayList;
-import java.util.List;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.openide.util.Parameters;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -68,84 +62,6 @@
private Util() {}
/**
- * Search for an XML element in the direct children of a parent.
- * DOM provides a similar method but it does a recursive search
- * which we do not want. It also gives a node list and we want
- * only one result.
- * @param parent a parent element
- * @param name the intended local name
- * @param namespace the intended namespace
- * @return the one child element with that name, or null if none or more than one
- */
- public static Element findElement(Element parent, String name, String namespace) {
- Element result = null;
- NodeList l = parent.getChildNodes();
- int len = l.getLength();
- for (int i = 0; i < len; i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element)l.item(i);
- if (name.equals(el.getLocalName()) &&
- ((namespace != null && namespace.equals(el.getNamespaceURI())) || namespace == null)) {
- if (result == null) {
- result = el;
- } else {
- return null;
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Extract nested text from an element.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent element
- * @return the nested text, or null if none was found
- */
- public static String findText(Element parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- /**
- * Find all direct child elements of an element.
- * More useful than {@link Element#getElementsByTagNameNS} because it does
- * not recurse into recursive child elements.
- * Children which are all-whitespace text nodes are ignored; others cause
- * an exception to be thrown.
- * @param parent a parent element in a DOM tree
- * @return a list of direct child elements (may be empty)
- * @throws IllegalArgumentException if there are non-element children besides whitespace
- */
- public static List findSubElements(Element parent) throws IllegalArgumentException {
- NodeList l = parent.getChildNodes();
- List elements = new ArrayList(l.getLength());
- for (int i = 0; i < l.getLength(); i++) {
- Node n = l.item(i);
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- elements.add((Element)n);
- } else if (n.getNodeType() == Node.TEXT_NODE) {
- String text = ((Text)n).getNodeValue();
- if (text.trim().length() > 0) {
- throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
- }
- } else if (n.getNodeType() == Node.COMMENT_NODE) {
- // skip
- } else {
- throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
- }
- }
- return elements;
- }
-
- /**
* Create an XML error handler that rethrows errors and fatal errors and logs warnings.
* @return a standard error handler
*/
diff --git a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/WorkspaceParser.java b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/WorkspaceParser.java
--- a/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/WorkspaceParser.java
+++ b/projectimport.eclipse.core/src/org/netbeans/modules/projectimport/eclipse/core/WorkspaceParser.java
@@ -156,10 +156,10 @@
!JSF_LIB_NS.equals(root.getNamespaceURI())) {
return;
}
- for (Element el : Util.findSubElements(root)) {
+ for (Element el : XMLUtil.findSubElements(root)) {
String libraryName = el.getAttribute("Name"); // NOI18N
List jars = new ArrayList();
- for (Element file : Util.findSubElements(el)) {
+ for (Element file : XMLUtil.findSubElements(el)) {
String path = file.getAttribute("SourceLocation"); // NOI18N
if (!"false".equals(file.getAttribute("RelativeToWorkspace"))) { // NOI18N
path = new File(workspace.getDirectory(), path).getPath();
diff --git a/projectimport.eclipse.web/src/org/netbeans/modules/projectimport/eclipse/web/Util.java b/projectimport.eclipse.web/src/org/netbeans/modules/projectimport/eclipse/web/Util.java
--- a/projectimport.eclipse.web/src/org/netbeans/modules/projectimport/eclipse/web/Util.java
+++ b/projectimport.eclipse.web/src/org/netbeans/modules/projectimport/eclipse/web/Util.java
@@ -41,15 +41,9 @@
package org.netbeans.modules.projectimport.eclipse.web;
-import java.util.ArrayList;
-import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.util.Exceptions;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -63,84 +57,6 @@
private Util() {}
/**
- * Search for an XML element in the direct children of a parent.
- * DOM provides a similar method but it does a recursive search
- * which we do not want. It also gives a node list and we want
- * only one result.
- * @param parent a parent element
- * @param name the intended local name
- * @param namespace the intended namespace
- * @return the one child element with that name, or null if none or more than one
- */
- public static Element findElement(Element parent, String name, String namespace) {
- Element result = null;
- NodeList l = parent.getChildNodes();
- int len = l.getLength();
- for (int i = 0; i < len; i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element)l.item(i);
- if (name.equals(el.getLocalName()) &&
- ((namespace != null && namespace.equals(el.getNamespaceURI())) || namespace == null)) {
- if (result == null) {
- result = el;
- } else {
- return null;
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Extract nested text from an element.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent element
- * @return the nested text, or null if none was found
- */
- public static String findText(Element parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- /**
- * Find all direct child elements of an element.
- * More useful than {@link Element#getElementsByTagNameNS} because it does
- * not recurse into recursive child elements.
- * Children which are all-whitespace text nodes are ignored; others cause
- * an exception to be thrown.
- * @param parent a parent element in a DOM tree
- * @return a list of direct child elements (may be empty)
- * @throws IllegalArgumentException if there are non-element children besides whitespace
- */
- public static List findSubElements(Element parent) throws IllegalArgumentException {
- NodeList l = parent.getChildNodes();
- List elements = new ArrayList(l.getLength());
- for (int i = 0; i < l.getLength(); i++) {
- Node n = l.item(i);
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- elements.add((Element)n);
- } else if (n.getNodeType() == Node.TEXT_NODE) {
- String text = ((Text)n).getNodeValue();
- if (text.trim().length() > 0) {
- throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
- }
- } else if (n.getNodeType() == Node.COMMENT_NODE) {
- // skip
- } else {
- throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
- }
- }
- return elements;
- }
-
- /**
* Create an XML error handler that rethrows errors and fatal errors and logs warnings.
* @return a standard error handler
*/
diff --git a/projectimport.eclipse.web/src/org/netbeans/modules/projectimport/eclipse/web/WebProjectFactory.java b/projectimport.eclipse.web/src/org/netbeans/modules/projectimport/eclipse/web/WebProjectFactory.java
--- a/projectimport.eclipse.web/src/org/netbeans/modules/projectimport/eclipse/web/WebProjectFactory.java
+++ b/projectimport.eclipse.web/src/org/netbeans/modules/projectimport/eclipse/web/WebProjectFactory.java
@@ -245,9 +245,9 @@
return null;
}
WebContentData data = new WebContentData();
- Element moduleEl = Util.findElement(modulesEl, "wb-module", null); //NOI18N
+ Element moduleEl = XMLUtil.findElement(modulesEl, "wb-module", null); //NOI18N
if (moduleEl != null) { // #175364
- for (Element el : Util.findSubElements(moduleEl)) {
+ for (Element el : XMLUtil.findSubElements(moduleEl)) {
if ("wb-resource".equals(el.getNodeName())) { //NOI18N
if ("/".equals(el.getAttribute("deploy-path"))) { //NOI18N
data.webRoot = el.getAttribute("source-path"); //NOI18N
@@ -281,9 +281,9 @@
if ("5.0".equals(specVer)) {
specVer = "1.5"; // NOI18N
}
- Element attrsEl = Util.findElement(modulesEl, "attributes", null); //NOI18N
+ Element attrsEl = XMLUtil.findElement(modulesEl, "attributes", null); //NOI18N
if (attrsEl != null) {
- for (Element el : Util.findSubElements(attrsEl)) {
+ for (Element el : XMLUtil.findSubElements(attrsEl)) {
if ("attribute".equals(el.getNodeName())) { //NOI18N
if ("webrootdir".equals(el.getAttribute("name"))) { //NOI18N
data.webRoot = el.getAttribute("value"); //NOI18N
diff --git a/projectimport.jbuilder/src/org/netbeans/modules/projectimport/jbuilder/parsing/UserLibrarySupport.java b/projectimport.jbuilder/src/org/netbeans/modules/projectimport/jbuilder/parsing/UserLibrarySupport.java
--- a/projectimport.jbuilder/src/org/netbeans/modules/projectimport/jbuilder/parsing/UserLibrarySupport.java
+++ b/projectimport.jbuilder/src/org/netbeans/modules/projectimport/jbuilder/parsing/UserLibrarySupport.java
@@ -195,7 +195,7 @@
return null;
}
- List/**/ reqElems = Util.findSubElements(docEl);
+ List reqElems = XMLUtil.findSubElements(docEl);
for (int i = 0; i < reqElems.size(); i++) {
Element elem = (Element)reqElems.get(i);
String classElem = getClassElement(elem);
@@ -235,7 +235,7 @@
}
private void resolvePath(final File[] folders, final AbstractProject.UserLibrary retval, final Element classElem) throws IllegalArgumentException {
- List/**/ pathElems = (classElem != null) ? Util.findSubElements(classElem) : Collections.EMPTY_LIST;
+ List pathElems = (classElem != null) ? XMLUtil.findSubElements(classElem) : Collections.EMPTY_LIST;
for (int i = 0; i < pathElems.size(); i++) {
String path = getPath((Element)pathElems.get(i));
if (path != null) {
@@ -277,8 +277,9 @@
String fullName = null;
if (docEl != null) {
- Element fullNameElement = Util.findElement(docEl, FULLNAME_ELEMENT,null);
- fullName = (fullNameElement != null) ? Util.findText(fullNameElement) : null;
+ try {XMLUtil.write(docEl.getOwnerDocument(), System.out, "UTC-8"); } catch (Exception e) {}
+ Element fullNameElement = XMLUtil.findElement(docEl, FULLNAME_ELEMENT,null);
+ fullName = (fullNameElement != null) ? XMLUtil.findText(fullNameElement) : null;
}
return fullName;
@@ -302,7 +303,7 @@
String path = null;
if (pathElem != null && pathElem.getNodeName().equals(name)) {
- path = Util.findText(pathElem);
+ path = XMLUtil.findText(pathElem);
}
diff --git a/projectui/nbproject/project.xml b/projectui/nbproject/project.xml
--- a/projectui/nbproject/project.xml
+++ b/projectui/nbproject/project.xml
@@ -185,7 +185,7 @@
- 8.0
+ 8.3
diff --git a/projectui/test/unit/src/org/netbeans/modules/project/ui/actions/TestSupport.java b/projectui/test/unit/src/org/netbeans/modules/project/ui/actions/TestSupport.java
--- a/projectui/test/unit/src/org/netbeans/modules/project/ui/actions/TestSupport.java
+++ b/projectui/test/unit/src/org/netbeans/modules/project/ui/actions/TestSupport.java
@@ -190,7 +190,7 @@
assert false : "Shared not implemented";
}
Element root = xml.getDocumentElement ();
- Element data = findElement (root, elementName, namespace);
+ Element data = XMLUtil.findElement (root, elementName, namespace);
if (data != null) {
return (Element) data.cloneNode (true);
} else {
@@ -205,7 +205,7 @@
}
Element root = xml.getDocumentElement ();
- Element existing = findElement (root, fragment.getLocalName (), fragment.getNamespaceURI ());
+ Element existing = XMLUtil.findElement (root, fragment.getLocalName (), fragment.getNamespaceURI ());
// XXX first compare to existing and return if the same
if (existing != null) {
root.removeChild (existing);
@@ -236,7 +236,7 @@
}
Element root = xml.getDocumentElement ();
- Element data = findElement (root, elementName, namespace);
+ Element data = XMLUtil.findElement (root, elementName, namespace);
if (data != null) {
root.removeChild (data);
return true;
@@ -245,24 +245,4 @@
}
}
}
-
- // copied from org.netbeans.modules.project.ant.Util
- private static Element findElement(Element parent, String name, String namespace) {
- Element result = null;
- NodeList l = parent.getChildNodes();
- int len = l.getLength();
- for (int i = 0; i < len; i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element)l.item(i);
- if (name.equals(el.getLocalName()) && namespace.equals(el.getNamespaceURI())) {
- if (result == null) {
- result = el;
- } else {
- return null;
- }
- }
- }
- }
- return result;
- }
}
diff --git a/ruby.project/src/org/netbeans/modules/ruby/rubyproject/UpdateHelper.java b/ruby.project/src/org/netbeans/modules/ruby/rubyproject/UpdateHelper.java
--- a/ruby.project/src/org/netbeans/modules/ruby/rubyproject/UpdateHelper.java
+++ b/ruby.project/src/org/netbeans/modules/ruby/rubyproject/UpdateHelper.java
@@ -43,13 +43,7 @@
import java.io.IOException;
import javax.swing.JButton;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
import org.openide.DialogDisplayer;
import org.openide.ErrorManager;
import org.openide.NotifyDescriptor;
@@ -307,39 +301,6 @@
EditableProperties cachedProperties = this.helper.getProperties(RakeProjectHelper.PROJECT_PROPERTIES_PATH);
return cachedProperties;
}
-
- private static void copyDocument(Document doc, Element from, Element to, String projectConfigurationNamespace) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(projectConfigurationNamespace, oldElement.getTagName());
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc, oldElement, newElement, projectConfigurationNamespace);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
// private static Element updateMinAntVersion (final Element root, final Document doc) {
// NodeList list = root.getElementsByTagNameNS (RubyProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
diff --git a/ruby.rakeproject/src/org/netbeans/modules/ruby/modules/project/rake/RakeBasedProjectFactorySingleton.java b/ruby.rakeproject/src/org/netbeans/modules/ruby/modules/project/rake/RakeBasedProjectFactorySingleton.java
--- a/ruby.rakeproject/src/org/netbeans/modules/ruby/modules/project/rake/RakeBasedProjectFactorySingleton.java
+++ b/ruby.rakeproject/src/org/netbeans/modules/ruby/modules/project/rake/RakeBasedProjectFactorySingleton.java
@@ -178,11 +178,11 @@
if (!"project".equals(projectEl.getLocalName()) || !PROJECT_NS.equals(projectEl.getNamespaceURI())) { // NOI18N
return null;
}
- Element typeEl = Util.findElement(projectEl, "type", PROJECT_NS); // NOI18N
+ Element typeEl = XMLUtil.findElement(projectEl, "type", PROJECT_NS); // NOI18N
if (typeEl == null) {
return null;
}
- String type = Util.findText(typeEl);
+ String type = XMLUtil.findText(typeEl);
if (type == null) {
return null;
}
diff --git a/ruby.rakeproject/src/org/netbeans/modules/ruby/modules/project/rake/Util.java b/ruby.rakeproject/src/org/netbeans/modules/ruby/modules/project/rake/Util.java
--- a/ruby.rakeproject/src/org/netbeans/modules/ruby/modules/project/rake/Util.java
+++ b/ruby.rakeproject/src/org/netbeans/modules/ruby/modules/project/rake/Util.java
@@ -41,13 +41,7 @@
package org.netbeans.modules.ruby.modules.project.rake;
-import java.util.ArrayList;
-import java.util.List;
import org.openide.ErrorManager;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -61,83 +55,6 @@
private Util() {}
/**
- * Search for an XML element in the direct children of a parent.
- * DOM provides a similar method but it does a recursive search
- * which we do not want. It also gives a node list and we want
- * only one result.
- * @param parent a parent element
- * @param name the intended local name
- * @param namespace the intended namespace
- * @return the one child element with that name, or null if none or more than one
- */
- public static Element findElement(Element parent, String name, String namespace) {
- Element result = null;
- NodeList l = parent.getChildNodes();
- int len = l.getLength();
- for (int i = 0; i < len; i++) {
- if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
- Element el = (Element)l.item(i);
- if (name.equals(el.getLocalName()) && namespace.equals(el.getNamespaceURI())) {
- if (result == null) {
- result = el;
- } else {
- return null;
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Extract nested text from an element.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent element
- * @return the nested text, or null if none was found
- */
- public static String findText(Element parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- /**
- * Find all direct child elements of an element.
- * More useful than {@link Element#getElementsByTagNameNS} because it does
- * not recurse into recursive child elements.
- * Children which are all-whitespace text nodes are ignored; others cause
- * an exception to be thrown.
- * @param parent a parent element in a DOM tree
- * @return a list of direct child elements (may be empty)
- * @throws IllegalArgumentException if there are non-element children besides whitespace
- */
- public static List findSubElements(Element parent) throws IllegalArgumentException {
- NodeList l = parent.getChildNodes();
- List elements = new ArrayList(l.getLength());
- for (int i = 0; i < l.getLength(); i++) {
- Node n = l.item(i);
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- elements.add((Element)n);
- } else if (n.getNodeType() == Node.TEXT_NODE) {
- String text = ((Text)n).getNodeValue();
- if (text.trim().length() > 0) {
- throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
- }
- } else if (n.getNodeType() == Node.COMMENT_NODE) {
- // skip
- } else {
- throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
- }
- }
- return elements;
- }
-
- /**
* Create an XML error handler that rethrows errors and fatal errors and logs warnings.
* @return a standard error handler
*/
diff --git a/ruby.rakeproject/src/org/netbeans/modules/ruby/spi/project/support/rake/RakeProjectHelper.java b/ruby.rakeproject/src/org/netbeans/modules/ruby/spi/project/support/rake/RakeProjectHelper.java
--- a/ruby.rakeproject/src/org/netbeans/modules/ruby/spi/project/support/rake/RakeProjectHelper.java
+++ b/ruby.rakeproject/src/org/netbeans/modules/ruby/spi/project/support/rake/RakeProjectHelper.java
@@ -389,7 +389,7 @@
Document doc = getConfigurationXml(shared);
if (shared) {
Element project = doc.getDocumentElement();
- Element config = Util.findElement(project, "configuration", PROJECT_NS); // NOI18N
+ Element config = XMLUtil.findElement(project, "configuration", PROJECT_NS); // NOI18N
assert config != null;
return config;
} else {
@@ -828,7 +828,7 @@
public Element run() {
synchronized (modifiedMetadataPaths) {
Element root = getConfigurationDataRoot(shared);
- Element data = Util.findElement(root, elementName, namespace);
+ Element data = XMLUtil.findElement(root, elementName, namespace);
if (data != null) {
return cloneSafely(data);
} else {
@@ -866,7 +866,7 @@
public Void run() {
synchronized (modifiedMetadataPaths) {
Element root = getConfigurationDataRoot(shared);
- Element existing = Util.findElement(root, fragment.getLocalName(), fragment.getNamespaceURI());
+ Element existing = XMLUtil.findElement(root, fragment.getLocalName(), fragment.getNamespaceURI());
// XXX first compare to existing and return if the same
if (existing != null) {
root.removeChild(existing);
@@ -908,7 +908,7 @@
public Boolean run() {
synchronized (modifiedMetadataPaths) {
Element root = getConfigurationDataRoot(shared);
- Element data = Util.findElement(root, elementName, namespace);
+ Element data = XMLUtil.findElement(root, elementName, namespace);
if (data != null) {
root.removeChild(data);
modifying(shared ? PROJECT_XML_PATH : PRIVATE_XML_PATH);
diff --git a/ruby.rakeproject/src/org/netbeans/modules/ruby/spi/project/support/rake/ReferenceHelper.java b/ruby.rakeproject/src/org/netbeans/modules/ruby/spi/project/support/rake/ReferenceHelper.java
--- a/ruby.rakeproject/src/org/netbeans/modules/ruby/spi/project/support/rake/ReferenceHelper.java
+++ b/ruby.rakeproject/src/org/netbeans/modules/ruby/spi/project/support/rake/ReferenceHelper.java
@@ -66,7 +66,6 @@
import org.netbeans.modules.ruby.api.project.rake.RakeArtifactQuery;
import org.netbeans.api.queries.CollocationQuery;
import org.netbeans.modules.ruby.modules.project.rake.RakeBasedProjectFactorySingleton;
-import org.netbeans.modules.ruby.modules.project.rake.Util;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.SubprojectProvider;
import org.openide.ErrorManager;
@@ -546,7 +545,7 @@
// Linear search; always keeping references sorted first by foreign project
// name, then by target name.
Element nextRefEl = null;
- Iterator it = Util.findSubElements(references).iterator();
+ Iterator it = XMLUtil.findSubElements(references).iterator();
while (it.hasNext()) {
Element testRefEl = it.next();
RawReference testRef = RawReference.create(testRefEl);
@@ -793,7 +792,7 @@
private static boolean removeRawReferenceElement(String foreignProjectName, String id, Element references, boolean escaped) throws IllegalArgumentException {
// As with addRawReference, do a linear search through.
- for (Element testRefEl : Util.findSubElements(references)) {
+ for (Element testRefEl : XMLUtil.findSubElements(references)) {
RawReference testRef = RawReference.create(testRefEl);
String refID = testRef.getID();
String refName = testRef.getForeignProjectName();
@@ -846,7 +845,7 @@
}
private static RawReference[] getRawReferences(Element references) throws IllegalArgumentException {
- List subEls = Util.findSubElements(references);
+ List subEls = XMLUtil.findSubElements(references);
List refs = new ArrayList(subEls.size());
for (Element subEl : subEls) {
refs.add(RawReference.create(subEl));
@@ -888,7 +887,7 @@
}
private static RawReference getRawReference(String foreignProjectName, String id, Element references, boolean escaped) throws IllegalArgumentException {
- for (Element subEl : Util.findSubElements(references)) {
+ for (Element subEl : XMLUtil.findSubElements(references)) {
RawReference ref = RawReference.create(subEl);
String refID = ref.getID();
String refName = ref.getForeignProjectName();
@@ -1513,7 +1512,7 @@
if (idx == -1) {
throw new IllegalArgumentException("bad subelement name: " + elName); // NOI18N
}
- String val = Util.findText(el);
+ String val = XMLUtil.findText(el);
if (val == null) {
throw new IllegalArgumentException("empty subelement: " + el); // NOI18N
}
@@ -1531,7 +1530,7 @@
if (!REF_NAME.equals(xml.getLocalName()) || !REFS_NS2.equals(xml.getNamespaceURI())) {
throw new IllegalArgumentException("bad element name: " + xml); // NOI18N
}
- List nl = Util.findSubElements(xml);
+ List nl = XMLUtil.findSubElements(xml);
if (nl.size() < 6) {
throw new IllegalArgumentException("missing or extra data: " + xml); // NOI18N
}
@@ -1546,7 +1545,7 @@
if (idx == -1) {
throw new IllegalArgumentException("bad subelement name: " + elName); // NOI18N
}
- String val = Util.findText(el);
+ String val = XMLUtil.findText(el);
if (val == null) {
throw new IllegalArgumentException("empty subelement: " + el); // NOI18N
}
@@ -1564,9 +1563,9 @@
if (!"properties".equals(el.getLocalName())) { // NOI18N
throw new IllegalArgumentException("bad subelement. expected 'properties': " + el); // NOI18N
}
- for (Element el2 : Util.findSubElements(el)) {
+ for (Element el2 : XMLUtil.findSubElements(el)) {
String key = el2.getAttribute("name");
- String value = Util.findText(el2);
+ String value = XMLUtil.findText(el2);
// #53553: NPE
if (value == null) {
value = ""; // NOI18N
diff --git a/web.freeform/nbproject/project.xml b/web.freeform/nbproject/project.xml
--- a/web.freeform/nbproject/project.xml
+++ b/web.freeform/nbproject/project.xml
@@ -239,12 +239,11 @@
unit
- org.netbeans.modules.web.freeform
-
-
+ org.netbeans.libs.freemarker
- org.netbeans.modules.javahelp
+ org.netbeans.libs.junit4
+
org.netbeans.modules.editor.mimelookup.impl
@@ -253,11 +252,21 @@
org.netbeans.modules.editor.settings.storage
+ org.netbeans.modules.javahelp
+
+
+ org.netbeans.modules.nbjunit
+
+
+
+
org.netbeans.modules.projectui
- org.netbeans.libs.freemarker
+ org.netbeans.modules.web.freeform
+
+
diff --git a/web.freeform/src/org/netbeans/modules/web/freeform/LookupProviderImpl.java b/web.freeform/src/org/netbeans/modules/web/freeform/LookupProviderImpl.java
--- a/web.freeform/src/org/netbeans/modules/web/freeform/LookupProviderImpl.java
+++ b/web.freeform/src/org/netbeans/modules/web/freeform/LookupProviderImpl.java
@@ -71,6 +71,7 @@
import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups;
import org.openide.util.lookup.ProxyLookup;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -288,7 +289,7 @@
if (web == null) {
return null;
}
- List webModules = Util.findSubElements(web);
+ List webModules = XMLUtil.findSubElements(web);
List roots = new ArrayList();
for (Element webModulesEl : webModules) {
assert webModulesEl.getLocalName().equals("web-module") : webModulesEl; // NOI18N
@@ -298,8 +299,8 @@
}
private File getFile(Element parent, String fileElName, Project proj, PropertyEvaluator evaluator) {
- Element el = Util.findElement(parent, fileElName, WebProjectNature.NS_WEB_2);
- return Util.resolveFile(evaluator, FileUtil.toFile(proj.getProjectDirectory()), Util.findText(el));
+ Element el = XMLUtil.findElement(parent, fileElName, WebProjectNature.NS_WEB_2);
+ return Util.resolveFile(evaluator, FileUtil.toFile(proj.getProjectDirectory()), XMLUtil.findText(el));
}
}
diff --git a/web.freeform/src/org/netbeans/modules/web/freeform/WebFreeFormActionProvider.java b/web.freeform/src/org/netbeans/modules/web/freeform/WebFreeFormActionProvider.java
--- a/web.freeform/src/org/netbeans/modules/web/freeform/WebFreeFormActionProvider.java
+++ b/web.freeform/src/org/netbeans/modules/web/freeform/WebFreeFormActionProvider.java
@@ -266,21 +266,21 @@
// See corresponding schema.
Element data = Util.getPrimaryConfigurationData(helper);
- Element properties = Util.findElement(data, "properties", Util.NAMESPACE); // NOI18N
+ Element properties = XMLUtil.findElement(data, "properties", Util.NAMESPACE); // NOI18N
if (properties != null) {
- Iterator/**/ propertiesIt = Util.findSubElements(properties).iterator();
+ Iterator propertiesIt = XMLUtil.findSubElements(properties).iterator();
while (propertiesIt.hasNext()) {
Element el = (Element) propertiesIt.next();
Element nue = script.getOwnerDocument().createElement("property"); // NOI18N
if (el.getLocalName().equals("property")) { // NOI18N
String name = el.getAttribute("name"); // NOI18N
assert name != null;
- String text = Util.findText(el);
+ String text = XMLUtil.findText(el);
assert text != null;
nue.setAttribute("name", name); // NOI18N
nue.setAttribute("value", text); // NOI18N
} else if (el.getLocalName().equals("property-file")) { // NOI18N
- String text = Util.findText(el);
+ String text = XMLUtil.findText(el);
assert text != null;
nue.setAttribute("file", text); // NOI18N
} else {
@@ -460,7 +460,7 @@
// XXX cannot use FreeformProjectGenerator since that is currently not a public support SPI from ant/freeform
// XXX should this try to find an existing binding? probably not, since it is assumed that if there was one, we would never get here to begin with
Element data = Util.getPrimaryConfigurationData(helper);
- Element ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
+ Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
if (ideActions == null) {
// Probably won't happen, since generator produces it always.
// Not trivial to just add it now, since order is significant in the schema. (FPG deals with these things.)
@@ -506,9 +506,9 @@
} else {
// Add a context menu item, since it applies to the project as a whole.
// Assume there is already a defined, which is quite likely.
- Element view = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
+ Element view = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
if (view != null) {
- Element contextMenu = Util.findElement(view, "context-menu", Util.NAMESPACE); // NOI18N
+ Element contextMenu = XMLUtil.findElement(view, "context-menu", Util.NAMESPACE); // NOI18N
if (contextMenu != null) {
Element ideAction = doc.createElementNS(Util.NAMESPACE, "ide-action"); // NOI18N
ideAction.setAttribute("name", command); // NOI18N
@@ -684,17 +684,17 @@
private String findSourceFolders(String type) {
StringBuffer result = new StringBuffer();
Element data = Util.getPrimaryConfigurationData(helper);
- Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
+ Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
if (foldersEl != null) {
- for (Iterator i = Util.findSubElements(foldersEl).iterator(); i.hasNext();) {
+ for (Iterator i = XMLUtil.findSubElements(foldersEl).iterator(); i.hasNext();) {
Element sourceFolderEl = (Element)i.next();
- Element typeEl = Util.findElement(sourceFolderEl , "type", Util.NAMESPACE); // NOI18N
- if (typeEl == null || !Util.findText(typeEl).equals(type))
+ Element typeEl = XMLUtil.findElement(sourceFolderEl , "type", Util.NAMESPACE); // NOI18N
+ if (typeEl == null || !XMLUtil.findText(typeEl).equals(type))
continue;
- Element locationEl = Util.findElement(sourceFolderEl , "location", Util.NAMESPACE); // NOI18N
+ Element locationEl = XMLUtil.findElement(sourceFolderEl , "location", Util.NAMESPACE); // NOI18N
if (locationEl == null)
continue;
- String location = Util.findText(locationEl);
+ String location = XMLUtil.findText(locationEl);
if (result.length() > 0)
result.append(":"); // NOI18N
result.append(location);
@@ -705,13 +705,13 @@
private String findContextPath() {
Element data = aux.getConfigurationFragment(WebProjectNature.EL_WEB, WebProjectNature.NS_WEB_2, true); // NOI18N
- Element webModulEl = Util.findElement(data, "web-module", WebProjectNature.NS_WEB_2); // NOI18N
+ Element webModulEl = XMLUtil.findElement(data, "web-module", WebProjectNature.NS_WEB_2); // NOI18N
if (webModulEl == null)
return null;
- Element contextPathEl = Util.findElement(webModulEl, "context-path", WebProjectNature.NS_WEB_2); // NOI18N
+ Element contextPathEl = XMLUtil.findElement(webModulEl, "context-path", WebProjectNature.NS_WEB_2); // NOI18N
if (contextPathEl == null)
return null;
- return Util.findText(contextPathEl);
+ return XMLUtil.findText(contextPathEl);
}
}
diff --git a/web.freeform/src/org/netbeans/modules/web/freeform/WebModules.java b/web.freeform/src/org/netbeans/modules/web/freeform/WebModules.java
--- a/web.freeform/src/org/netbeans/modules/web/freeform/WebModules.java
+++ b/web.freeform/src/org/netbeans/modules/web/freeform/WebModules.java
@@ -70,7 +70,6 @@
import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.api.project.SourceGroup;
-import org.netbeans.modules.ant.freeform.spi.support.Util;
import org.netbeans.modules.j2ee.dd.spi.MetadataUnit;
import org.netbeans.modules.j2ee.dd.spi.web.WebAppMetadataModelFactory;
import org.netbeans.modules.web.api.webmodule.WebModule;
@@ -85,6 +84,7 @@
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
import org.netbeans.spi.project.support.ant.PropertyUtils;
import org.openide.util.Mutex;
+import org.openide.xml.XMLUtil;
/**
* Web module implementation on top of freeform project.
@@ -171,21 +171,21 @@
if (web == null) {
return mods;
}
- List/**/ webModules = Util.findSubElements(web);
+ List webModules = XMLUtil.findSubElements(web);
Iterator it = webModules.iterator();
while (it.hasNext()) {
Element webModulesEl = (Element)it.next();
assert webModulesEl.getLocalName().equals("web-module") : webModulesEl;
FileObject docRootFO = getFile (webModulesEl, "doc-root"); //NOI18N
- Element j2eeSpecEl = Util.findElement (webModulesEl, "j2ee-spec-level", WebProjectNature.NS_WEB_2);
- String j2eeSpec = j2eeSpecEl == null ? null : evaluator.evaluate (Util.findText (j2eeSpecEl));
- Element contextPathEl = Util.findElement (webModulesEl, "context-path", WebProjectNature.NS_WEB_2);
- String contextPathText = contextPathEl == null ? null : Util.findText (contextPathEl);
+ Element j2eeSpecEl = XMLUtil.findElement (webModulesEl, "j2ee-spec-level", WebProjectNature.NS_WEB_2);
+ String j2eeSpec = j2eeSpecEl == null ? null : evaluator.evaluate (XMLUtil.findText (j2eeSpecEl));
+ Element contextPathEl = XMLUtil.findElement (webModulesEl, "context-path", WebProjectNature.NS_WEB_2);
+ String contextPathText = contextPathEl == null ? null : XMLUtil.findText (contextPathEl);
String contextPath = contextPathText == null ? null : evaluator.evaluate (contextPathText);
- Element classpathEl = Util.findElement (webModulesEl, "classpath", WebProjectNature.NS_WEB_2);
+ Element classpathEl = XMLUtil.findElement (webModulesEl, "classpath", WebProjectNature.NS_WEB_2);
FileObject [] sources = getSources ();
ClassPath cp = classpathEl == null ? null : createClasspath (classpathEl, sources);
- Element webInfEl = Util.findElement (webModulesEl, "web-inf", WebProjectNature.NS_WEB_2);
+ Element webInfEl = XMLUtil.findElement (webModulesEl, "web-inf", WebProjectNature.NS_WEB_2);
FileObject webInf = null;
if (webInfEl != null) {
webInf = getFile (webModulesEl, "web-inf"); //NOI18N
@@ -196,8 +196,8 @@
}
private FileObject getFile (Element parent, String fileElName) {
- Element el = Util.findElement (parent, fileElName, WebProjectNature.NS_WEB_2);
- String fname = Util.findText (el);
+ Element el = XMLUtil.findElement (parent, fileElName, WebProjectNature.NS_WEB_2);
+ String fname = XMLUtil.findText (el);
if (fname == null) {
// empty element => cannot find fileobject
return null;
@@ -240,7 +240,7 @@
*/
private ClassPath createClasspath(Element classpathEl, FileObject[] sources) {
// System.out.println("creating classpath for " + classpathEl);
- String cp = Util.findText(classpathEl);
+ String cp = XMLUtil.findText(classpathEl);
if (cp == null) {
cp = "";
}
diff --git a/web.freeform/src/org/netbeans/modules/web/freeform/WebProjectGenerator.java b/web.freeform/src/org/netbeans/modules/web/freeform/WebProjectGenerator.java
--- a/web.freeform/src/org/netbeans/modules/web/freeform/WebProjectGenerator.java
+++ b/web.freeform/src/org/netbeans/modules/web/freeform/WebProjectGenerator.java
@@ -48,8 +48,8 @@
import org.netbeans.modules.web.api.webmodule.WebProjectConstants;
import org.netbeans.spi.project.AuxiliaryConfiguration;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
-import org.openide.filesystems.FileObject;
import org.openide.util.NbBundle;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -102,40 +102,40 @@
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
- Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
+ Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
if (foldersEl == null) {
foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
- Util.appendChildElement(data, foldersEl, rootElementsOrder);
+ XMLUtil.appendChildElement(data, foldersEl, rootElementsOrder);
} else {
- List l = Util.findSubElements(foldersEl);
+ List l = XMLUtil.findSubElements(foldersEl);
for (int i = 0; i < l.size(); i++) {
Element e = (Element) l.get(i);
- Element te = Util.findElement(e, "type", Util.NAMESPACE);
- if (te != null && Util.findText(te).equals(folderType)) {
+ Element te = XMLUtil.findElement(e, "type", Util.NAMESPACE);
+ if (te != null && XMLUtil.findText(te).equals(folderType)) {
foldersEl.removeChild(e);
break;
}
}
}
- Element viewEl = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
+ Element viewEl = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
if (viewEl == null) {
viewEl = doc.createElementNS(Util.NAMESPACE, "view"); // NOI18N
- Util.appendChildElement(data, viewEl, rootElementsOrder);
+ XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
}
- Element itemsEl = Util.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
+ Element itemsEl = XMLUtil.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
if (itemsEl == null) {
itemsEl = doc.createElementNS(Util.NAMESPACE, "items"); // NOI18N
- Util.appendChildElement(viewEl, itemsEl, viewElementsOrder);
+ XMLUtil.appendChildElement(viewEl, itemsEl, viewElementsOrder);
} else {
- List l = Util.findSubElements(itemsEl);
+ List l = XMLUtil.findSubElements(itemsEl);
for (int i = 0; i < l.size(); i++) {
Element e = (Element) l.get(i);
if (e.hasAttribute("style")) {
if (e.getAttribute("style").equals("tree")) {
// #110173
- Element labelElement = Util.findElement(e, "label", Util.NAMESPACE);
- if (labelElement != null && label.equals(Util.findText(labelElement))) {
+ Element labelElement = XMLUtil.findElement(e, "label", Util.NAMESPACE);
+ if (labelElement != null && label.equals(XMLUtil.findText(labelElement))) {
itemsEl.removeChild(e);
break;
}
@@ -159,7 +159,7 @@
el = doc.createElementNS(Util.NAMESPACE, "location"); // NOI18N
el.appendChild(doc.createTextNode(path));
sourceFolderEl.appendChild(el);
- Util.appendChildElement(foldersEl, sourceFolderEl, folderElementsOrder);
+ XMLUtil.appendChildElement(foldersEl, sourceFolderEl, folderElementsOrder);
sourceFolderEl = doc.createElementNS(Util.NAMESPACE, "source-folder"); // NOI18N
sourceFolderEl.setAttribute("style", "tree"); // NOI18N
@@ -177,7 +177,7 @@
insertWebInfElement(itemsEl, firstNode, sourceFolderEl);
}
} else {
- Util.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
+ XMLUtil.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
}
}
Util.putPrimaryConfigurationData(helper, data);
@@ -192,7 +192,7 @@
if (secondNode != null) {
itemsEl.insertBefore(sourceFolderEl, secondNode);
} else {
- Util.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
+ XMLUtil.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
}
}
@@ -213,32 +213,32 @@
return list;
}
}
- List wms = Util.findSubElements(data);
+ List wms = XMLUtil.findSubElements(data);
Iterator it = wms.iterator();
while (it.hasNext()) {
Element wmEl = it.next();
WebModule wm = new WebModule();
- Iterator it2 = Util.findSubElements(wmEl).iterator();
+ Iterator it2 = XMLUtil.findSubElements(wmEl).iterator();
while (it2.hasNext()) {
Element el = (Element)it2.next();
if (el.getLocalName().equals("doc-root")) { // NOI18N
- wm.docRoot = Util.findText(el);
+ wm.docRoot = XMLUtil.findText(el);
continue;
}
if (el.getLocalName().equals("classpath")) { // NOI18N
- wm.classpath = Util.findText(el);
+ wm.classpath = XMLUtil.findText(el);
continue;
}
if (el.getLocalName().equals("context-path")) { // NOI18N
- wm.contextPath = Util.findText(el);
+ wm.contextPath = XMLUtil.findText(el);
continue;
}
if (el.getLocalName().equals("j2ee-spec-level")) { // NOI18N
- wm.j2eeSpecLevel = Util.findText(el);
+ wm.j2eeSpecLevel = XMLUtil.findText(el);
continue;
}
if (el.getLocalName().equals("web-inf")) { // NOI18N
- wm.webInf = Util.findText(el);
+ wm.webInf = XMLUtil.findText(el);
}
}
list.add(wm);
@@ -295,7 +295,7 @@
}
Document doc = data.getOwnerDocument();
- List wms = Util.findSubElements(data);
+ List wms = XMLUtil.findSubElements(data);
Iterator it = wms.iterator();
while (it.hasNext()) {
Element wmEl = it.next();
diff --git a/web.freeform/test/unit/src/org/netbeans/modules/web/freeform/WebProjectGeneratorTest.java b/web.freeform/test/unit/src/org/netbeans/modules/web/freeform/WebProjectGeneratorTest.java
--- a/web.freeform/test/unit/src/org/netbeans/modules/web/freeform/WebProjectGeneratorTest.java
+++ b/web.freeform/test/unit/src/org/netbeans/modules/web/freeform/WebProjectGeneratorTest.java
@@ -64,6 +64,7 @@
import org.openide.filesystems.FileUtil;
import org.openide.modules.ModuleInfo;
import org.openide.util.Lookup;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -196,13 +197,13 @@
// check that the correct /1 data was saved
Element el = aux.getConfigurationFragment(WebProjectNature.EL_WEB, WebProjectNature.NS_WEB_1, true);
assertNotNull("Web modules should be saved in /1", el);
- List subElements = Util.findSubElements(el);
+ List subElements = XMLUtil.findSubElements(el);
assertEquals(1, subElements.size());
// compare the web module
Element el2 = subElements.get(0);
assertElement(el2, "web-module", null);
- assertElementArray(Util.findSubElements(el2),
+ assertElementArray(XMLUtil.findSubElements(el2),
new String[] {"doc-root", "context-path", "j2ee-spec-level", "web-inf"},
new String[] {"web", "mymodule", "1.5", "web/WEB-INF"});
// validate against schema:
@@ -224,12 +225,12 @@
assertNull("No /1 data should exist.", el);
el = aux.getConfigurationFragment(WebProjectNature.EL_WEB, WebProjectNature.NS_WEB_2, true);
assertNotNull("Should have /2 data.", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(1, subElements.size());
// compare the web module
el2 = subElements.get(0);
assertElement(el2, "web-module", null);
- assertElementArray(Util.findSubElements(el2),
+ assertElementArray(XMLUtil.findSubElements(el2),
new String[] {"doc-root", "context-path", "j2ee-spec-level", "web-inf"},
new String[] {"web", "mymodule", "1.5", "somewhereelse/WEB-INF"});
// validate against schema:
@@ -252,12 +253,12 @@
assertNull("No /1 data should exist.", el);
el = aux.getConfigurationFragment(WebProjectNature.EL_WEB, WebProjectNature.NS_WEB_2, true);
assertNotNull("Should have /2 data.", el);
- subElements = Util.findSubElements(el);
+ subElements = XMLUtil.findSubElements(el);
assertEquals(1, subElements.size());
// compare the web module
el2 = subElements.get(0);
assertElement(el2, "web-module", null);
- assertElementArray(Util.findSubElements(el2),
+ assertElementArray(XMLUtil.findSubElements(el2),
new String[] {"doc-root", "context-path", "j2ee-spec-level", "web-inf"},
new String[] {"web", "mymodule", "1.5", "somewhereelse/WEB-INF"});
// validate against schema:
@@ -304,7 +305,7 @@
String message = "Element "+element+" does not match [name="+expectedName+",value="+expectedValue+"]"; // NOI18N
assertEquals(message, expectedName, element.getLocalName());
if (expectedValue != null) {
- assertEquals(message, expectedValue, Util.findText(element));
+ assertEquals(message, expectedValue, XMLUtil.findText(element));
}
}
@@ -332,7 +333,7 @@
expectedValue+", attr="+expectedAttrName+", attrvalue="+expectedAttrValue+"]"; // NOI18N
assertEquals(message, expectedName, element.getLocalName());
if (expectedValue != null) {
- assertEquals(message, expectedValue, Util.findText(element));
+ assertEquals(message, expectedValue, XMLUtil.findText(element));
}
String val = element.getAttribute(expectedAttrName);
assertEquals(expectedAttrValue, val);
diff --git a/web.project/nbproject/project.xml b/web.project/nbproject/project.xml
--- a/web.project/nbproject/project.xml
+++ b/web.project/nbproject/project.xml
@@ -522,7 +522,17 @@
unit
- org.netbeans.modules.web.project
+ org.netbeans.libs.junit4
+
+
+
+ org.netbeans.modules.j2eeapis
+
+
+ org.netbeans.modules.masterfs
+
+
+ org.netbeans.modules.nbjunit
@@ -532,10 +542,9 @@
- org.netbeans.modules.j2eeapis
-
-
- org.netbeans.modules.masterfs
+ org.netbeans.modules.web.project
+
+
org.openide.util
diff --git a/web.project/src/org/netbeans/modules/web/project/UpdateProjectImpl.java b/web.project/src/org/netbeans/modules/web/project/UpdateProjectImpl.java
--- a/web.project/src/org/netbeans/modules/web/project/UpdateProjectImpl.java
+++ b/web.project/src/org/netbeans/modules/web/project/UpdateProjectImpl.java
@@ -69,6 +69,7 @@
import org.openide.filesystems.URLMapper;
import org.openide.util.Mutex;
import org.openide.util.NbBundle;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -295,7 +296,7 @@
if (oldRoot != null) {
Document doc = oldRoot.getOwnerDocument();
Element newRoot = doc.createElementNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
- copyDocument (doc, oldRoot, newRoot);
+ XMLUtil.copyDocument (oldRoot, newRoot, WebProjectType.PROJECT_CONFIGURATION_NAMESPACE);
if (version == 1) {
//1->2 upgrade
Element sourceRoots = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); //NOI18N
@@ -317,7 +318,7 @@
Element library = (Element) libList.item(i);
Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
//remove ${ and } from the beginning and end
- String webFileText = findText(webFile);
+ String webFileText = XMLUtil.findText(webFile);
webFileText = webFileText.substring(2, webFileText.length() - 1);
// warIncludesMap.put(webFileText, pathInWarElements.getLength() > 0 ? findText((Element) pathInWarElements.item(0)) : Item.PATH_IN_WAR_NONE);
if (webFileText.startsWith ("lib.")) {
@@ -375,56 +376,6 @@
}
}
- /**
- * Extract nested text from a node.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent node
- * @return the nested text, or null if none was found
- */
- private static String findText(Node parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- private static void copyDocument (Document doc, Element from, Element to) {
- NodeList nl = from.getChildNodes();
- int length = nl.getLength();
- for (int i=0; i< length; i++) {
- Node node = nl.item (i);
- Node newNode = null;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE:
- Element oldElement = (Element) node;
- newNode = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
- NamedNodeMap m = oldElement.getAttributes();
- Element newElement = (Element) newNode;
- for (int index = 0; index < m.getLength(); index++) {
- Node attr = m.item(index);
- newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
- }
- copyDocument(doc,oldElement,(Element)newNode);
- break;
- case Node.TEXT_NODE:
- Text oldText = (Text) node;
- newNode = doc.createTextNode(oldText.getData());
- break;
- case Node.COMMENT_NODE:
- Comment oldComment = (Comment) node;
- newNode = doc.createComment(oldComment.getData());
- break;
- }
- if (newNode != null) {
- to.appendChild (newNode);
- }
- }
- }
-
private static Element updateMinAntVersion (final Element root, final Document doc) {
NodeList list = root.getElementsByTagNameNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,TAG_MINIMUM_ANT_VERSION);
if (list.getLength() == 1) {
diff --git a/web.project/src/org/netbeans/modules/web/project/classpath/ClassPathSupportCallbackImpl.java b/web.project/src/org/netbeans/modules/web/project/classpath/ClassPathSupportCallbackImpl.java
--- a/web.project/src/org/netbeans/modules/web/project/classpath/ClassPathSupportCallbackImpl.java
+++ b/web.project/src/org/netbeans/modules/web/project/classpath/ClassPathSupportCallbackImpl.java
@@ -45,16 +45,15 @@
import java.util.List;
import java.util.Map;
import org.netbeans.modules.j2ee.common.Util;
-import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
import org.netbeans.modules.web.project.WebProjectType;
import org.netbeans.spi.project.support.ant.AntProjectHelper;
+import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
* Defines the various class paths for a web project.
@@ -120,20 +119,20 @@
Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
NodeList pathInWarElements = library.getElementsByTagNameNS(ns, TAG_PATH_IN_WAR);
//remove ${ and } from the beginning and end
- String webFileText = findText(webFile);
+ String webFileText = XMLUtil.findText(webFile);
webFileText = webFileText.substring(2, webFileText.length() - 1);
//#86522
if (webModuleLibraries.equals(TAG_WEB_MODULE__ADDITIONAL_LIBRARIES)) {
String pathInWar = PATH_IN_WAR_NONE;
if (pathInWarElements.getLength() > 0) {
- pathInWar = findText((Element) pathInWarElements.item(0));
+ pathInWar = XMLUtil.findText((Element) pathInWarElements.item(0));
if (pathInWar == null)
pathInWar = "";
}
warIncludesMap.put(webFileText, pathInWar);
} else {
- warIncludesMap.put(webFileText, pathInWarElements.getLength() > 0 ? findText((Element) pathInWarElements.item(0)) : PATH_IN_WAR_NONE);
+ warIncludesMap.put(webFileText, pathInWarElements.getLength() > 0 ? XMLUtil.findText((Element) pathInWarElements.item(0)) : PATH_IN_WAR_NONE);
}
if (dirs != null) {
warIncludesMap.put(webFileText+"."+Util.DESTINATION_DIRECTORY, dirs);
@@ -148,40 +147,6 @@
}
/**
- * Extracts the first nested text from an element.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent element
- * @return the nested text, or null if none was found
- */
- private static String findText( Element parent ) {
- NodeList l = parent.getChildNodes();
- for ( int i = 0; i < l.getLength(); i++ ) {
- if ( l.item(i).getNodeType() == Node.TEXT_NODE ) {
- Text text = (Text)l.item( i );
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- /**
- * Extract nested text from a node.
- * Currently does not handle coalescing text nodes, CDATA sections, etc.
- * @param parent a parent node
- * @return the nested text, or null if none was found
- */
- private static String findText(Node parent) {
- NodeList l = parent.getChildNodes();
- for (int i = 0; i < l.getLength(); i++) {
- if (l.item(i).getNodeType() == Node.TEXT_NODE) {
- Text text = (Text)l.item(i);
- return text.getNodeValue();
- }
- }
- return null;
- }
-
- /**
* Updates the project helper with the list of classpath items which are to be
* included in deployment.
*/