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


Java XMLUtil.findSubElements方法代码示例

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


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

示例1: targetUsesTaskExactlyOnce

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Check to see if a given Ant target uses a given task once (and only once).
 * @param target an Ant <code>&lt;target&gt;</code> element
 * @param taskName the (unqualified) name of an Ant task
 * @return a task element with that name, or null if there is none or more than one
 */
Element targetUsesTaskExactlyOnce(Element target, String taskName) {
    // XXX should maybe also look for any other usage of the task in the same script in case there is none in the mentioned target
    Element foundTask = null;
    for (Element task : XMLUtil.findSubElements(target)) {
        if (task.getLocalName().equals(taskName)) {
            if (foundTask != null) {
                // Duplicate.
                return null;
            } else {
                foundTask = task;
            }
        }
    }
    return foundTask;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JavaActions.java

示例2: setLibrariesLocation

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Stores given libraries location in given project.
 */
public static void setLibrariesLocation(AntProjectHelper helper, String librariesDefinition) {
    //TODO do we need to create new auxiliary configuration instance? feels like a hack, we should be
    // using the one from the project's lookup.  
    if (librariesDefinition == null) {
        helper.createAuxiliaryConfiguration().removeConfigurationFragment(EL_LIBRARIES, NAMESPACE, true);
        return;
    }
    Element libraries = helper.createAuxiliaryConfiguration().getConfigurationFragment(EL_LIBRARIES, NAMESPACE, true);
    if (libraries == null) {
        libraries = XMLUtil.createDocument("dummy", null, null, null).createElementNS(NAMESPACE, EL_LIBRARIES); // NOI18N
    } else {
        List<Element> elements = XMLUtil.findSubElements(libraries);
        if (elements.size() == 1) {
            libraries.removeChild(elements.get(0));
        }
    }
    libraries.appendChild(libraries.getOwnerDocument().createElementNS(NAMESPACE, EL_DEFINITIONS)).
        appendChild(libraries.getOwnerDocument().createTextNode(librariesDefinition));
    helper.createAuxiliaryConfiguration().putConfigurationFragment(libraries, true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ProjectLibraryProvider.java

示例3: 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

示例4: getDataFiles

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
public List<FileObject> getDataFiles() {
    Element genldata = project.getPrimaryConfigurationData();
    Element foldersEl = XMLUtil.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N
    List<Element> folders = foldersEl != null ? XMLUtil.findSubElements(foldersEl) : Collections.<Element>emptyList();
    List<FileObject> result = new ArrayList<FileObject>();

    for (Element el : folders) {
        if ("source-folder".equals(el.getLocalName()) && FreeformProjectType.NS_GENERAL.equals(el.getNamespaceURI())) { // NOI18N
            addFile(el, result);
        }
    }
    
    addFile(project.getProjectDirectory(), "build.xml", result); // NOI18N
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:FreeformProjectOperations.java

示例5: 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

示例6: compilationUnits

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private List<Element> compilationUnits() {
    Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
    if (java == null) {
        return Collections.emptyList();
    }
    return XMLUtil.findSubElements(java);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:JavaActions.java

示例7: parseJSFLibraryRegistryV2

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
void parseJSFLibraryRegistryV2() throws IOException {
    if (!workspace.getUserJSFLibraries().exists()) {
        return;
    }
    Document xml;
    try {
        xml = XMLUtil.parse(new InputSource(Utilities.toURI(workspace.getUserJSFLibraries()).toString()), false, true, XMLUtil.defaultErrorHandler(), null);
    } catch (SAXException e) {
        IOException ioe = (IOException) new IOException(workspace.getUserJSFLibraries() + ": " + e.toString()).initCause(e); // NOI18N
        throw ioe;
    }
    
    Element root = xml.getDocumentElement();
    if (!"JSFLibraryRegistry".equals(root.getLocalName()) || // NOI18N
        !JSF_LIB_NS.equals(root.getNamespaceURI())) {
        return;
    }
    for (Element el : XMLUtil.findSubElements(root)) {
        String libraryName = el.getAttribute("Name"); // NOI18N
        List<String> jars = new ArrayList<String>();
        for (Element file : XMLUtil.findSubElements(el)) {
            String path = file.getAttribute("SourceLocation"); // NOI18N
            if (!"false".equals(file.getAttribute("RelativeToWorkspace"))) { // NOI18N
                path = new File(workspace.getDirectory(), path).getPath();
            }
            jars.add(path);
        }
        // TODO: in Ganymede Javadoc/sources customization does not seem to be persisted. eclipse defect??
        workspace.addUserLibrary(libraryName, jars, null, null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:WorkspaceParser.java

示例8: namesOfChildren

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private static String namesOfChildren(Element e) {
    StringBuilder b = new StringBuilder();
    for (Element kid : XMLUtil.findSubElements(e)) {
        if (b.length() > 0) {
            b.append(' ');
        }
        b.append(kid.getLocalName());
        String ns = kid.getNamespaceURI();
        b.append(ns.charAt(ns.length() - 1));
    }
    return b.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:AntBasedProjectFactorySingletonTest.java

示例9: getClassPathExtensions

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Returns existing classpath extensions mapping.
 * Returned map is unmodifiable.
 * @return classpath extensions map &lt;key=runtime-path(String), value=binary-path(String or null)&gt;
 */
public Map<String, String> getClassPathExtensions() {
    if (cpExtensions != null) {
        return Collections.unmodifiableMap(cpExtensions);
    }
    Map<String, String> cps = new HashMap<String, String>();
    for (Element cpExtEl : XMLUtil.findSubElements(getConfData())) {
        if (CLASS_PATH_EXTENSION.equals(cpExtEl.getTagName())) {
            Element binOrigEl = findElement(cpExtEl, BINARY_ORIGIN);
            Element runtimePathEl = findElement(cpExtEl, CLASS_PATH_RUNTIME_PATH);
            cps.put(XMLUtil.findText(runtimePathEl), binOrigEl != null ? XMLUtil.findText(binOrigEl) : null);
        }
    }
    return Collections.unmodifiableMap(cpExtensions = cps);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ProjectXMLManager.java

示例10: findFriends

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/** Utility method for finding friend. */
public static String[] findFriends(final Element confData) {
    Element friendsEl = findFriendsElement(confData);
    if (friendsEl != null) {
        Set<String> friends = new TreeSet<String>();
        for (Element friendEl : XMLUtil.findSubElements(friendsEl)) {
            if (FRIEND.equals(friendEl.getTagName())) {
                friends.add(XMLUtil.findText(friendEl));
            }
        }
        return friends.toArray(new String[friends.size()]);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ProjectXMLManager.java

示例11: 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

示例12: findBinaryNBMFiles

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Try to find which files are part of a module's binary build (i.e. slated for NBM).
 * Tries to scan update tracking for the file, but also always adds in the module JAR
 * as a fallback (since this is the most important file for various purposes).
 * Note that update_tracking/*.xml is added as well as files it lists.
 */
private static Set<File> findBinaryNBMFiles(File cluster, String cnb, File jar) throws IOException {
    Set<File> files = new HashSet<File>();
    files.add(jar);
    File tracking = new File(new File(cluster, "update_tracking"), cnb.replace('.', '-') + ".xml"); // NOI18N
    if (tracking.isFile()) {
        files.add(tracking);
        Document doc;
        try {
            xmlFilesParsed++;
            timeSpentInXmlParsing -= System.currentTimeMillis();
            doc = XMLUtil.parse(new InputSource(Utilities.toURI(tracking).toString()), false, false, null, null);
            timeSpentInXmlParsing += System.currentTimeMillis();
        } catch (SAXException e) {
            throw (IOException) new IOException(e.toString()).initCause(e);
        }
        for (Element moduleVersion : XMLUtil.findSubElements(doc.getDocumentElement())) {
            if (moduleVersion.getTagName().equals("module_version") && moduleVersion.getAttribute("last").equals("true")) { // NOI18N
                for (Element fileEl : XMLUtil.findSubElements(moduleVersion)) {
                    if (fileEl.getTagName().equals("file")) { // NOI18N
                        String name = fileEl.getAttribute("name"); // NOI18N
                        File f = new File(cluster, name.replace('/', File.separatorChar));
                        if (f.isFile()) {
                            files.add(f);
                        }
                    }
                }
            }
        }
    }
    return files;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:ModuleList.java

示例13: rebindAction

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private void rebindAction(Element actionE, Element projectE, Set<String> targetsCreated) {
    Element scriptE = XMLUtil.findElement(actionE, "script", Util.NAMESPACE); // NOI18N
    String script;
    if (scriptE != null) {
        script = XMLUtil.findText(scriptE);
        actionE.removeChild(scriptE);
    } else {
        script = "build.xml"; // NOI18N
    }
    scriptE = actionE.getOwnerDocument().createElementNS(Util.NAMESPACE, "script"); // NOI18N
    scriptE.appendChild(actionE.getOwnerDocument().createTextNode(NBJDK_XML));
    actionE.insertBefore(scriptE, actionE.getFirstChild());
    List<String> targetNames = new ArrayList<String>();
    for (Element targetE : XMLUtil.findSubElements(actionE)) {
        if (!targetE.getLocalName().equals("target")) { // NOI18N
            continue;
        }
        targetNames.add(XMLUtil.findText(targetE));
    }
    if (targetNames.isEmpty()) {
        targetNames.add(null);
    }
    String scriptPath = evaluator.evaluate(script);
    for (String target : targetNames) {
        if (targetsCreated.add(target)) {
            createOverride(projectE, target, scriptPath);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:JdkConfiguration.java

示例14: annotationProcessingEnabled

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
public @Override Set<? extends Trigger> annotationProcessingEnabled() {
    Set<Trigger> result = triggerCache;
    if (result != null) {
        return result;
    }
    result = EnumSet.noneOf(Trigger.class);
    if (ap != null) {
        for (Element e : XMLUtil.findSubElements(ap)) {
            if (e.getLocalName().equals(EL_SCAN_TRIGGER)) {
                result.add(Trigger.ON_SCAN);
            } else if (e.getLocalName().equals(EL_EDITOR_TRIGGER)) {
                result.add(Trigger.IN_EDITOR);
            }
        }
    }
    if (result.size() == 1 && result.contains(Trigger.IN_EDITOR)) {
        //Contains only editor-trigger
        //Add required scan-trigger and log
        result.add(Trigger.ON_SCAN);
        LOG.log(
            Level.WARNING, 
            "Project {0} project.xml contains annotation processing editor-trigger only. The scan-trigger is required as well, adding it into the APQ.Result.", //NOI18N
            FileUtil.getFileDisplayName(helper.getProjectDirectory()));
    }
    synchronized (LCK) {
        if (triggerCache == null) {
            triggerCache = result;
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:AnnotationProcessingQueryImpl.java

示例15: findCUClasspath

import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
 * Try to find the compile-time classpath corresponding to a source root.
 * @param sources a source root in the project (as a virtual Ant name)
 * @return the classpath (in Ant form), or null if none was specified or there was no such source root
 */
String findCUClasspath(String sources, String moud) {
    Element compilationUnitEl = findCompilationUnit(sources);
    if (compilationUnitEl != null) {
        for (Element classpath : XMLUtil.findSubElements(compilationUnitEl)) {
            if (classpath.getLocalName().equals("classpath")) { // NOI18N
                String mode = classpath.getAttribute("mode"); // NOI18N
                if (mode.equals(moud)) {
                    return XMLUtil.findText(classpath);
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:JavaActions.java


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