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 @@ -63,84 +63,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