This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 136595
Collapse All | Expand All

(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java (-5 / +6 lines)
Lines 87-92 Link Here
87
import org.openide.util.RequestProcessor;
87
import org.openide.util.RequestProcessor;
88
import org.openide.util.Utilities;
88
import org.openide.util.Utilities;
89
import org.openide.util.WeakListeners;
89
import org.openide.util.WeakListeners;
90
import org.openide.xml.XMLUtil;
90
import org.w3c.dom.Element;
91
import org.w3c.dom.Element;
91
92
92
/**
93
/**
Lines 601-618 Link Here
601
     */
602
     */
602
    private String computeModuleClasspath(ModuleList ml) {
603
    private String computeModuleClasspath(ModuleList ml) {
603
        Element data = project.getPrimaryConfigurationData();
604
        Element data = project.getPrimaryConfigurationData();
604
        Element moduleDependencies = Util.findElement(data,
605
        Element moduleDependencies = XMLUtil.findElement(data,
605
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
606
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
606
        assert moduleDependencies != null : "Malformed metadata in " + project;
607
        assert moduleDependencies != null : "Malformed metadata in " + project;
607
        StringBuffer cp = new StringBuffer();
608
        StringBuffer cp = new StringBuffer();
608
        for (Element dep : Util.findSubElements(moduleDependencies)) {
609
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
609
            if (Util.findElement(dep, "compile-dependency", // NOI18N
610
            if (XMLUtil.findElement(dep, "compile-dependency", // NOI18N
610
                    NbModuleProject.NAMESPACE_SHARED) == null) {
611
                    NbModuleProject.NAMESPACE_SHARED) == null) {
611
                continue;
612
                continue;
612
            }
613
            }
613
            Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
614
            Element cnbEl = XMLUtil.findElement(dep, "code-name-base", // NOI18N
614
                NbModuleProject.NAMESPACE_SHARED);
615
                NbModuleProject.NAMESPACE_SHARED);
615
            String cnb = Util.findText(cnbEl);
616
            String cnb = XMLUtil.findText(cnbEl);
616
            ModuleEntry module = ml.getEntry(cnb);
617
            ModuleEntry module = ml.getEntry(cnb);
617
            if (module == null) {
618
            if (module == null) {
618
                Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + FileUtil.getFileDisplayName(project.getProjectDirectory()));
619
                Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + FileUtil.getFileDisplayName(project.getProjectDirectory()));
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java (-14 / +15 lines)
Lines 131-136 Link Here
131
import org.openide.util.Exceptions;
131
import org.openide.util.Exceptions;
132
import org.openide.util.lookup.AbstractLookup;
132
import org.openide.util.lookup.AbstractLookup;
133
import org.openide.util.lookup.InstanceContent;
133
import org.openide.util.lookup.InstanceContent;
134
import org.openide.xml.XMLUtil;
134
135
135
/**
136
/**
136
 * A NetBeans module project.
137
 * A NetBeans module project.
Lines 221-228 Link Here
221
                    .displayName(NbBundle.getMessage(NbModuleProject.class, "LBL_javahelp_packages")).add();
222
                    .displayName(NbBundle.getMessage(NbModuleProject.class, "LBL_javahelp_packages")).add();
222
        }
223
        }
223
        for (Map.Entry<FileObject,Element> entry : getExtraCompilationUnits().entrySet()) {
224
        for (Map.Entry<FileObject,Element> entry : getExtraCompilationUnits().entrySet()) {
224
            Element pkgrootEl = Util.findElement(entry.getValue(), "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
225
            Element pkgrootEl = XMLUtil.findElement(entry.getValue(), "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
225
            String pkgrootS = Util.findText(pkgrootEl);
226
            String pkgrootS = XMLUtil.findText(pkgrootEl);
226
            sourcesHelper.sourceRoot(pkgrootS).type(JavaProjectConstants.SOURCES_TYPE_JAVA)
227
            sourcesHelper.sourceRoot(pkgrootS).type(JavaProjectConstants.SOURCES_TYPE_JAVA)
227
                    .displayName(/* XXX should schema incl. display name? */entry.getKey().getNameExt()).add();
228
                    .displayName(/* XXX should schema incl. display name? */entry.getKey().getNameExt()).add();
228
        }
229
        }
Lines 340-346 Link Here
340
                AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
341
                AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
341
                Element data = ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true);
342
                Element data = ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true);
342
                if (data != null) {
343
                if (data != null) {
343
                    return Util.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
344
                    return XMLUtil.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
344
                } else {
345
                } else {
345
                    return helper.getPrimaryConfigurationData(true);
346
                    return helper.getPrimaryConfigurationData(true);
346
                }
347
                }
Lines 357-363 Link Here
357
            public Void run() {
358
            public Void run() {
358
                AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
359
                AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
359
                if (ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true) != null) {
360
                if (ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true) != null) {
360
                    ac.putConfigurationFragment(Util.translateXML(data, NbModuleProject.NAMESPACE_SHARED_2), true);
361
                    ac.putConfigurationFragment(XMLUtil.translateXML(data, NbModuleProject.NAMESPACE_SHARED_2), true);
361
                } else {
362
                } else {
362
                    helper.putPrimaryConfigurationData(data, true);
363
                    helper.putPrimaryConfigurationData(data, true);
363
                }
364
                }
