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

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

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

ClassPath.getRoots介绍

暂无

代码示例

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

FileObject getSourceFileObject() {
  FileObject[] roots = sourcePath.getRoots();
  if (roots != null && roots.length > 0) {
    return roots[0];
  }
  return null;
}

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

FileObject getSourceFileObject(){
  FileObject[] roots = mySourcePath.getRoots();
  if ( roots!= null && roots.length >0 ){
    return roots[0];
  }
  return null;
}

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

public SpringIndex(ClassPath cp) {
  this.binaryRoots = cp.getRoots();
}

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

private static void addSourceRoots(ClassPath ecp,
                  List<FileObject> allSourceRoots,
                  Set<FileObject> preferredRoots) {
  FileObject[] sourceRoots = ecp.getRoots();
  for (FileObject fr : sourceRoots) {
    if (!preferredRoots.contains(fr) && !fr.isVirtual()) {
      allSourceRoots.add(fr);
      preferredRoots.add(fr);
    }
  }
}

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

private String[] getSourceRoots(ClassPath classPath) {
  FileObject[] sourceRoots = classPath.getRoots();
  List<String> roots = new ArrayList<String>(sourceRoots.length);
  for (FileObject fo : sourceRoots) {
    String root = getRoot(fo);
    if (root != null) {
      roots.add(root);
    }
  }
  return roots.toArray(new String[0]);
}

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

private String[] getSourceRoots(ClassPath classPath) {
  FileObject[] sourceRoots = classPath.getRoots();
  List<String> roots = new ArrayList<String>(sourceRoots.length);
  for (FileObject fo : sourceRoots) {
    String root = getRoot(fo);
    if (root != null) {
      roots.add(root);
    }
  }
  return roots.toArray(new String[0]);
}

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

private static void addSourceRoots(ClassPath ecp,
                  List<FileObject> allSourceRoots,
                  Set<FileObject> preferredRoots) {
  FileObject[] sourceRoots = ecp.getRoots();
  for (FileObject fr : sourceRoots) {
    if (!preferredRoots.contains(fr) && !fr.isVirtual()) {
      allSourceRoots.add(fr);
      preferredRoots.add(fr);
    }
  }
}

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

private static Set<String> getSourceRootsSet(ClassPath classPath) {
  FileObject[] sourceRoots = classPath.getRoots();
  Set<String> roots = new HashSet<String>(sourceRoots.length);
  for (FileObject fo : sourceRoots) {
    String root = getRoot(fo);
    if (root != null) {
      roots.add(root);
    }
  }
  return roots;
}

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

