本文整理汇总了Java中org.netbeans.api.java.classpath.ClassPath.Entry方法的典型用法代码示例。如果您正苦于以下问题:Java ClassPath.Entry方法的具体用法?Java ClassPath.Entry怎么用?Java ClassPath.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.java.classpath.ClassPath
的用法示例。
在下文中一共展示了ClassPath.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRoots
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private List<FileObject> getRoots(ClassPath cp) {
List<FileObject> list = new ArrayList<FileObject>(cp.entries().size());
for (ClassPath.Entry e : cp.entries()) {
// try to map it to sources
URL url = e.getURL();
SourceForBinaryQuery.Result r = SourceForBinaryQuery.findSourceRoots(url);
FileObject [] fos = r.getRoots();
if (fos.length > 0) {
for (int i = 0 ; i < fos.length; i++) list.add(fos[i]);
} else {
if (e.getRoot()!=null)
list.add(e.getRoot()); // add the class-path location directly
}
}
return list;
}
示例2: hasJavaFxModule
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
/**
* Checks if JavaFx is present as a module in the platform.
* @param javaPlatform to check
* @return returns true if the JavaFx is available as a platform module
*/
public static boolean hasJavaFxModule(@NonNull final JavaPlatform javaPlatform) {
if (JDK9.compareTo(javaPlatform.getSpecification().getVersion()) > 0) {
return false;
}
for (ClassPath.Entry e : javaPlatform.getBootstrapLibraries().entries()) {
final URL url = e.getURL();
if (!MODULE_PROTOCOL.equals(url.getProtocol())) {
continue;
}
if (MODULE_JFX_BASE.equals(getModuleName(url))) {
return true;
}
}
return false;
}
示例3: isModular
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private static boolean isModular(@NonNull final JavaPlatform platform) {
boolean modular = false;
for (ClassPath.Entry e : platform.getBootstrapLibraries().entries()) {
if (MODULE_PROTOCOL.equals(e.getURL().getProtocol())) {
modular = true;
break;
}
}
return modular;
}
示例4: 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;
}
示例5: apply
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@Override
public List<PathResourceImplementation> apply(List<ClassPath.Entry> entries) {
final List<PathResourceImplementation> res = new ArrayList<PathResourceImplementation>();
for (ClassPath.Entry entry : entries) {
final URL aptRoot = AptCacheForSourceQuery.getAptFolder(entry.getURL());
if (aptRoot != null) {
res.add(ClassPathSupport.createResource(aptRoot));
}
}
return res;
}
示例6: toSourcePath
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
/**
* Tries to convert a classpath with classes into a classpath containing
* java source code.
*
* @param cp
* @return
*/
public static ClassPath toSourcePath(final ClassPath cp) {
final List<FileObject> resources = new ArrayList<FileObject>();
for (ClassPath.Entry e : cp.entries()) {
final FileObject[] srcRoots = SourceForBinaryQuery.findSourceRoots(e.getURL()).getRoots();
resources.addAll(Arrays.asList(srcRoots));
}
return ClassPathSupport.createClassPath(resources.toArray(new FileObject[resources.size()]));
}
示例7: contains
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private static boolean contains (final ClassPath cp, final URL url) {
for (ClassPath.Entry entry : cp.entries()) {
if (entry.getURL().equals(url)) {
return true;
}
}
return false;
}
示例8: FileObjectCrawler
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
FileObjectCrawler(
@NonNull final FileObject root,
@NullAllowed final FileObject[] files,
final Set<? extends TimeStampAction> checkTimeStamps,
@NullAllowed final ClassPath.Entry entry,
@NonNull final CancelRequest cancelRequest,
@NonNull final SuspendStatus suspendStatus) throws IOException {
super (root.toURL(), checkTimeStamps, false, supportsAllFiles(root, files), cancelRequest, suspendStatus);
this.root = root;
this.entry = entry;
this.files = files;
}
示例9: translate
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@NonNull
private static ClassPath translate(
@NonNull final ClassPath cp,
@NonNull final Map<URL,Pair<URL,FileObject[]>> dictionary) {
final List<URL> roots = new ArrayList<>(cp.entries().size());
for (ClassPath.Entry e : cp.entries()) {
final URL orig = e.getURL();
final SourceForBinaryQuery.Result2 res = SourceForBinaryQuery.findSourceRoots2(orig);
if (res.preferSources()) {
final FileObject[] srcs = res.getRoots();
for (FileObject src : srcs) {
try {
final URL cacheURL = BaseUtilities.toURI(
JavaIndex.getClassFolder(src.toURL())).toURL();
dictionary.put(cacheURL,Pair.of(orig,res.getRoots()));
roots.add(cacheURL);
} catch (IOException ioe) {
Exceptions.printStackTrace(ioe);
}
}
} else {
dictionary.put(orig, Pair.of(orig,res.getRoots()));
roots.add(orig);
}
}
return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
}
示例10: getJavadocRoots
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private static URL[] getJavadocRoots(JavaPlatform platform) {
Set<URL> result = new HashSet<URL>();
List<ClassPath.Entry> l = platform.getBootstrapLibraries().entries();
for (Iterator it = l.iterator(); it.hasNext();) {
ClassPath.Entry e = (ClassPath.Entry) it.next();
result.addAll(Arrays.asList(JavadocForBinaryQuery.findJavadoc(e.getURL()).getRoots()));
}
return result.toArray(new URL[result.size()]);
}
示例11: testResources
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
public void testResources () throws Exception {
final URL url1 = new URL ("file:///tmp/a/");
final URL url2 = new URL ("file:///tmp/b/");
final URL url3 = new URL ("file:///tmp/b/");
final ClassPath cp1 = ClassPathSupport.createClassPath(new URL[] {url1, url2});
final ClassPath cp2 = ClassPathSupport.createClassPath(new URL[] {url3});
final ClassPath prxCp = ClassPathSupport.createProxyClassPath(new ClassPath[] {cp1,cp2});
List<ClassPath.Entry> entries = prxCp.entries();
assertEquals(3,entries.size());
assertEquals(url1,entries.get(0).getURL());
assertEquals(url2,entries.get(1).getURL());
assertEquals(url3,entries.get(2).getURL());
}
示例12: 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;
}
示例13: isSourceRoot
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private boolean isSourceRoot() {
final ClassPath cp = modules.getModuleSources(moduleName);
if (cp == null) {
return false;
}
for (ClassPath.Entry e : cp.entries()) {
if (e.getURL().equals(url)) {
return true;
}
}
return false;
}
示例14: 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());
}
示例15: list
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@Override
public Iterable<JavaFileObject> list(
@NonNull final Location l,
@NonNull final String packageName,
@NonNull final Set<JavaFileObject.Kind> kinds,
final boolean recursive ) {
final List<JavaFileObject> result = new ArrayList<> ();
String folderName = FileObjects.convertPackage2Folder(packageName);
if (folderName.length() > 0) {
folderName += FileObjects.NBFS_SEPARATOR_CHAR;
}
final ModuleLocation.WithExcludes ml = asSourceModuleLocation(l);
for (ClassPath.Entry entry : ml.getModuleEntries()) {
if (ignoreExcludes || entry.includes(folderName)) {
FileObject root = entry.getRoot();
if (root != null) {
FileObject tmpFile = root.getFileObject(folderName);
if (tmpFile != null && tmpFile.isFolder()) {
Enumeration<? extends FileObject> files = tmpFile.getChildren (recursive);
while (files.hasMoreElements()) {
FileObject file = files.nextElement();
if (ignoreExcludes || entry.includes(file)) {
final JavaFileObject.Kind kind = FileObjects.getKind(file.getExt());
if (kinds.contains(kind)) {
result.add (FileObjects.sourceFileObject(file, root));
}
}
}
}
}
}
}
return result;
}