org.netbeans.api.java.classpath.ClassPath.entries()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.netbeans.api.java.classpath.ClassPath.entries()方法的一些代码示例,展示了ClassPath.entries()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPath.entries()方法的具体详情如下:
包路径:org.netbeans.api.java.classpath.ClassPath
类名称:ClassPath
方法名:entries

ClassPath.entries介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans

private static boolean hasClassPathesIdenticEntries(ClassPath cp1, ClassPath cp2) {
  if (cp1.entries().size() != cp2.entries().size()) {
    return false;
  }
  for (int i = 0; i < cp1.entries().size(); i++) {
    if (!cp1.entries().get(i).getURL().sameFile(cp2.entries().get(i).getURL())) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

public static URL[] getClassPathRoots (final ClassPath cp) {
  assert cp != null;
  final List<ClassPath.Entry> entries = cp.entries();
  final List<URL> result = new ArrayList<URL>(entries.size());
  for (ClassPath.Entry entry : entries) {
    result.add (entry.getURL());
  }
  return result.toArray(new URL[result.size()]);
}

代码示例来源:origin: dcaoyuan/nbscala

private static java.util.List<URL> getPathList (ClassPath cp) {
  java.util.List<URL> result = new ArrayList<URL> ();
  for (ClassPath.Entry entry : cp.entries()) {
    result.add (entry.getURL());
  }
  return result;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

private URL getOwnerRootNoSib () {
  //todo: fix me, now supports just 1 src root
  final List<ClassPath.Entry> entries = userRoots.entries();
  return entries.size() == 1 ? entries.get(0).getURL() : null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans

private static int computeClassPathHash(ClassPath classPath) {
  int hashCode = 0;
  for (ClassPath.Entry entry : classPath.entries()) {
    hashCode = 37*hashCode + entry.getURL().getPath().hashCode();
  }
  return hashCode;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2me-cdc-platform

private static java.util.List<URL> getPathList (ClassPath cp) {
  ArrayList<URL> result = new ArrayList<URL> ();
  for (ClassPath.Entry entry : (java.util.List<ClassPath.Entry>)cp.entries() ) {
    result.add (entry.getURL());
  }
  return result;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans

private static int computeClassPathHash(ClassPath classPath) {
    int hashValue = 0;
    for (ClassPath.Entry entry : classPath.entries()) {
      hashValue += entry.getURL().getPath().hashCode();
    }
    return hashValue;
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects

private static List<URL> getURLRoots(ClassPath cp) {
  List<URL> urls = new ArrayList<URL>();
  for (Entry entry : cp.entries()) {
    URL url = entry.getURL();
    urls.add(url);
  }
  return urls;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2me-cdc-platform

void setSources (ClassPath sources) {
  String srcPath = null;
  if (sources.entries().size()>0) {
    URL folderRoot = ((ClassPath.Entry)sources.entries().get(0)).getURL();
    if ("jar".equals(folderRoot.getProtocol())) {   //NOI18N
      folderRoot = FileUtil.getArchiveFile (folderRoot);
    }
    srcPath = new File(URI.create(folderRoot.toExternalForm())).getAbsolutePath();
  }
  setSources (srcPath);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

public TransformationClassLoader(ClassLoader parent, ClassPath cp, CompilerConfiguration config) {
  super(parent, config);
  for (ClassPath.Entry entry : cp.entries()) {
    this.addURL(entry.getURL());
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects

private List<URL> getChangedPaths(final GlobalPathRegistryEvent event) {
  if (!ClassPath.SOURCE.equals(event.getId())) {
    return null;
  }
  List<URL> urls = new ArrayList<URL>();
  for (ClassPath cp : event.getChangedPaths()) {
    for (Entry entry : cp.entries()) {
      URL url = entry.getURL();
      urls.add(url);
    }
  }
  return urls;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

private URL getOwnerRootSib (final URL sibling) throws MalformedURLException {
  assert sibling != null;
  for (ClassPath.Entry entry : userRoots.entries()) {
    final URL rootURL = entry.getURL();
    if (FileObjects.isParentOf(rootURL, sibling)) {
      return rootURL;
    }
  }
  for (ClassPath.Entry entry : sourceRoots.entries()) {
    final URL rootURL = entry.getURL();
    if (FileObjects.isParentOf(rootURL, sibling)) {
      return rootURL;
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

private static boolean ensureSourcePath(final @NonNull FileObject root) throws IOException {
  final ClassPath srcPath = ClassPath.getClassPath(root, ClassPath.SOURCE);
  String srcPathStr;
  if (srcPath != null) {
    final StringBuilder sb = new StringBuilder();
    for (ClassPath.Entry entry : srcPath.entries()) {
      sb.append(entry.getURL()).append(' ');  //NOI18N
    }
    srcPathStr = sb.toString();
  } else {
    srcPathStr = "";    //NOI18N
  }
  return JavaIndex.ensureAttributeValue(root.toURL(), SOURCE_PATH, srcPathStr);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

public static ClassLoader forClassPath(
    @NonNull final ClassPath classPath,
    @NullAllowed final ClassLoader parent,
    @NullAllowed final Consumer<? super URL> usedRoots) {
  Parameters.notNull("classPath", classPath); //NOI18N
  final List<ClassPath.Entry> entries = classPath.entries();
  final URL[] urls = new URL[entries.size()];
  final Iterator<ClassPath.Entry> eit = entries.iterator();
  for (int i=0; eit.hasNext(); i++) {
    urls[i] = eit.next().getURL();
  }
  return forURLs(urls, parent, usedRoots);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

@Override
public javax.tools.FileObject getFileForOutput( Location l, String pkgName, String relativeName, javax.tools.FileObject sibling ) 
  throws IOException, UnsupportedOperationException, IllegalArgumentException {
  if (!allowOutput) {
    throw new UnsupportedOperationException("Output is unsupported.");  //NOI18N
  }
  javax.tools.JavaFileObject file = findFile (pkgName, relativeName);
  if (file == null) {
    final List<ClassPath.Entry> entries = this.cp.entries();
    if (!entries.isEmpty()) {
      final String resourceName = FileObjects.resolveRelativePath(pkgName, relativeName);
      file = provider.getArchive(entries.get(0).getURL(), cacheFile).create(resourceName, filter);
    }
  }
  return file;    //todo: wrap to make read only
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

private FileObject[] findFile (final String relativePath) {
  for (ClassPath.Entry entry : this.sourceRoots.entries()) {
    if (ignoreExcludes || entry.includes(relativePath)) {
      FileObject root = entry.getRoot();
      if (root != null) {
        FileObject file = root.getFileObject(relativePath);
        if (file != null) {
          return new FileObject[] {file, root};
        }
      }
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

/**
 * Creates a {@link ReferencesCount} for source classpath represented by given
 * {@link ClasspathInfo}.
 * @param cpInfo the {@link ClasspathInfo} to create {@link ReferencesCount} for.
 * @return the {@link ReferencesCount}
 */
@NonNull
public static ReferencesCount get(@NonNull final ClasspathInfo cpInfo) {
  Parameters.notNull("cpInfo", cpInfo);   //NOI18N
  final List<? extends ClassPath.Entry> scp = cpInfo.getClassPath(ClasspathInfo.PathKind.SOURCE).entries();
  final List<URL> roots = new ArrayList<URL>(scp.size());
  for (ClassPath.Entry e : scp) {
    roots.add(e.getURL());
  }
  return new ReferencesCount(roots);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

private File getClassFolderForApt(final @NonNull URL surl) {
  for (ClassPath.Entry entry : apt.entries()) {
    if (FileObjects.isParentOf(entry.getURL(), surl)) {
      final URL classFolder = AptCacheForSourceQuery.getClassFolder(entry.getURL());
      if (classFolder != null) {
        try {
          return BaseUtilities.toFile(classFolder.toURI());
        } catch (URISyntaxException ex) {
          Exceptions.printStackTrace(ex);
        }
      }
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javafx2-project

private static boolean isTest(final @NonNull FileObject root, final @NonNull Project project) {
  assert root != null;
  assert project != null;
  final ClassPath cp = ClassPath.getClassPath(root, ClassPath.COMPILE);
  for (ClassPath.Entry entry : cp.entries()) {
    final FileObject[] srcRoots = SourceForBinaryQuery.findSourceRoots(entry.getURL()).getRoots();
    for (FileObject srcRoot : srcRoots) {
      if (project.equals(FileOwnerQuery.getOwner(srcRoot))) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

private static boolean isIncluded (final ElementHandle<TypeElement> element, final ClasspathInfo cpInfo) {
  FileObject fobj = getFile (element,cpInfo);
  if (fobj == null) {
    //Not source
    return true;
  }
  ClassPath sourcePath = cpInfo.getClassPath(ClasspathInfo.PathKind.SOURCE);
  for (ClassPath.Entry e : sourcePath.entries()) {
    FileObject root = e.getRoot ();
    if (root != null && FileUtil.isParentOf(root,fobj)) {
      return e.includes(fobj);
    }
  }
  return true;
}

相关文章