public FileObject[] getRoots () {       //No need for caching, platforms does.
  ClassPath sources = this.platform.getSourceFolders();
  return sources.getRoots();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-cldcplatform

public String getSourcePath() {
  return toRelativePaths(Arrays.asList(sources.getRoots()));
}

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

public SpringIndex(FileObject fo) {
  this.binaryRoots = (ClassPath.getClassPath(fo, ClassPath.EXECUTE).getRoots());
}

代码示例来源:origin: hmvictor/radar-netbeans

private static String getLibrariesPath(ClassPath classPath) {
  StringBuilder librariesPath = new StringBuilder();
  for (FileObject root : classPath.getRoots()) {
    if (librariesPath.length() > 0) {
      librariesPath.append(',');
    }
    FileObject archiveFile = FileUtil.getArchiveFile(root);
    if (archiveFile != null) {
      librariesPath.append(archiveFile.getPath());
    }
  }
  return librariesPath.toString();
}

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

public static String getCommandLine(ClasspathInfo cpInfo) {
  ClassPath sourceCP = cpInfo.getClassPath(PathKind.SOURCE);
  FileObject[] roots = sourceCP != null ? sourceCP.getRoots() : new FileObject[0];
  FileObject file = roots.length > 0 ? roots[0] : null;
  
  for (CompilerSettings cs : Lookup.getDefault().lookupAll(CompilerSettings.class)) {
    String cl = cs.buildCommandLine(file);
    
    if (cl != null) return cl;
  }
  
  return "";
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-cldcplatform

private void removeSourceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeSourceButtonActionPerformed
  final J2MEPlatform platform = findSelectedPlatform();
  if (platform == null)
    return;
  final Object selectedValue = sourceList.getSelectedValue();
  if (selectedValue == null)
    return;
  int i = sourceList.getSelectedIndex();
  final ArrayList<FileObject> list = new ArrayList<FileObject>(Arrays.asList(platform.getSourceFolders().getRoots()));
  list.remove(selectedValue);
  platform.setSourceFolders(list);
  descriptorUpdated();
  if (i >= sourceList.getModel().getSize()) i--;
  if (i >= 0) sourceList.setSelectedIndex(i);
}//GEN-LAST:event_removeSourceButtonActionPerformed

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mobility-cldcplatform

private void addSourceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addSourceButtonActionPerformed
  final J2MEPlatform platform = findSelectedPlatform();
  if (platform == null)
    return;
  final String value = browse(NbBundle.getMessage(DetectPanel.class, "TITLE_DetectPanel_SelectSource")); // NOI18N
  if (value == null)
    return;
  final FileObject o = platform.resolveRelativePathToFileObject(value);
  if (o == null)
    return;
  final ArrayList<FileObject> list = new ArrayList<FileObject>(Arrays.asList(platform.getSourceFolders().getRoots()));
  list.add(o);
  platform.setSourceFolders(list);
  descriptorUpdated();
}//GEN-LAST:event_addSourceButtonActionPerformed

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-ejbjarproject

@Override
public File[] getRequiredLibraries() {
  ClassPath cp = ClassPathFactory.createClassPath(
        ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
        FileUtil.toFile(project.getProjectDirectory()), project.evaluator(), new String[]{"javac.classpath"}));
  List<File> files = new ArrayList<File>();
  for (FileObject fo : cp.getRoots()) {
    fo = FileUtil.getArchiveFile(fo);
    if (fo == null) {
      continue;
    }
    files.add(FileUtil.toFile(fo));
  }
  return files.toArray(new File[files.size()]);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-clientproject

@Override
public File[] getRequiredLibraries() {
  ClassPath cp = ClassPathFactory.createClassPath(
        ProjectClassPathSupport.createPropertyBasedClassPathImplementation(
        FileUtil.toFile(project.getProjectDirectory()), project.evaluator(), new String[]{"javac.classpath"}));
  List<File> files = new ArrayList<File>();
  for (FileObject fo : cp.getRoots()) {
    fo = FileUtil.getArchiveFile(fo);
    if (fo == null) {
      continue;
    }
    files.add(FileUtil.toFile(fo));
  }
  return files.toArray(new File[files.size()]);
}

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

private static boolean isAptBuildGeneratedFolder(@NonNull final FileObject root) {
  final ClassPath scp = ClassPath.getClassPath(root, ClassPath.SOURCE);
  if (scp != null) {
    for (FileObject srcRoot : scp.getRoots()) {
      if (root.toURL().equals(
          AnnotationProcessingQuery.getAnnotationProcessingOptions(srcRoot).sourceOutputDirectory())) {
        return true;
      }
    }
  }
  return false;
}

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

private static void listenOnProcessorPath(
    @NullAllowed final ClassPath cp,
    @NonNull final APTUtils target) {
  if (cp != null) {
    cp.addPropertyChangeListener(WeakListeners.propertyChange(target, cp));
    cp.getRoots();//so that the ClassPath starts listening on the filesystem
  }
}

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

private static boolean isAptBuildGeneratedFolder(
    @NonNull final URL root,
    @NonNull final ClassPath srcPath) {
  Parameters.notNull("root", root);       //NOI18N
  Parameters.notNull("srcPath", srcPath); //NOI18N
  for (FileObject srcRoot : srcPath.getRoots()) {
    if (root.equals(AnnotationProcessingQuery.getAnnotationProcessingOptions(srcRoot).sourceOutputDirectory())) {
      return true;
    }
  }
  return false;
}

相关文章