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


Java ClassPath.entries方法代码示例

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


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

示例1: testDeadLock

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
public void testDeadLock() throws Exception{
    List<PathResourceImplementation> resources = Collections.<PathResourceImplementation>emptyList();
    final ReentrantLock lock = new ReentrantLock (false);
    final CountDownLatch signal = new CountDownLatch (1);
    final ClassPath cp = ClassPathFactory.createClassPath(ClassPathSupport.createProxyClassPathImplementation(new ClassPathImplementation[] {new LockClassPathImplementation (resources,lock, signal)}));
    lock.lock();
    final ExecutorService es = Executors.newSingleThreadExecutor();        
    try {
        es.submit(new Runnable () {
            public void run () {
                cp.entries();
            }
        });
        signal.await();
        cp.entries();
    } finally {
        es.shutdownNow();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ProxyClassPathImplementationTest.java

示例2: createResult

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@CheckForNull
private R createResult(
        @NonNull final URL artifact,
        @NonNull final MultiModule modules,
        @NonNull final String[] templates) {
    for (String moduleName : modules.getModuleNames()) {
        final ClassPath scp = modules.getModuleSources(moduleName);
        if (scp != null) {
            for (ClassPath.Entry e : scp.entries()) {
                if (artifact.equals(e.getURL())) {
                    return new R(
                            artifact,
                            modules,
                            moduleName,
                            templates);
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MultiModuleBinaryForSourceQueryImpl.java

示例3: getFileFromClasspath

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private static FileObject getFileFromClasspath(ClassPath cp, String classRelativePath) {
    for (ClassPath.Entry entry : cp.entries()) {
        FileObject roots[];
        if (entry.isValid()) {
            roots = new FileObject[]{entry.getRoot()};
        } else {
            SourceForBinaryQuery.Result res = SourceForBinaryQuery.findSourceRoots(entry.getURL());
            roots = res.getRoots();
        }
        for (FileObject root : roots) {
            FileObject metaInf = root.getFileObject(classRelativePath);
            if (metaInf != null) {
                return metaInf;
            }
        }
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:SpringBeanImpl.java

示例4: doClean

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private static void doClean(ClassPath exec) throws IOException {
    for (ClassPath.Entry entry : exec.entries()) {
        SourceForBinaryQuery.Result2 r = SourceForBinaryQuery.findSourceRoots2(entry.getURL());

        if (r.preferSources() && r.getRoots().length > 0) {
            for (FileObject source : r.getRoots()) {
                File sourceFile = FileUtil.toFile(source);

                if (sourceFile == null) {
                    LOG.log(Level.WARNING, "Source URL: {0} cannot be translated to file, skipped", source.getURL().toExternalForm());
                    continue;
                }

                BuildArtifactMapperImpl.clean(Utilities.toURI(sourceFile).toURL());
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ProjectRunnerImpl.java

示例5: getResources

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@Override
@NonNull
public List<? extends PathResourceImplementation> getResources() {
    List<PathResourceImplementation> res;
    synchronized (this) {
        res = cache;
    }
    if (res == null) {
        final ClassPath cp = getActiveClassPath();
        final List<ClassPath.Entry> entries = cp.entries();
        res = new ArrayList<>(entries.size());
        for (ClassPath.Entry entry : entries) {
            res.add(org.netbeans.spi.java.classpath.support.ClassPathSupport.createResource(entry.getURL()));
        }
        synchronized (this) {
            if (cache == null) {
                cache = Collections.unmodifiableList(res);
            } else {
                res = cache;
            }
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:MuxClassPathImplementation.java

示例6: toURIs

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@CheckForNull
private static URI[] toURIs(@NullAllowed final ClassPath cp) {
    if (cp == null) {
        return null;
    }
    final List<ClassPath.Entry> entries = cp.entries();
    final List<URI> roots = new ArrayList<>(entries.size());
    for (ClassPath.Entry entry : entries) {
        try {
            roots.add(entry.getURL().toURI());
        } catch (URISyntaxException ex) {
            log.log(
                Level.INFO,
                "Cannot convert {0} to URI.",   //NOI18N
                entry.getURL());
        }
    }
    return roots.toArray(new URI[roots.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ClasspathInfo.java

示例7: testCompileClassPathWithModuleInfo

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
public void testCompileClassPathWithModuleInfo() throws Exception {
    if (systemModules == null) {
        System.out.println("No jdk 9 home configured.");    //NOI18N
        return;
    }
    TestFileUtils.writeFile(d,
            "pom.xml",
            "<project xmlns='http://maven.apache.org/POM/4.0.0'>" +
            "<modelVersion>4.0.0</modelVersion>" +
            "<groupId>grp</groupId>" +
            "<artifactId>art</artifactId>" +
            "<packaging>jar</packaging>" +
            "<version>1.0-SNAPSHOT</version>" +
            "<name>Test</name>" +
            "</project>");
    FileObject src = FileUtil.createFolder(d, "src/main/java");
    FileObject mi = FileUtil.createData(src, "module-info.java");
    ClassPath cp = ClassPath.getClassPath(src, JavaClassPathConstants.MODULE_COMPILE_PATH);
    assertNotNull(cp);
    List<ClassPath.Entry> entries = cp.entries();
    assertFalse(entries.isEmpty());
    assertRoots(entries, "target/classes");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ClassPathProviderImplTest.java

示例8: testWSClientSupport

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
public void testWSClientSupport () throws Exception {
    ClassPathProviderImpl cpProvider = pp.getClassPathProvider();
    ClassPath[] cps = cpProvider.getProjectClassPaths(ClassPath.SOURCE);
    ClassPath cp = cps[0];
    List<ClassPath.Entry> entries = cp.entries();
    assertNotNull ("Entries can not be null", entries);
    assertEquals ("There must be 3 src entries",1, entries.size());
    assertEquals("There must be src root", entries.get(0).getRoot(), sources);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:SourcePathImplementationTest.java

示例9: readRoots

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private static Set<URL> readRoots(
        JavadocRegistry jdr,
        Set<ClassPath> classpaths,
        Set<JavadocForBinaryQuery.Result> results) {
    
    Set<URL> roots = new HashSet<URL>();
    List<ClassPath> paths = new LinkedList<ClassPath>();
    paths.addAll( jdr.regs.getPaths( ClassPath.COMPILE ) );        
    paths.addAll( jdr.regs.getPaths( ClassPath.BOOT ) );
    for (ClassPath ccp : paths) {
        classpaths.add (ccp);
        //System.out.println("CCP " + ccp );
        for (ClassPath.Entry ccpRoot : ccp.entries()) {
            //System.out.println(" CCPR " + ccpRoot.getURL());
            JavadocForBinaryQuery.Result result = JavadocForBinaryQuery.findJavadoc(ccpRoot.getURL());
            results.add (result);
            URL[] jdRoots = result.getRoots();
            for (URL jdRoot : jdRoots) {
                if(verify(jdRoot)) {
                    roots.add(jdRoot);
                }
            }
        }
    }
    //System.out.println("roots=" + roots);
    return roots;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:JavadocRegistry.java

示例10: urlsOfCp

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private Set<String> urlsOfCp(ClassPath cp) {
    Set<String> s = new TreeSet<String>();
    for (ClassPath.Entry entry : cp.entries()) {
        s.add(entry.getURL().toExternalForm());
    }
    return s;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ClassPathProviderImplTest.java

示例11: testPatchModuleWithSourcePatch_UnscannedBaseModule

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
public void testPatchModuleWithSourcePatch_UnscannedBaseModule() throws Exception {
    if (systemModules == null) {
        System.out.println("No jdk 9 home configured.");    //NOI18N
        return;
    }
    assertNotNull(tp);
    assertNotNull(src);
    createModuleInfo(src, "Modle", "java.logging"); //NOI18N
    final FileObject tests = tp.getProjectDirectory().createFolder("tests");
    final ClassPath testSourcePath = org.netbeans.spi.java.classpath.support.ClassPathSupport.createClassPath(tests);
    final URL dist = BinaryForSourceQuery.findBinaryRoots(src.entries().get(0).getURL()).getRoots()[1];
    final ClassPath userModules = org.netbeans.spi.java.classpath.support.ClassPathSupport.createClassPath(dist);
    MockCompilerOptions.getInstance().forRoot(tests)
            .apply("--patch-module")    //NOI18N
            .apply(String.format("Modle=%s", FileUtil.toFile(tests).getAbsolutePath())) //NOI18N
            .apply("--add-modules") //NOI18N
            .apply("Modle") //NOI18N
            .apply("--add-reads")   //NOI18N
            .apply("Modle=ALL-UNNAMED"); //NOI18N
    final ClassPath cp = ClassPathFactory.createClassPath(ModuleClassPaths.createModuleInfoBasedPath(
            userModules,
            testSourcePath,
            systemModules,
            userModules,
            ClassPath.EMPTY,
            null));
    cp.entries();
    assertEquals(
            Collections.singletonList(dist),
            collectEntries(cp));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ModuleClassPathsTest.java

示例12: findFiles

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private static Collection<? extends FileObject> findFiles(ClassPath cp) {
    List<FileObject> roots = new ArrayList<>();

    for (Entry binaryEntry : cp.entries()) {
        Result2 sources = SourceForBinaryQuery.findSourceRoots2(binaryEntry.getURL());

        if (sources.preferSources()) {
            roots.addAll(Arrays.asList(sources.getRoots()));
        } else {
            FileObject binaryRoot = binaryEntry.getRoot();

            if (binaryRoot != null)
                roots.add(binaryRoot);
        }
    }

    List<FileObject> result = new LinkedList<>();

    for (FileObject root : roots) {
        FileObject folder = root.getFileObject("META-INF/upgrade");

        if (folder != null) {
            result.addAll(findFiles(folder));
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:DeclarativeHintRegistry.java

示例13: collectRoots

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private static void collectRoots (
        @NonNull final MultiModule modules,
        @NonNull final String buildDirProp,
        @NonNull final List<? super String> from,
        @NonNull final List<? super String> to,
        @NonNull final Set<? super ClassPath> cps) {
    for (String moduleName : modules.getModuleNames()) {
        final String dest = String.format(
                "${%s}/%s/*.class", //NOI18N
                buildDirProp,
                moduleName);
        final ClassPath scp = modules.getModuleSources(moduleName);
        if (scp != null) {
            for (ClassPath.Entry e : scp.entries()) {
                try {
                    final File f = BaseUtilities.toFile(e.getURL().toURI());
                    String source = String.format(
                            "%s/*.java",       //NOI18N
                            f.getAbsolutePath());
                    from.add(source);
                    to.add(dest);
                } catch (IllegalArgumentException | URISyntaxException exc) {
                    LOG.log(
                            Level.WARNING,
                            "Cannot convert source root: {0} to file.", //NOI18N
                            e.getURL());
                }
            }
            cps.add(scp);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:MultiModuleFileBuiltQueryImpl.java

示例14: merge

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@SuppressWarnings("CollectionContainsUrl")
public static ClassPath merge(final ClassPath... cps) {
    final Set<URL> roots = new LinkedHashSet<URL>(cps.length);
    for (final ClassPath cp : cps) {
        if (cp != null) {
            for (final ClassPath.Entry entry : cp.entries()) {
                final URL root = entry.getURL();
                if (!roots.contains(root)) {
                    roots.add(root);
                }
            }
        }
    }
    return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:RefactoringUtils.java

示例15: createResources

import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private List<PathResourceImplementation> createResources(
        @NonNull final Collection<? super BinaryForSourceQuery.Result> results,
        @NonNull final Collection<? super ClassPath> sourcePaths,
        @NonNull final Collection<? super File> moduleInfos) {
    final Set<URL> binaries = new LinkedHashSet<>();
    for (String moduleName : model.getModuleNames()) {
        final ClassPath scp = model.getModuleSources(moduleName);
        if (scp != null) {
            sourcePaths.add(scp);
            final Consumer<URL> consummer = !requiresModuleInfo || scp.findResource(MODULE_INFO_JAVA) != null ?
                    (u) -> {
                        final BinaryForSourceQuery.Result r = BinaryForSourceQuery.findBinaryRoots(u);
                        results.add(r);
                        binaries.addAll(filterArtefact(archives, r.getRoots()));
                    }:
                    (u) -> {};
                for (ClassPath.Entry e : scp.entries()) {
                    try {
                        final URL url = e.getURL();
                        consummer.accept(url);
                        Optional.ofNullable(requiresModuleInfo ? BaseUtilities.toFile(url.toURI()) : null)
                                .map ((root) -> new File(root, MODULE_INFO_JAVA))
                                .ifPresent(moduleInfos::add);
                    } catch (URISyntaxException use) {
                        LOG.log(
                                Level.WARNING,
                                "Cannot convert to URI: {0}",   //NOI18N
                                e.getURL());
                    }
                }

        }
    }
    return binaries.stream()
            .map((url) -> org.netbeans.spi.java.classpath.support.ClassPathSupport.createResource(url))
            .collect(Collectors.toList());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:ModuleClassPaths.java


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