Lines 373-381 Link Here
373
374
374
    private NbModuleProvider.NbModuleType getModuleType() {
375
    private NbModuleProvider.NbModuleType getModuleType() {
375
        Element data = getPrimaryConfigurationData();
376
        Element data = getPrimaryConfigurationData();
376
        if (Util.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
377
        if (XMLUtil.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
377
            return NbModuleProvider.SUITE_COMPONENT;
378
            return NbModuleProvider.SUITE_COMPONENT;
378
        } else if (Util.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
379
        } else if (XMLUtil.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
379
            return NbModuleProvider.STANDALONE;
380
            return NbModuleProvider.STANDALONE;
380
        } else {
381
        } else {
381
            return NbModuleProvider.NETBEANS_ORG;
382
            return NbModuleProvider.NETBEANS_ORG;
Lines 471-479 Link Here
471
472
472
    public String getCodeNameBase() {
473
    public String getCodeNameBase() {
473
        Element config = getPrimaryConfigurationData();
474
        Element config = getPrimaryConfigurationData();
474
        Element cnb = Util.findElement(config, "code-name-base", NbModuleProject.NAMESPACE_SHARED); // NOI18N
475
        Element cnb = XMLUtil.findElement(config, "code-name-base", NbModuleProject.NAMESPACE_SHARED); // NOI18N
475
        if (cnb != null) {
476
        if (cnb != null) {
476
            return Util.findText(cnb);
477
            return XMLUtil.findText(cnb);
477
        } else {
478
        } else {
478
            return null;
479
            return null;
479
        }
480
        }
Lines 623-634 Link Here
623
            return true;
624
            return true;
624
        }
625
        }
625
        Element config = getPrimaryConfigurationData();
626
        Element config = getPrimaryConfigurationData();
626
        Element pubPkgs = Util.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
627
        Element pubPkgs = XMLUtil.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
627
        if (pubPkgs == null) {
628
        if (pubPkgs == null) {
628
            // Try <friend-packages> too.
629
            // Try <friend-packages> too.
629
            pubPkgs = Util.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
630
            pubPkgs = XMLUtil.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
630
        }
631
        }
631
        return pubPkgs != null && !Util.findSubElements(pubPkgs).isEmpty();
632
        return pubPkgs != null && !XMLUtil.findSubElements(pubPkgs).isEmpty();
632
    }
633
    }
633
    
634
    
634
    public List<String> supportedTestTypes() {
635
    public List<String> supportedTestTypes() {
Lines 655-664 Link Here
655
    public Map<FileObject,Element> getExtraCompilationUnits() {
656
    public Map<FileObject,Element> getExtraCompilationUnits() {
656
        if (extraCompilationUnits == null) {
657
        if (extraCompilationUnits == null) {
657
            extraCompilationUnits = new HashMap<FileObject,Element>();
658
            extraCompilationUnits = new HashMap<FileObject,Element>();
658
            for (Element ecu : Util.findSubElements(getPrimaryConfigurationData())) {
659
            for (Element ecu : XMLUtil.findSubElements(getPrimaryConfigurationData())) {
659
                if (ecu.getLocalName().equals("extra-compilation-unit")) { // NOI18N
660
                if (ecu.getLocalName().equals("extra-compilation-unit")) { // NOI18N
660
                    Element pkgrootEl = Util.findElement(ecu, "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
661
                    Element pkgrootEl = XMLUtil.findElement(ecu, "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
661
                    String pkgrootS = Util.findText(pkgrootEl);
662
                    String pkgrootS = XMLUtil.findText(pkgrootEl);
662
                    String pkgrootEval = evaluator().evaluate(pkgrootS);
663
                    String pkgrootEval = evaluator().evaluate(pkgrootS);
663
                    FileObject pkgroot = getHelper().resolveFileObject(pkgrootEval);
664
                    FileObject pkgroot = getHelper().resolveFileObject(pkgrootEval);
664
                    if (pkgroot == null) {
665
                    if (pkgroot == null) {
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ProjectXMLManager.java (-30 / +30 lines)
Lines 218-226 Link Here
218
        } else {
218
        } else {
219
            ml = ModuleList.getModuleList(prjDirF);
219
            ml = ModuleList.getModuleList(prjDirF);
220
        }
220
        }
221
        for (Element depEl : Util.findSubElements(moduleDependencies)) {
221
        for (Element depEl : XMLUtil.findSubElements(moduleDependencies)) {
222
            Element cnbEl = findElement(depEl, ProjectXMLManager.CODE_NAME_BASE);
222
            Element cnbEl = findElement(depEl, ProjectXMLManager.CODE_NAME_BASE);
223
            String _cnb = Util.findText(cnbEl);
223
            String _cnb = XMLUtil.findText(cnbEl);
224
            ModuleDependency depToAdd = getModuleDependency(_cnb, ml, depEl);
224
            ModuleDependency depToAdd = getModuleDependency(_cnb, ml, depEl);
225
            if (depToAdd == null) {
225
            if (depToAdd == null) {
226
                continue;
226
                continue;
Lines 255-267 Link Here
255
        Element relVerEl = findElement(runDepEl, ProjectXMLManager.RELEASE_VERSION);
255
        Element relVerEl = findElement(runDepEl, ProjectXMLManager.RELEASE_VERSION);
256
        String relVer = null;
256
        String relVer = null;
257
        if (relVerEl != null) {
257
        if (relVerEl != null) {
258
            relVer = Util.findText(relVerEl);
258
            relVer = XMLUtil.findText(relVerEl);
259
        }
259
        }
260
260
261
        Element specVerEl = findElement(runDepEl, ProjectXMLManager.SPECIFICATION_VERSION);
261
        Element specVerEl = findElement(runDepEl, ProjectXMLManager.SPECIFICATION_VERSION);
262
        String specVer = null;
262
        String specVer = null;
263
        if (specVerEl != null) {
263
        if (specVerEl != null) {
264
            specVer = Util.findText(specVerEl);
264
            specVer = XMLUtil.findText(specVerEl);
265
        }
265
        }
266
266
267
        Element compDepEl = findElement(depEl, ProjectXMLManager.COMPILE_DEPENDENCY);
267
        Element compDepEl = findElement(depEl, ProjectXMLManager.COMPILE_DEPENDENCY);
Lines 287-295 Link Here
287
        } else {
287
        } else {
288
            ml = ModuleList.getModuleList(prjDirF);
288
            ml = ModuleList.getModuleList(prjDirF);
289
        }
289
        }
290
        for (Element dep : Util.findSubElements(moduleDependencies)) {
290
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
291
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
291
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
292
            String depCnb = Util.findText(cnbEl);
292
            String depCnb = XMLUtil.findText(cnbEl);
293
            if (depCnb.equals(cnb)) {
293
            if (depCnb.equals(cnb)) {
294
                return getModuleDependency(cnb, ml, dep);
294
                return getModuleDependency(cnb, ml, dep);
295
            }
295
            }
Lines 301-309 Link Here
301
    public void removeDependency(String cnbToRemove) {
301
    public void removeDependency(String cnbToRemove) {
302
        Element _confData = getConfData();
302
        Element _confData = getConfData();
303
        Element moduleDependencies = findModuleDependencies(_confData);
303
        Element moduleDependencies = findModuleDependencies(_confData);
304
        for (Element dep : Util.findSubElements(moduleDependencies)) {
304
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
305
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
305
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
306
            String _cnb = Util.findText(cnbEl);
306
            String _cnb = XMLUtil.findText(cnbEl);
307
            if (cnbToRemove.equals(_cnb)) {
307
            if (cnbToRemove.equals(_cnb)) {
308
                moduleDependencies.removeChild(dep);
308
                moduleDependencies.removeChild(dep);
309
            }
309
            }
Lines 330-338 Link Here
330
    public void removeDependenciesByCNB(Collection<String> cnbsToDelete) {
330
    public void removeDependenciesByCNB(Collection<String> cnbsToDelete) {
331
        Element _confData = getConfData();
331
        Element _confData = getConfData();
332
        Element moduleDependencies = findModuleDependencies(_confData);
332
        Element moduleDependencies = findModuleDependencies(_confData);
333
        for (Element dep : Util.findSubElements(moduleDependencies)) {
333
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
334
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
334
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
335
            String _cnb = Util.findText(cnbEl);
335
            String _cnb = XMLUtil.findText(cnbEl);
336
            if (cnbsToDelete.remove(_cnb)) {
336
            if (cnbsToDelete.remove(_cnb)) {
337
                moduleDependencies.removeChild(dep);
337
                moduleDependencies.removeChild(dep);
338
            }
338
            }
Lines 350-360 Link Here
350
    public void editDependency(ModuleDependency origDep, ModuleDependency newDep) {
350
    public void editDependency(ModuleDependency origDep, ModuleDependency newDep) {
351
        Element _confData = getConfData();
351
        Element _confData = getConfData();
352
        Element moduleDependencies = findModuleDependencies(_confData);
352
        Element moduleDependencies = findModuleDependencies(_confData);
353
        List<Element> currentDeps = Util.findSubElements(moduleDependencies);
353
        List<Element> currentDeps = XMLUtil.findSubElements(moduleDependencies);
354
        for (Iterator<Element> it = currentDeps.iterator(); it.hasNext();) {
354
        for (Iterator<Element> it = currentDeps.iterator(); it.hasNext();) {
355
            Element dep = it.next();
355
            Element dep = it.next();
356
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
356
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
357
            String _cnb = Util.findText(cnbEl);
357
            String _cnb = XMLUtil.findText(cnbEl);
358
            if (_cnb.equals(origDep.getModuleEntry().getCodeNameBase())) {
358
            if (_cnb.equals(origDep.getModuleEntry().getCodeNameBase())) {
359
                moduleDependencies.removeChild(dep);
359
                moduleDependencies.removeChild(dep);
360
                Element nextDep = it.hasNext() ? it.next() : null;
360
                Element nextDep = it.hasNext() ? it.next() : null;
Lines 474-494 Link Here
474
        Element _confData = getConfData();
474
        Element _confData = getConfData();
475
        Element testModuleDependenciesEl = findTestDependenciesElement(_confData);
475
        Element testModuleDependenciesEl = findTestDependenciesElement(_confData);
476
        Element testTypeRemoveEl = null;
476
        Element testTypeRemoveEl = null;
477
        for (Element type : Util.findSubElements(testModuleDependenciesEl)) {
477
        for (Element type : XMLUtil.findSubElements(testModuleDependenciesEl)) {
478
            Element nameEl = findElement(type, TEST_TYPE_NAME);
478
            Element nameEl = findElement(type, TEST_TYPE_NAME);
479
            String nameOfType = Util.findText(nameEl);
479
            String nameOfType = XMLUtil.findText(nameEl);
480
            if (testType.equals(nameOfType)) {
480
            if (testType.equals(nameOfType)) {
481
                testTypeRemoveEl = type;
481
                testTypeRemoveEl = type;
482
            }
482
            }
483
        }
483
        }
484
        //found such a test type
484
        //found such a test type
485
        if (testTypeRemoveEl != null) {
485
        if (testTypeRemoveEl != null) {
486
            for (Element el : Util.findSubElements(testTypeRemoveEl)) {
486
            for (Element el : XMLUtil.findSubElements(testTypeRemoveEl)) {
487
                Element cnbEl = findElement(el, TEST_DEPENDENCY_CNB);
487
                Element cnbEl = findElement(el, TEST_DEPENDENCY_CNB);
488
                if (cnbEl == null) {
488
                if (cnbEl == null) {
489
                    continue;   //name node, continue
489
                    continue;   //name node, continue
490
                }
490
                }
491
                String _cnb = Util.findText(cnbEl);
491
                String _cnb = XMLUtil.findText(cnbEl);
492
                if (cnbToRemove.equals(_cnb)) {
492
                if (cnbToRemove.equals(_cnb)) {
493
                    // found test dependency with desired CNB
493
                    // found test dependency with desired CNB
494
                    testTypeRemoveEl.removeChild(el);
494
                    testTypeRemoveEl.removeChild(el);
Lines 542-548 Link Here
542
                }
542
                }
543
                Element testTypeEl = null;
543
                Element testTypeEl = null;
544
                //iterate through test types to determine if testType exist
544
                //iterate through test types to determine if testType exist
545
                for (Element tt : Util.findSubElements(testModuleDependenciesEl)) {
545
                for (Element tt : XMLUtil.findSubElements(testModuleDependenciesEl)) {
546
                    Node nameNode = findElement(tt, "name"); // NOI18N
546
                    Node nameNode = findElement(tt, "name"); // NOI18N
547
                    assert nameNode != null : "should be some child with name";
547
                    assert nameNode != null : "should be some child with name";
548
                    //Node nameNode = tt.getFirstChild();
548
                    //Node nameNode = tt.getFirstChild();
Lines 638-661 Link Here
638
        Map<String, Set<TestModuleDependency>> testDeps = new HashMap<String, Set<TestModuleDependency>>();
638
        Map<String, Set<TestModuleDependency>> testDeps = new HashMap<String, Set<TestModuleDependency>>();
639
639
640
        if (testDepsEl != null) {
640
        if (testDepsEl != null) {
641
            for (Element typeEl : Util.findSubElements(testDepsEl)) {
641
            for (Element typeEl : XMLUtil.findSubElements(testDepsEl)) {
642
                Element testTypeEl = findElement(typeEl, TEST_TYPE_NAME);
642
                Element testTypeEl = findElement(typeEl, TEST_TYPE_NAME);
643
                String testType = null;
643
                String testType = null;
644
                if (testTypeEl != null) {
644
                if (testTypeEl != null) {
645
                    testType = Util.findText(testTypeEl);
645
                    testType = XMLUtil.findText(testTypeEl);
646
                }
646
                }
647
                if (testType == null) {
647
                if (testType == null) {
648
                    testType = TestModuleDependency.UNIT; // default variant
648
                    testType = TestModuleDependency.UNIT; // default variant
649
                }
649
                }
650
                Set<TestModuleDependency> directTestDeps = new TreeSet<TestModuleDependency>();
650
                Set<TestModuleDependency> directTestDeps = new TreeSet<TestModuleDependency>();
651
                for (Element depEl : Util.findSubElements(typeEl)) {
651
                for (Element depEl : XMLUtil.findSubElements(typeEl)) {
652
                    if (depEl.getTagName().equals(TEST_DEPENDENCY)) {
652
                    if (depEl.getTagName().equals(TEST_DEPENDENCY)) {
653
                        // parse test dep
653
                        // parse test dep
654
                        Element cnbEl = findElement(depEl, TEST_DEPENDENCY_CNB);
654
                        Element cnbEl = findElement(depEl, TEST_DEPENDENCY_CNB);
655
                        boolean test = findElement(depEl, TEST_DEPENDENCY_TEST) != null;
655
                        boolean test = findElement(depEl, TEST_DEPENDENCY_TEST) != null;
656
                        String _cnb = null;
656
                        String _cnb = null;
657
                        if (cnbEl != null) {
657
                        if (cnbEl != null) {
658
                            _cnb = Util.findText(cnbEl);
658
                            _cnb = XMLUtil.findText(cnbEl);
659
                        }
659
                        }
660
                        boolean recursive = findElement(depEl, TEST_DEPENDENCY_RECURSIVE) != null;
660
                        boolean recursive = findElement(depEl, TEST_DEPENDENCY_RECURSIVE) != null;
661
                        boolean compile = findElement(depEl, TEST_DEPENDENCY_COMPILE) != null;
661
                        boolean compile = findElement(depEl, TEST_DEPENDENCY_COMPILE) != null;
Lines 806-817 Link Here
806
            return Collections.unmodifiableMap(cpExtensions);
806
            return Collections.unmodifiableMap(cpExtensions);
807
        }
807
        }
808
        Map<String, String> cps = new HashMap<String, String>();
808
        Map<String, String> cps = new HashMap<String, String>();
809
        for (Element cpExtEl : Util.findSubElements(getConfData())) {
809
        for (Element cpExtEl : XMLUtil.findSubElements(getConfData())) {
810
            if (CLASS_PATH_EXTENSION.equals(cpExtEl.getTagName())) {
810
            if (CLASS_PATH_EXTENSION.equals(cpExtEl.getTagName())) {
811
                Element binOrigEl = findElement(cpExtEl, BINARY_ORIGIN);
811
                Element binOrigEl = findElement(cpExtEl, BINARY_ORIGIN);
812
                Element runtimePathEl = findElement(cpExtEl, CLASS_PATH_RUNTIME_PATH);
812
                Element runtimePathEl = findElement(cpExtEl, CLASS_PATH_RUNTIME_PATH);
813
                if (binOrigEl != null && runtimePathEl != null) {
813
                if (binOrigEl != null && runtimePathEl != null) {
814
                    cps.put(Util.findText(runtimePathEl), Util.findText(binOrigEl));
814
                    cps.put(XMLUtil.findText(runtimePathEl), XMLUtil.findText(binOrigEl));
815
                }
815
                }
816
            }
816
            }
817
        }
817
        }
Lines 822-828 Link Here
822
    public String getCodeNameBase() {
822
    public String getCodeNameBase() {
823
        if (cnb == null) {
823
        if (cnb == null) {
824
            Element cnbEl = findElement(getConfData(), ProjectXMLManager.CODE_NAME_BASE);
824
            Element cnbEl = findElement(getConfData(), ProjectXMLManager.CODE_NAME_BASE);
825
            cnb = Util.findText(cnbEl);
825
            cnb = XMLUtil.findText(cnbEl);
826
        }
826
        }
827
        return cnb;
827
        return cnb;
828
    }
828
    }
Lines 875-881 Link Here
875
    }
875
    }
876
876
877
    private static Element findElement(Element parentEl, String elementName) {
877
    private static Element findElement(Element parentEl, String elementName) {
878
        return Util.findElement(parentEl, elementName, NbModuleProject.NAMESPACE_SHARED);
878
        return XMLUtil.findElement(parentEl, elementName, NbModuleProject.NAMESPACE_SHARED);
879
    }
879
    }
880
880
881
    /** Package-private for unit tests only. */
881
    /** Package-private for unit tests only. */
Lines 922-932 Link Here
922
     */
922
     */
923
    private static Set<ManifestManager.PackageExport> findAllPackages(Element parent) {
923
    private static Set<ManifestManager.PackageExport> findAllPackages(Element parent) {
924
        Set<ManifestManager.PackageExport> packages = new HashSet<ManifestManager.PackageExport>();
924
        Set<ManifestManager.PackageExport> packages = new HashSet<ManifestManager.PackageExport>();
925
        for (Element pkgEl : Util.findSubElements(parent)) {
925
        for (Element pkgEl : XMLUtil.findSubElements(parent)) {
926
            if (PACKAGE.equals(pkgEl.getTagName())) {
926
            if (PACKAGE.equals(pkgEl.getTagName())) {
927
                packages.add(new ManifestManager.PackageExport(Util.findText(pkgEl), false));
927
                packages.add(new ManifestManager.PackageExport(XMLUtil.findText(pkgEl), false));
928
            } else if (SUBPACKAGES.equals(pkgEl.getTagName())) {
928
            } else if (SUBPACKAGES.equals(pkgEl.getTagName())) {
929
                packages.add(new ManifestManager.PackageExport(Util.findText(pkgEl), true));
929
                packages.add(new ManifestManager.PackageExport(XMLUtil.findText(pkgEl), true));
930
            }
930
            }
931
        }
931
        }
932
        return packages;
932
        return packages;
Lines 958-966 Link Here
958
        Element friendsEl = findFriendsElement(confData);
958
        Element friendsEl = findFriendsElement(confData);
959
        if (friendsEl != null) {
959
        if (friendsEl != null) {
960
            Set<String> friends = new TreeSet<String>();
960
            Set<String> friends = new TreeSet<String>();
961
            for (Element friendEl : Util.findSubElements(friendsEl)) {
961
            for (Element friendEl : XMLUtil.findSubElements(friendsEl)) {
962
                if (FRIEND.equals(friendEl.getTagName())) {
962
                if (FRIEND.equals(friendEl.getTagName())) {
963
                    friends.add(Util.findText(friendEl));
963
                    friends.add(XMLUtil.findText(friendEl));
964
                }
964
                }
965
            }
965
            }
966
            return friends.toArray(new String[friends.size()]);
966
            return friends.toArray(new String[friends.size()]);
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/Util.java (-102 lines)
Lines 122-229 Link Here
122
    
122
    
123
    private static final String SFS_VALID_PATH_RE = "(\\p{Alnum}|\\/|_)+"; // NOI18N
123
    private static final String SFS_VALID_PATH_RE = "(\\p{Alnum}|\\/|_)+"; // NOI18N
124
    
124
    
125
    // COPIED FROM org.netbeans.modules.project.ant:
126
    // (except for namespace == null support in findElement)
127
    // (and support for comments in findSubElements)
128
    
129
    /**
130
     * Search for an XML element in the direct children of a parent.
131
     * DOM provides a similar method but it does a recursive search
132
     * which we do not want. It also gives a node list and we want
133
     * only one result.
134
     * @param parent a parent element
135
     * @param name the intended local name
136
     * @param namespace the intended namespace (or null)
137
     * @return the first child element with that name, or null if none
138
     */
139
    public static Element findElement(Element parent, String name, String namespace) {
140
        NodeList l = parent.getChildNodes();
141
        for (int i = 0; i < l.getLength(); i++) {
142
            if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
143
                Element el = (Element)l.item(i);
144
                if ((namespace == null && name.equals(el.getTagName())) ||
145
                        (namespace != null && name.equals(el.getLocalName()) &&
146
                        namespace.equals(el.getNamespaceURI()))) {
147
                    return el;
148
                }
149
            }
150
        }
151
        return null;
152
    }
153
    
154
    /**
155
     * Extract nested text from an element.
156
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
157
     * @param parent a parent element
158
     * @return the nested text, or null if none was found
159
     */
160
    public static String findText(Element parent) {
161
        NodeList l = parent.getChildNodes();
162
        for (int i = 0; i < l.getLength(); i++) {
163
            if (l.item(i).getNodeType() == Node.TEXT_NODE) {
164
                Text text = (Text)l.item(i);
165
                return text.getNodeValue();
166
            }
167
        }
168
        return null;
169
    }
170
    
171
    /**
172
     * Find all direct child elements of an element.
173
     * More useful than {@link Element#getElementsByTagNameNS} because it does
174
     * not recurse into recursive child elements.
175
     * Children which are all-whitespace text nodes or comments are ignored; others cause
176
     * an exception to be thrown.
177
     * @param parent a parent element in a DOM tree
178
     * @return a list of direct child elements (may be empty)
179
     * @throws IllegalArgumentException if there are non-element children besides whitespace
180
     */
181
    public static List<Element> findSubElements(Element parent) throws IllegalArgumentException {
182
        NodeList l = parent.getChildNodes();
183
        List<Element> elements = new ArrayList<Element>(l.getLength());
184
        for (int i = 0; i < l.getLength(); i++) {
185
            Node n = l.item(i);
186
            if (n.getNodeType() == Node.ELEMENT_NODE) {
187
                elements.add((Element)n);
188
            } else if (n.getNodeType() == Node.TEXT_NODE) {
189
                String text = ((Text)n).getNodeValue();
190
                if (text.trim().length() > 0) {
191
                    throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
192
                }
193
            } else if (n.getNodeType() == Node.COMMENT_NODE) {
194
                // OK, ignore
195
            } else {
196
                throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
197
            }
198
        }
199
        return elements;
200
    }
201
202
    /**
203
     * Convert an XML fragment from one namespace to another.
204
     */
205
    public static Element translateXML(Element from, String namespace) {
206
        Element to = from.getOwnerDocument().createElementNS(namespace, from.getLocalName());
207
        NodeList nl = from.getChildNodes();
208
        int length = nl.getLength();
209
        for (int i = 0; i < length; i++) {
210
            Node node = nl.item(i);
211
            Node newNode;
212
            if (node.getNodeType() == Node.ELEMENT_NODE) {
213
                newNode = translateXML((Element) node, namespace);
214
            } else {
215
                newNode = node.cloneNode(true);
216
            }
217
            to.appendChild(newNode);
218
        }
219
        NamedNodeMap m = from.getAttributes();
220
        for (int i = 0; i < m.getLength(); i++) {
221
            Node attr = m.item(i);
222
            to.setAttribute(attr.getNodeName(), attr.getNodeValue());
223
        }
224
        return to;
225
    }
226
227
    /**
125
    /**
228
     * Pass to {@link XPath#setNamespaceContext} to bind {@code nbm:} to the /3 namespace.
126
     * Pass to {@link XPath#setNamespaceContext} to bind {@code nbm:} to the /3 namespace.
229
     */
127
     */
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/AccessibilityQueryImpl.java (-4 / +5 lines)
Lines 48-53 Link Here
48
import org.openide.ErrorManager;
48
import org.openide.ErrorManager;
49
import org.openide.filesystems.FileObject;
49
import org.openide.filesystems.FileObject;
50
import org.openide.filesystems.FileUtil;
50
import org.openide.filesystems.FileUtil;
51
import org.openide.xml.XMLUtil;
51
import org.w3c.dom.Element;
52
import org.w3c.dom.Element;
52
53
53
/**
54
/**
Lines 69-85 Link Here
69
            if (path != null) {
70
            if (path != null) {
70
                String name = path.replace('/', '.');
71
                String name = path.replace('/', '.');
71
                Element config = project.getPrimaryConfigurationData();
72
                Element config = project.getPrimaryConfigurationData();
72
                Element pubPkgs = Util.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
73
                Element pubPkgs = XMLUtil.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
73
                if (pubPkgs == null) {
74
                if (pubPkgs == null) {
74
                    // Try <friend-packages> too.
75
                    // Try <friend-packages> too.
75
                    pubPkgs = Util.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
76
                    pubPkgs = XMLUtil.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
76
                }
77
                }
77
                if (pubPkgs != null) {
78
                if (pubPkgs != null) {
78
                    Iterator it = Util.findSubElements(pubPkgs).iterator();
79
                    Iterator it = XMLUtil.findSubElements(pubPkgs).iterator();
79
                    while (it.hasNext()) {
80
                    while (it.hasNext()) {
80
                        Element pubPkg = (Element) it.next();
81
                        Element pubPkg = (Element) it.next();
81
                        boolean sub = "subpackages".equals(pubPkg.getLocalName()); // NOI18N
82
                        boolean sub = "subpackages".equals(pubPkg.getLocalName()); // NOI18N
82
                        String pubPkgS = Util.findText(pubPkg);
83
                        String pubPkgS = XMLUtil.findText(pubPkg);
83
                        if (name.equals(pubPkgS) || (sub && name.startsWith(pubPkgS + '.'))) {
84
                        if (name.equals(pubPkgS) || (sub && name.startsWith(pubPkgS + '.'))) {
84
                            return true;
85
                            return true;
85
                        }
86
                        }
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java (-7 / +7 lines)
Lines 63-69 Link Here
63
import org.netbeans.spi.java.classpath.ClassPathProvider;
63
import org.netbeans.spi.java.classpath.ClassPathProvider;
64
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
64
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
65
import org.netbeans.modules.apisupport.project.NbModuleProject;
65
import org.netbeans.modules.apisupport.project.NbModuleProject;
66
import org.netbeans.modules.apisupport.project.Util;
67
import org.netbeans.spi.java.classpath.PathResourceImplementation;
66
import org.netbeans.spi.java.classpath.PathResourceImplementation;
68
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
67
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
69
import org.netbeans.spi.project.support.ant.AntProjectEvent;
68
import org.netbeans.spi.project.support.ant.AntProjectEvent;
Lines 74-79 Link Here
74
import org.openide.filesystems.FileStateInvalidException;
73
import org.openide.filesystems.FileStateInvalidException;
75
import org.openide.filesystems.FileUtil;
74
import org.openide.filesystems.FileUtil;
76
import org.openide.util.WeakListeners;
75
import org.openide.util.WeakListeners;
76
import org.openide.xml.XMLUtil;
77
import org.w3c.dom.Element;
77
import org.w3c.dom.Element;
78
78
79
public final class ClassPathProviderImpl implements ClassPathProvider {
79
public final class ClassPathProviderImpl implements ClassPathProvider {
Lines 296-304 Link Here
296
        for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
296
        for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
297
            final FileObject pkgroot = entry.getKey();
297
            final FileObject pkgroot = entry.getKey();
298
            Element pkgrootEl = entry.getValue();
298
            Element pkgrootEl = entry.getValue();
299
            Element classpathEl = Util.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
299
            Element classpathEl = XMLUtil.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
300
            assert classpathEl != null : "no <classpath> in " + pkgrootEl;
300
            assert classpathEl != null : "no <classpath> in " + pkgrootEl;
301
            final String classpathS = Util.findText(classpathEl);
301
            final String classpathS = XMLUtil.findText(classpathEl);
302
            if (classpathS == null) {
302
            if (classpathS == null) {
303
                extraCompilationUnitsCompile.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
303
                extraCompilationUnitsCompile.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
304
                extraCompilationUnitsExecute.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
304
                extraCompilationUnitsExecute.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
Lines 333-341 Link Here
333
                    }
333
                    }
334
                    public void configurationXmlChanged(AntProjectEvent ev) {
334
                    public void configurationXmlChanged(AntProjectEvent ev) {
335
                        Element pkgrootEl = project.getExtraCompilationUnits().get(pkgroot);
335
                        Element pkgrootEl = project.getExtraCompilationUnits().get(pkgroot);
336
                        Element classpathEl = Util.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
336
                        Element classpathEl = XMLUtil.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
337
                        assert classpathEl != null : "no <classpath> in " + pkgrootEl;
337
                        assert classpathEl != null : "no <classpath> in " + pkgrootEl;
338
                        cpS = Util.findText(classpathEl);
338
                        cpS = XMLUtil.findText(classpathEl);
339
                        pcs.firePropertyChange(PROP_RESOURCES, null, null);
339
                        pcs.firePropertyChange(PROP_RESOURCES, null, null);
340
                    }
340
                    }
341
                    public void propertiesChanged(AntProjectEvent ev) {}
341
                    public void propertiesChanged(AntProjectEvent ev) {}
Lines 344-354 Link Here
344
                extraCompilationUnitsCompile.put(pkgroot, ClassPathFactory.createClassPath(ecuCompile));
344
                extraCompilationUnitsCompile.put(pkgroot, ClassPathFactory.createClassPath(ecuCompile));
345
                // Add <built-to> dirs and JARs for ClassPath.EXECUTE.
345
                // Add <built-to> dirs and JARs for ClassPath.EXECUTE.
346
                List<PathResourceImplementation> extraEntries = new ArrayList<PathResourceImplementation>();
346
                List<PathResourceImplementation> extraEntries = new ArrayList<PathResourceImplementation>();
347
                for (Element kid : Util.findSubElements(pkgrootEl)) {
347
                for (Element kid : XMLUtil.findSubElements(pkgrootEl)) {
348
                    if (!kid.getLocalName().equals("built-to")) { // NOI18N
348
                    if (!kid.getLocalName().equals("built-to")) { // NOI18N
349
                        continue;
349
                        continue;
350
                    }
350
                    }
351
                    String rawtext = Util.findText(kid);
351
                    String rawtext = XMLUtil.findText(kid);
352
                    assert rawtext != null : "Null content for <built-to> in " + project;
352
                    assert rawtext != null : "Null content for <built-to> in " + project;
353
                    String text = project.evaluator().evaluate(rawtext);
353
                    String text = project.evaluator().evaluate(rawtext);
354
                    if (text == null) {
354
                    if (text == null) {
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java (-5 / +5 lines)
Lines 409-421 Link Here
409
                is.close();
409
                is.close();
410
            }
410
            }
411
            Element docel = doc.getDocumentElement();
411
            Element docel = doc.getDocumentElement();
412
            Element type = Util.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
412
            Element type = XMLUtil.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
413
            String cnb = null;
413
            String cnb = null;
414
            if (Util.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
414
            if (XMLUtil.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
415
                Element cfg = Util.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
415
                Element cfg = XMLUtil.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
416
                Element data = Util.findElement(cfg, "data", null); // NOI18N
416
                Element data = XMLUtil.findElement(cfg, "data", null); // NOI18N
417
                if (data != null) {
417
                if (data != null) {
418
                    cnb = Util.findText(Util.findElement(data, "code-name-base", null)); // NOI18N
418
                    cnb = XMLUtil.findText(XMLUtil.findElement(data, "code-name-base", null)); // NOI18N
419
                }
419
                }
420
            }
420
            }
421
            return cnb;
421
            return cnb;
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImpl.java (-3 / +3 lines)
Lines 50-60 Link Here
50
import javax.swing.event.ChangeListener;
50
import javax.swing.event.ChangeListener;
51
import org.netbeans.api.java.queries.SourceForBinaryQuery;
51
import org.netbeans.api.java.queries.SourceForBinaryQuery;
52
import org.netbeans.modules.apisupport.project.NbModuleProject;
52
import org.netbeans.modules.apisupport.project.NbModuleProject;
53
import org.netbeans.modules.apisupport.project.Util;
54
import org.netbeans.modules.apisupport.project.universe.TestEntry;
53
import org.netbeans.modules.apisupport.project.universe.TestEntry;
55
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
54
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
56
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileUtil;
56
import org.openide.filesystems.FileUtil;
57
import org.openide.xml.XMLUtil;
58
import org.w3c.dom.Element;
58
import org.w3c.dom.Element;
59
59
60
/**
60
/**
Lines 136-146 Link Here
136
                if (res == null) {
136
                if (res == null) {
137
                // Check extra compilation units.
137
                // Check extra compilation units.
138
                ECUS: for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
138
                ECUS: for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
139
                    for (Element kid : Util.findSubElements(entry.getValue())) {
139
                    for (Element kid : XMLUtil.findSubElements(entry.getValue())) {
140
                        if (!kid.getLocalName().equals("built-to")) { // NOI18N
140
                        if (!kid.getLocalName().equals("built-to")) { // NOI18N
141
                            continue;
141
                            continue;
142
                        }
142
                        }
143
                        String rawtext = Util.findText(kid);
143
                        String rawtext = XMLUtil.findText(kid);
144
                        assert rawtext != null : "Null content for <built-to> in " + project;
144
                        assert rawtext != null : "Null content for <built-to> in " + project;
145
                        String text = project.evaluator().evaluate(rawtext);
145
                        String text = project.evaluator().evaluate(rawtext);
146
                        if (text == null) {
146
                        if (text == null) {
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java (-7 / +8 lines)
Lines 64-69 Link Here
64
import org.openide.ErrorManager;
64
import org.openide.ErrorManager;
65
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileObject;
66
import org.openide.filesystems.FileUtil;
66
import org.openide.filesystems.FileUtil;
67
import org.openide.xml.XMLUtil;
67
import org.w3c.dom.Element;
68
import org.w3c.dom.Element;
68
69
69
/**
70
/**
Lines 90-108 Link Here
90
            return Collections.emptySet();
91
            return Collections.emptySet();
91
        }
92
        }
92
        Element data = project.getPrimaryConfigurationData();
93
        Element data = project.getPrimaryConfigurationData();
93
        Element moduleDependencies = Util.findElement(data,
94
        Element moduleDependencies = XMLUtil.findElement(data,
94
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
95
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
95
        assert moduleDependencies != null : "Malformed metadata in " + project;
96
        assert moduleDependencies != null : "Malformed metadata in " + project;
96
        for (Element dep : Util.findSubElements(moduleDependencies)) {
97
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
97
            /* Probably better to open runtime deps too. TBD.
98
            /* Probably better to open runtime deps too. TBD.
98
            if (Util.findElement(dep, "build-prerequisite", // NOI18N
99
            if (Util.findElement(dep, "build-prerequisite", // NOI18N
99
                    NbModuleProject.NAMESPACE_SHARED) == null) {
100
                    NbModuleProject.NAMESPACE_SHARED) == null) {
100
                continue;
101
                continue;
101
            }
102
            }
102
             */
103
             */
103
            Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
104
            Element cnbEl = XMLUtil.findElement(dep, "code-name-base", // NOI18N
104
                NbModuleProject.NAMESPACE_SHARED);
105
                NbModuleProject.NAMESPACE_SHARED);
105
            String cnb = Util.findText(cnbEl);
106
            String cnb = XMLUtil.findText(cnbEl);
106
            ModuleEntry module = ml.getEntry(cnb);
107
            ModuleEntry module = ml.getEntry(cnb);
107
            if (module == null) {
108
            if (module == null) {
108
                Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + project);
109
                Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + project);
Lines 130-144 Link Here
130
            }
131
            }
131
        }
132
        }
132
        // #63824: consider also artifacts found in ${cp.extra} and/or <class-path-extension>s
133
        // #63824: consider also artifacts found in ${cp.extra} and/or <class-path-extension>s
133
        for (Element cpext : Util.findSubElements(data)) {
134
        for (Element cpext : XMLUtil.findSubElements(data)) {
134
            if (!cpext.getTagName().equals("class-path-extension")) { // NOI18N
135
            if (!cpext.getTagName().equals("class-path-extension")) { // NOI18N
135
                continue;
136
                continue;
136
            }
137
            }
137
            Element binorig = Util.findElement(cpext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
138
            Element binorig = XMLUtil.findElement(cpext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
138
            if (binorig == null) {
139
            if (binorig == null) {
139
                continue;
140
                continue;
140
            }
141
            }
141
            String text = Util.findText(binorig);
142
            String text = XMLUtil.findText(binorig);
142
            String eval = project.evaluator().evaluate(text);
143
            String eval = project.evaluator().evaluate(text);
143
            if (eval == null) {
144
            if (eval == null) {
144
                continue;
145
                continue;
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java (-2 / +3 lines)
Lines 89-94 Link Here
89
import org.openide.util.Lookup;
89
import org.openide.util.Lookup;
90
import org.openide.util.Mutex;
90
import org.openide.util.Mutex;
91
import org.openide.util.lookup.Lookups;
91
import org.openide.util.lookup.Lookups;
92
import org.openide.xml.XMLUtil;
92
import org.w3c.dom.Element;
93
import org.w3c.dom.Element;
93
94
94
/**
95
/**
Lines 242-249 Link Here
242
        }
243
        }
243
        
244
        
244
        private String getSimpleName() {
245
        private String getSimpleName() {
245
            Element nameEl = Util.findElement(helper.getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
246
            Element nameEl = XMLUtil.findElement(helper.getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
246
            String text = (nameEl != null) ? Util.findText(nameEl) : null;
247
            String text = (nameEl != null) ? XMLUtil.findText(nameEl) : null;
247
            return (text != null) ? text : "???"; // NOI18N
248
            return (text != null) ? text : "???"; // NOI18N
248
        }
249
        }
249
        
250
        
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/BasicBrandingModel.java (-3 / +3 lines)
Lines 55-61 Link Here
55
import org.netbeans.api.annotations.common.CheckForNull;
55
import org.netbeans.api.annotations.common.CheckForNull;
56
import org.netbeans.api.annotations.common.NullAllowed;
56
import org.netbeans.api.annotations.common.NullAllowed;
57
import org.netbeans.api.project.Project;
57
import org.netbeans.api.project.Project;
58
import org.netbeans.modules.apisupport.project.Util;
59
import org.netbeans.modules.apisupport.project.suite.BrandingSupport;
58
import org.netbeans.modules.apisupport.project.suite.BrandingSupport;
60
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BrandedFile;
59
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BrandedFile;
61
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BundleKey;
60
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BundleKey;
Lines 65-70 Link Here
65
import org.openide.filesystems.FileUtil;
64
import org.openide.filesystems.FileUtil;
66
import org.openide.util.ChangeSupport;
65
import org.openide.util.ChangeSupport;
67
import org.openide.util.NbBundle;
66
import org.openide.util.NbBundle;
67
import org.openide.xml.XMLUtil;
68
import org.w3c.dom.Element;
68
import org.w3c.dom.Element;
69
69
70
/**
70
/**
Lines 385-392 Link Here
385
                res = getProjectDirectoryFile().getName();
385
                res = getProjectDirectoryFile().getName();
386
            return res;
386
            return res;
387
        }
387
        }
388
        Element nameEl = Util.findElement(suiteProps.getProject().getHelper().getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
388
        Element nameEl = XMLUtil.findElement(suiteProps.getProject().getHelper().getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
389
        String text = (nameEl != null) ? Util.findText(nameEl) : null;
389
        String text = (nameEl != null) ? XMLUtil.findText(nameEl) : null;
390
        return (text != null) ? text : "???"; // NOI18N
390
        return (text != null) ? text : "???"; // NOI18N
391
    }
391
    }
392
392
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibraries.java (-9 / +9 lines)
Lines 1467-1489 Link Here
1467
            dependencies = new HashSet<Dependency>();
1467
            dependencies = new HashSet<Dependency>();
1468
            // Cannot use ProjectXMLManager since we need to report also deps on nonexistent modules.
1468
            // Cannot use ProjectXMLManager since we need to report also deps on nonexistent modules.
1469
            Element dataE = project.getPrimaryConfigurationData();
1469
            Element dataE = project.getPrimaryConfigurationData();
1470
            Element depsE = Util.findElement(dataE, "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1470
            Element depsE = XMLUtil.findElement(dataE, "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1471
            assert depsE != null : "Malformed metadata in " + project;
1471
            assert depsE != null : "Malformed metadata in " + project;
1472
            for (Element dep : Util.findSubElements(depsE)) {
1472
            for (Element dep : XMLUtil.findSubElements(depsE)) {
1473
                Element run = Util.findElement(dep, "run-dependency", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1473
                Element run = XMLUtil.findElement(dep, "run-dependency", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1474
                if (run == null) {
1474
                if (run == null) {
1475
                    continue;
1475
                    continue;
1476
                }
1476
                }
1477
                String text = Util.findText(Util.findElement(dep, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
1477
                String text = XMLUtil.findText(XMLUtil.findElement(dep, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
1478
                Element relverE = Util.findElement(run, "release-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1478
                Element relverE = XMLUtil.findElement(run, "release-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1479
                if (relverE != null) {
1479
                if (relverE != null) {
1480
                    text += '/' + Util.findText(relverE);
1480
                    text += '/' + XMLUtil.findText(relverE);
1481
                }
1481
                }
1482
                Element specverE = Util.findElement(run, "specification-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1482
                Element specverE = XMLUtil.findElement(run, "specification-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1483
                if (specverE != null) {
1483
                if (specverE != null) {
1484
                    text += " > " + Util.findText(specverE);
1484
                    text += " > " + XMLUtil.findText(specverE);
1485
                } else {
1485
                } else {
1486
                    Element implver = Util.findElement(run, "implementation-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1486
                    Element implver = XMLUtil.findElement(run, "implementation-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1487
                    if (implver != null) {
1487
                    if (implver != null) {
1488
                        // Will special-case '*' as an impl version to mean "match anything".
1488
                        // Will special-case '*' as an impl version to mean "match anything".
1489
                        text += " = *"; // NOI18N
1489
                        text += " = *"; // NOI18N
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/AbstractEntryWithSources.java (-5 / +6 lines)
Lines 54-59 Link Here
54
import org.openide.ErrorManager;
54
import org.openide.ErrorManager;
55
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileUtil;
56
import org.openide.filesystems.FileUtil;
57
import org.openide.xml.XMLUtil;
57
import org.w3c.dom.Element;
58
import org.w3c.dom.Element;
58
59
59
abstract class AbstractEntryWithSources extends AbstractEntry {
60
abstract class AbstractEntryWithSources extends AbstractEntry {
Lines 136-152 Link Here
136
            return new String[0];
137
            return new String[0];
137
        }
138
        }
138
        Element data = project.getPrimaryConfigurationData();
139
        Element data = project.getPrimaryConfigurationData();
139
        Element moduleDependencies = Util.findElement(data,
140
        Element moduleDependencies = XMLUtil.findElement(data,
140
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
141
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
141
        assert moduleDependencies != null : "Malformed metadata in " + project;
142
        assert moduleDependencies != null : "Malformed metadata in " + project;
142
        for (Element dep : Util.findSubElements(moduleDependencies)) {
143
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
143
            if (Util.findElement(dep, "run-dependency", // NOI18N
144
            if (XMLUtil.findElement(dep, "run-dependency", // NOI18N
144
                    NbModuleProject.NAMESPACE_SHARED) == null) {
145
                    NbModuleProject.NAMESPACE_SHARED) == null) {
145
                continue;
146
                continue;
146
            }
147
            }
147
            Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
148
            Element cnbEl = XMLUtil.findElement(dep, "code-name-base", // NOI18N
148
                NbModuleProject.NAMESPACE_SHARED);
149
                NbModuleProject.NAMESPACE_SHARED);
149
            String cnb = Util.findText(cnbEl);
150
            String cnb = XMLUtil.findText(cnbEl);
150
            deps.add(cnb);
151
            deps.add(cnb);
151
        }
152
        }
152
        return deps.toArray(new String[deps.size()]);
153
        return deps.toArray(new String[deps.size()]);
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java (-16 / +16 lines)
Lines 206-213 Link Here
206
        if (data == null) {
206
        if (data == null) {
207
            throw new IOException("Not an NBM project in " + basedir); // NOI18N
207
            throw new IOException("Not an NBM project in " + basedir); // NOI18N
208
        }
208
        }
209
        boolean suiteComponent = Util.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
209
        boolean suiteComponent = XMLUtil.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
210
        boolean standalone = Util.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
210
        boolean standalone = XMLUtil.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
211
        assert !(suiteComponent && standalone) : basedir;
211
        assert !(suiteComponent && standalone) : basedir;
212
        if (suiteComponent) {
212
        if (suiteComponent) {
213
            PropertyEvaluator eval = parseProperties(basedir, null, NbModuleType.SUITE_COMPONENT, "irrelevant"); // NOI18N
213
            PropertyEvaluator eval = parseProperties(basedir, null, NbModuleType.SUITE_COMPONENT, "irrelevant"); // NOI18N
Lines 598-620 Link Here
598
        }
598
        }
599
        assert root != null ^ type != NbModuleType.NETBEANS_ORG;
599
        assert root != null ^ type != NbModuleType.NETBEANS_ORG;
600
        assert path != null ^ type != NbModuleType.NETBEANS_ORG;
600
        assert path != null ^ type != NbModuleType.NETBEANS_ORG;
601
        String cnb = Util.findText(Util.findElement(data, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
601
        String cnb = XMLUtil.findText(XMLUtil.findElement(data, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
602
        PropertyEvaluator eval = parseProperties(basedir, root, type, cnb);
602
        PropertyEvaluator eval = parseProperties(basedir, root, type, cnb);
603
        String module = eval.getProperty("module.jar"); // NOI18N
603
        String module = eval.getProperty("module.jar"); // NOI18N
604
        // Cf. ParseProjectXml.computeClasspath:
604
        // Cf. ParseProjectXml.computeClasspath:
605
        StringBuffer cpextra = new StringBuffer();
605
        StringBuffer cpextra = new StringBuffer();
606
        for (Element ext : Util.findSubElements(data)) {
606
        for (Element ext : XMLUtil.findSubElements(data)) {
607
            if (!ext.getLocalName().equals("class-path-extension")) { // NOI18N
607
            if (!ext.getLocalName().equals("class-path-extension")) { // NOI18N
608
                continue;
608
                continue;
609
            }
609
            }
610
            Element binaryOrigin = Util.findElement(ext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
610
            Element binaryOrigin = XMLUtil.findElement(ext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
611
            String text;
611
            String text;
612
            if (binaryOrigin != null) {
612
            if (binaryOrigin != null) {
613
                text = Util.findText(binaryOrigin);
613
                text = XMLUtil.findText(binaryOrigin);
614
            } else {
614
            } else {
615
                Element runtimeRelativePath = Util.findElement(ext, "runtime-relative-path", NbModuleProject.NAMESPACE_SHARED); // NOI18N
615
                Element runtimeRelativePath = XMLUtil.findElement(ext, "runtime-relative-path", NbModuleProject.NAMESPACE_SHARED); // NOI18N
616
                assert runtimeRelativePath != null : "Malformed <class-path-extension> in " + basedir;
616
                assert runtimeRelativePath != null : "Malformed <class-path-extension> in " + basedir;
617
                String reltext = Util.findText(runtimeRelativePath);
617
                String reltext = XMLUtil.findText(runtimeRelativePath);
618
                // XXX assumes that module.jar is not overridden independently of module.jar.dir:
618
                // XXX assumes that module.jar is not overridden independently of module.jar.dir:
619
                text = "${cluster}/${module.jar.dir}/" + reltext; // NOI18N
619
                text = "${cluster}/${module.jar.dir}/" + reltext; // NOI18N
620
            }
620
            }
Lines 1034-1042 Link Here
1034
            } catch (SAXException e) {
1034
            } catch (SAXException e) {
1035
                throw (IOException) new IOException(e.toString()).initCause(e);
1035
                throw (IOException) new IOException(e.toString()).initCause(e);
1036
            }
1036
            }
1037
            for (Element moduleVersion : Util.findSubElements(doc.getDocumentElement())) {
1037
            for (Element moduleVersion : XMLUtil.findSubElements(doc.getDocumentElement())) {
1038
                if (moduleVersion.getTagName().equals("module_version") && moduleVersion.getAttribute("last").equals("true")) { // NOI18N
1038
                if (moduleVersion.getTagName().equals("module_version") && moduleVersion.getAttribute("last").equals("true")) { // NOI18N
1039
                    for (Element fileEl : Util.findSubElements(moduleVersion)) {
1039
                    for (Element fileEl : XMLUtil.findSubElements(moduleVersion)) {
1040
                        if (fileEl.getTagName().equals("file")) { // NOI18N
1040
                        if (fileEl.getTagName().equals("file")) { // NOI18N
1041
                            String name = fileEl.getAttribute("name"); // NOI18N
1041
                            String name = fileEl.getAttribute("name"); // NOI18N
1042
                            File f = new File(cluster, name.replace('/', File.separatorChar));
1042
                            File f = new File(cluster, name.replace('/', File.separatorChar));
Lines 1074-1091 Link Here
1074
            throw (IOException) new IOException(projectXml + ": " + e.toString()).initCause(e); // NOI18N
1074
            throw (IOException) new IOException(projectXml + ": " + e.toString()).initCause(e); // NOI18N
1075
        }
1075
        }
1076
        Element docel = doc.getDocumentElement();
1076
        Element docel = doc.getDocumentElement();
1077
        Element type = Util.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
1077
        Element type = XMLUtil.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
1078
        if (!Util.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
1078
        if (!XMLUtil.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
1079
            return null;
1079
            return null;
1080
        }
1080
        }
1081
        Element cfg = Util.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
1081
        Element cfg = XMLUtil.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
1082
        Element data = Util.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1082
        Element data = XMLUtil.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1083
        if (data != null) {
1083
        if (data != null) {
1084
            return data;
1084
            return data;
1085
        } else {
1085
        } else {
1086
            data = Util.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED_2); // NOI18N
1086
            data = XMLUtil.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED_2); // NOI18N
1087
            if (data != null) {
1087
            if (data != null) {
1088
                return Util.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
1088
                return XMLUtil.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
1089
            } else {
1089
            } else {
1090
                return null;
1090
                return null;
1091
            }
1091
            }
(-)a/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ProjectXMLManagerTest.java (-2 / +2 lines)
Lines 303-310 Link Here
303
                    Document doc = XMLUtil.parse(new InputSource(projectXML.toURI().toString()),
303
                    Document doc = XMLUtil.parse(new InputSource(projectXML.toURI().toString()),
304
                            false, true, null, null);
304
                            false, true, null, null);
305
                    Element project = doc.getDocumentElement();
305
                    Element project = doc.getDocumentElement();
306
                    Element config = Util.findElement(project, "configuration", null); // NOI18N
306
                    Element config = XMLUtil.findElement(project, "configuration", null); // NOI18N
307
                    data = Util.findElement(config, "data", NbModuleProject.NAMESPACE_SHARED);
307
                    data = XMLUtil.findElement(config, "data", NbModuleProject.NAMESPACE_SHARED);
308
                } catch (IOException e) {
308
                } catch (IOException e) {
309
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
309
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
310
                } catch (SAXException e) {
310
                } catch (SAXException e) {

Return to bug 136595