当前位置: 首页>>代码示例>>Java>>正文


Java XMLUtil.findText方法代码示例

本文整理汇总了Java中org.openide.xml.XMLUtil.findText方法的典型用法代码示例。如果您正苦于以下问题:Java XMLUtil.findText方法的具体用法?Java XMLUtil.findText怎么用?Java XMLUtil.findText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.xml.XMLUtil的用法示例。


在下文中一共展示了XMLUtil.findText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findBinaries

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Find a list of URLs of binaries which will be produced from a compilation unit.
 * Result may be empty.
 */
private List<URL> findBinaries(Element compilationUnitEl) {
    List<URL> binaries = new ArrayList<URL>();
    for (Element builtToEl : XMLUtil.findSubElements(compilationUnitEl)) {
        if (!builtToEl.getLocalName().equals("built-to")) { // NOI18N
            continue;
        }
        String text = XMLUtil.findText(builtToEl);
        String textEval = evaluator.evaluate(text);
        if (textEval == null) {
            continue;
        }
        File buildProduct = helper.resolveFile(textEval);
        URL buildProductURL = FileUtil.urlForArchiveOrDir(buildProduct);
        binaries.add(buildProductURL);
    }
    return binaries;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SourceForBinaryQueryImpl.java

示例2: findClassesOutputDir

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Find output classes given a compilation unit from project.xml.
 */
private String findClassesOutputDir(Element compilationUnitEl) {
    // Look for an appropriate <built-to>.
    for (Element builtTo : XMLUtil.findSubElements(compilationUnitEl)) {
        if (builtTo.getLocalName().equals("built-to")) { // NOI18N
            String rawtext = XMLUtil.findText(builtTo);
            // Check that it is not an archive.
            String evaltext = evaluator.evaluate(rawtext);
            if (evaltext != null) {
                File dest = helper.resolveFile(evaltext);
                URL destU;
                try {
                    destU = Utilities.toURI(dest).toURL();
                } catch (MalformedURLException e) {
                    throw new AssertionError(e);
                }
                if (!FileUtil.isArchiveFile(destU)) {
                    // OK, dir, take it.
                    return rawtext;
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:JavaActions.java

示例3: removeDependenciesByCNB

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Use this for removing more than one dependencies. It's faster then
 * iterating and using <code>removeDependency</code> for every entry.
 */
public void removeDependenciesByCNB(Collection<String> cnbsToDelete) {
    Element _confData = getConfData();
    Element moduleDependencies = findModuleDependencies(_confData);
    for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
        Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
        String _cnb = XMLUtil.findText(cnbEl);
        if (cnbsToDelete.remove(_cnb)) {
            moduleDependencies.removeChild(dep);
        }
        if (cnbsToDelete.size() == 0) {
            break; // everything was deleted
        }
    }
    if (cnbsToDelete.size() != 0) {
        Util.err.log(ErrorManager.WARNING,
                "Some modules weren't deleted: " + cnbsToDelete); // NOI18N
    }
    project.putPrimaryConfigurationData(_confData);
    directDeps = null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ProjectXMLManager.java

示例4: parseCNB

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private String parseCNB(final ZipEntry projectXML) throws IOException {
    Document doc;
    InputStream is = nbSrcZip.getInputStream(projectXML);
    try {
        doc = XMLUtil.parse(new InputSource(is), false, true, null, null);
    } catch (SAXException e) {
        throw (IOException) new IOException(projectXML + ": " + e.toString()).initCause(e); // NOI18N
    } finally {
        is.close();
    }
    Element docel = doc.getDocumentElement();
    Element type = XMLUtil.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
    String cnb = null;
    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 = XMLUtil.findText(XMLUtil.findElement(data, "code-name-base", null)); // NOI18N
        }
    }
    return cnb;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:GlobalSourceForBinaryImpl.java

示例5: getExtraCompilationUnits

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Find marked extra compilation units.
 * Gives a map from the package root to the defining XML element.
 */
public Map<FileObject,Element> getExtraCompilationUnits() {
    if (extraCompilationUnits == null) {
        extraCompilationUnits = new HashMap<FileObject,Element>();
        for (Element ecu : XMLUtil.findSubElements(getPrimaryConfigurationData())) {
            if (ecu.getLocalName().equals("extra-compilation-unit")) { // NOI18N
                Element pkgrootEl = XMLUtil.findElement(ecu, "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
                String pkgrootS = XMLUtil.findText(pkgrootEl);
                String pkgrootEval = evaluator().evaluate(pkgrootS);
                FileObject pkgroot = pkgrootEval != null ? getHelper().resolveFileObject(pkgrootEval) : null;
                if (pkgroot == null) {
                    Util.err.log(ErrorManager.WARNING, "Could not find package-root " + pkgrootEval + " for " + getCodeNameBase());
                    continue;
                }
                extraCompilationUnits.put(pkgroot, ecu);
            }
        }
    }
    return extraCompilationUnits;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:NbModuleProject.java

示例6: getModuleDependency

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private ModuleDependency getModuleDependency(String cnb, ModuleList ml, Element depEl) {
    ModuleEntry me = ml.getEntry(cnb);
    if (me == null) {
        // XXX might be e.g. shown in nb.errorForreground and "disabled"
        Util.err.log(ErrorManager.WARNING,
                "Detected dependency on module which cannot be found in " + // NOI18N
                "the current module's universe (platform, suite): " + cnb); // NOI18N
        me = new NonexistentModuleEntry(cnb);
    }
    String relVer = null;
    String specVer = null;
    boolean implDep = false;
    Element runDepEl = findElement(depEl, ProjectXMLManager.RUN_DEPENDENCY);
    if (runDepEl != null) {
        Element relVerEl = findElement(runDepEl, ProjectXMLManager.RELEASE_VERSION);
        if (relVerEl != null) {
            relVer = XMLUtil.findText(relVerEl);
        }
        Element specVerEl = findElement(runDepEl, ProjectXMLManager.SPECIFICATION_VERSION);
        if (specVerEl != null) {
            specVer = XMLUtil.findText(specVerEl);
        }
        implDep = findElement(runDepEl, ProjectXMLManager.IMPLEMENTATION_VERSION) != null;
    }
    Element compDepEl = findElement(depEl, ProjectXMLManager.COMPILE_DEPENDENCY);
    ModuleDependency newDep = new ModuleDependency(
            me, relVer, specVer, compDepEl != null, implDep);
    newDep.buildPrerequisite = findElement(depEl, ProjectXMLManager.BUILD_PREREQUISITE) != null;
    newDep.runDependency = runDepEl != null;
    return newDep;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ProjectXMLManager.java

示例7: removeDependency

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/** Remove given dependency from the configuration data. */
public void removeDependency(String cnbToRemove) {
    Element _confData = getConfData();
    Element moduleDependencies = findModuleDependencies(_confData);
    for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
        Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
        String _cnb = XMLUtil.findText(cnbEl);
        if (cnbToRemove.equals(_cnb)) {
            moduleDependencies.removeChild(dep);
        }
    }
    project.putPrimaryConfigurationData(_confData);
    directDeps = null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ProjectXMLManager.java

示例8: removeTestDependency

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Removes test dependency under type <code>testType</code>, indentified
 * by <code>cnbToRemove</code>. Does not remove whole test type even if
 * removed test dependency was the last one.
 */
public boolean removeTestDependency(String testType, String cnbToRemove) {
    boolean wasRemoved = false;
    Element _confData = getConfData();
    Element testModuleDependenciesEl = findTestDependenciesElement(_confData);
    Element testTypeRemoveEl = null;
    for (Element type : XMLUtil.findSubElements(testModuleDependenciesEl)) {
        Element nameEl = findElement(type, TEST_TYPE_NAME);
        String nameOfType = XMLUtil.findText(nameEl);
        if (testType.equals(nameOfType)) {
            testTypeRemoveEl = type;
        }
    }
    //found such a test type
    if (testTypeRemoveEl != null) {
        for (Element el : XMLUtil.findSubElements(testTypeRemoveEl)) {
            Element cnbEl = findElement(el, TEST_DEPENDENCY_CNB);
            if (cnbEl == null) {
                continue;   //name node, continue
            }
            String _cnb = XMLUtil.findText(cnbEl);
            if (cnbToRemove.equals(_cnb)) {
                // found test dependency with desired CNB
                testTypeRemoveEl.removeChild(el);
                wasRemoved = true;
                project.putPrimaryConfigurationData(_confData);
            }
        }
    }
    return wasRemoved;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ProjectXMLManager.java

示例9: isProject2

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
public @Override Result isProject2(FileObject projectDirectory) {
    if (FileUtil.toFile(projectDirectory) == null) {
        return null;
    }
    FileObject projectFile = projectDirectory.getFileObject(PROJECT_XML_PATH);
    //#54488: Added check for virtual
    if (projectFile == null || !projectFile.isData() || projectFile.isVirtual()) {
        return null;
    }
    File projectDiskFile = FileUtil.toFile(projectFile);
    //#63834: if projectFile exists and projectDiskFile does not, do nothing:
    if (projectDiskFile == null) {
        return null;
    }
    try {
        Document projectXml = loadProjectXml(projectDiskFile);
        if (projectXml != null) {
            Element typeEl = XMLUtil.findElement(projectXml.getDocumentElement(), "type", PROJECT_NS); // NOI18N
            if (typeEl != null) {
                String type = XMLUtil.findText(typeEl);
                if (type != null) {
                    AntBasedProjectType provider = findAntBasedProjectType(type);
                    if (provider != null) {
                        if (provider instanceof AntBasedGenericType) {
                            return new ProjectManager.Result(((AntBasedGenericType)provider).getIcon());
                        } else {
                            //put special icon?
                            return new ProjectManager.Result(null);
                        }
                    }
                }
            }
        }
    } catch (IOException ex) {
        LOG.log(Level.FINE, "Failed to load the project.xml file.", ex);
    }
    // better have false positives than false negatives (according to the ProjectManager.isProject/isProject2 javadoc.
    return new ProjectManager.Result(null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:AntBasedProjectFactorySingleton.java

示例10: isPubliclyAccessible

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
@SuppressWarnings("NP_BOOLEAN_RETURN_NULL")
  @Override public @CheckForNull Boolean isPubliclyAccessible(@NonNull FileObject pkg) {
    FileObject srcdir = project.getSourceDirectory();
    if (srcdir != null) {
        String path = FileUtil.getRelativePath(srcdir, pkg);
        if (path != null) {
            String name = path.replace('/', '.');
            Element config = project.getPrimaryConfigurationData();
            Element pubPkgs = XMLUtil.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
            if (pubPkgs == null) {
                // Try <friend-packages> too.
                pubPkgs = XMLUtil.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
            }
            if (pubPkgs != null) {
                for (Element pubPkg : XMLUtil.findSubElements(pubPkgs)) {
                    boolean sub = "subpackages".equals(pubPkg.getLocalName()); // NOI18N
                    String pubPkgS = XMLUtil.findText(pubPkg);
                    if (name.equals(pubPkgS) || (sub && name.startsWith(pubPkgS + '.'))) {
                        return true;
                    }
                }
                // Everything else assumed to *not* be public.
                return false;
            } else {
                Util.err.log(ErrorManager.WARNING, "Invalid project.xml for " + project);
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:AccessibilityQueryImpl.java

示例11: getLevel

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Get the source level indicated in a compilation unit (or null if none is indicated).
 */
private String getLevel(Element compilationUnitEl) {
    Element sourceLevelEl = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_LASTEST);
    if (sourceLevelEl != null) {
        return XMLUtil.findText(sourceLevelEl);
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:SourceLevelQueryImpl.java

示例12: getText

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private String getText(String elementName) {
    Element data = helper.getPrimaryConfigurationData(true);
    Element el = XMLUtil.findElement(data, elementName, "urn:test:shared");
    if (el != null) {
        String text = XMLUtil.findText(el);
        if (text != null) {
            return text;
        }
    }
    // Some kind of fallback here.
    return getProjectDirectory().getNameExt();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:AntBasedTestUtil.java

示例13: getValue

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
public Object getValue(String key) {
    if (key.equals(Action.NAME)) {
        Element labelEl = XMLUtil.findElement(actionEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
        return XMLUtil.findText(labelEl);
    } else {
        return super.getValue(key);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:Actions.java

示例14: isEnabled

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
public boolean isEnabled() {
    String script;
    Element scriptEl = XMLUtil.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
    if (scriptEl != null) {
        script = XMLUtil.findText(scriptEl);
    } else {
        script = "build.xml"; // NOI18N
    }
    String scriptLocation = p.evaluator().evaluate(script);
    return p.helper().resolveFileObject(scriptLocation) != null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:Actions.java

示例15: computeMatcher

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private boolean computeMatcher() {
    String incl = null;
    String excl = null;
    URI rootURI = URI.create(root.toExternalForm());
    // Annoying to duplicate logic from FreeformSources.
    // But using SourceGroup.contains is not an option since that requires FileObject creation.
    File rootFolder;
    try {
        rootFolder = Utilities.toFile(rootURI);
    } catch (IllegalArgumentException x) {
        Logger.getLogger(Classpaths.class.getName()).warning("Illegal source root: " + rootURI);
        rootFolder = null;
    }
    Element genldata = Util.getPrimaryConfigurationData(helper);
    Element foldersE = XMLUtil.findElement(genldata, "folders", Util.NAMESPACE); // NOI18N
    if (foldersE != null) {
        for (Element folderE : XMLUtil.findSubElements(foldersE)) {
            if (folderE.getLocalName().equals("source-folder")) {
                Element typeE = XMLUtil.findElement(folderE, "type", Util.NAMESPACE); // NOI18N
                if (typeE != null) {
                    String type = XMLUtil.findText(typeE);
                    if (type.equals(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
                        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 = XMLUtil.findElement(folderE, "includes", Util.NAMESPACE); // NOI18N
                            if (includesE != null) {
                                incl = evaluator.evaluate(XMLUtil.findText(includesE));
                                if (incl != null && incl.matches("\\$\\{[^}]+\\}")) { // NOI18N
                                    // Clearly intended to mean "include everything".
                                    incl = null;
                                }
                            }
                            Element excludesE = XMLUtil.findElement(folderE, "excludes", Util.NAMESPACE); // NOI18N
                            if (excludesE != null) {
                                excl = evaluator.evaluate(XMLUtil.findText(excludesE));
                            }
                        }
                    }
                }
            }
        }
    }
    if (!Utilities.compareObjects(incl, includes) || !Utilities.compareObjects(excl, excludes)) {
        includes = incl;
        excludes = excl;
        matcher = new PathMatcher(incl, excl, rootFolder);
        return true;
    } else {
        if (matcher == null) {
            matcher = new PathMatcher(incl, excl, rootFolder);
        }
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:56,代码来源:Classpaths.java


注:本文中的org.openide.xml.XMLUtil.findText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。