public FileObject find(String filename) { return classpath.findResource(filename); }
/** * Whether the given classpath contains support for Facelets. * * @param cp examined classpath * @return {@code true} if the facelets classes are present on the classpath, {@code false} otherwise */ public static boolean isFaceletsPresent(ClassPath cp) { if (cp == null) { return false; } return cp.findResource(JSFUtils.MYFACES_SPECIFIC_CLASS.replace('.', '/') + ".class") != null || //NOI18N cp.findResource("com/sun/facelets/Facelet.class") != null || //NOI18N cp.findResource("com/sun/faces/facelets/Facelet.class") != null || // NOI18N cp.findResource("javax/faces/view/facelets/FaceletContext.class") != null; //NOI18N }
private static boolean containsClass(ClassPath classPath, String className) { String classRelativePath = className.replace('.', '/') + ".class"; //NOI18N return classPath.findResource(classRelativePath) != null; }
private static boolean hasResource( @NonNull String resourceBase, @NullAllowed ClassPath boot, @NullAllowed ClassPath compile, @NullAllowed ClassPath source) { final String resourceClass = String.format("%s.class", resourceBase); final String resourceJava = String.format("%s.java", resourceBase); if (boot != null && boot.findResource(resourceClass) == null) { //NOI18N if (source != null && source.findResource(resourceJava) == null) { //NOI18N if (compile == null || compile.findResource(resourceClass) == null) { // NOI18N return false; } } } return true; }
static boolean hasResource(SourceGroup group , String classPathType, String fqn){ ClassPath classPath = ClassPath.getClassPath(group.getRootFolder(), classPathType); String path = fqn.replace('.', '/'); if ( ClassPath.SOURCE.equals( classPathType ) ){ path = path+".java"; // NOI18N } else { path = path+".class"; // NOI18N } if (classPath == null) { return false; } return classPath.findResource(path) != null; }
private void selectClasspathResource(Matcher m) { String resource = m.group(1) + m.group(4); int lineNumber = Integer.parseInt(m.group(5)); org.netbeans.api.java.classpath.ClassPath cp = ClassPathSupport.createClassPath(GlobalPathRegistry.getDefault().getSourceRoots().toArray(new FileObject[0])); FileObject source = cp.findResource(resource); if (source != null) { doOpen(source, lineNumber); } }
private void selectStackTrace(Matcher m) { String pkg = m.group(2); String filename = m.group(3); String resource = pkg.replace('.', '/') + filename; int lineNumber = Integer.parseInt(m.group(4)); org.netbeans.api.java.classpath.ClassPath cp = ClassPathSupport.createClassPath(GlobalPathRegistry.getDefault().getSourceRoots().toArray(new FileObject[0])); FileObject source = cp.findResource(resource); if (source != null) { doOpen(source, lineNumber); } }
/** * Checks whether the project of given file uses Swing Application Framework, * i.e. whether the framework is on project classpath. Does not check if * there is an Application subclass (the project can be just a library). * @param fileInProject some source file contained in the project * @return true if the project of given file uses app framework */ static boolean isFrameworkLibAvailable(FileObject fileInProject) { ClassPath cp = ClassPath.getClassPath(fileInProject, ClassPath.EXECUTE); return cp != null && cp.findResource(APPLICATION_RESOURCE_NAME) != null && projectCanUseFramework(fileInProject); }
private static boolean isJSF22(WebModule wm) { ClassPath classpath = ClassPath.getClassPath(wm.getDocumentBase(), ClassPath.COMPILE); return classpath != null && classpath.findResource("javax/faces/flow/Flow.class") != null; //NOI18N }
private @CheckForNull FileObject findBundle(FileObject javaFile) { ClassPath cp = ClassPath.getClassPath(javaFile, ClassPath.SOURCE); if (cp == null) { return null; } String name = cp.getResourceName(javaFile); if (name != null) { int index = name.lastIndexOf('/'); name = name.substring(0, index) + "/Bundle.properties"; //NOI18N return cp.findResource(name); } return null; }
private static boolean isJSF20(WebModule wm) { ClassPath classpath = ClassPath.getClassPath(wm.getDocumentBase(), ClassPath.COMPILE); return classpath != null && classpath.findResource("javax/faces/application/ProjectStage.class") != null; //NOI18N }
private URL getSourceFile(String name) { // this is slightly faster then original implementation FileObject fo = path.findResource(name.replace('.', '/') + config.getDefaultScriptExtension()); if (fo == null || fo.isFolder()) { return null; } return URLMapper.findURL(fo, URLMapper.EXTERNAL); } }
static DesignResourceMap getAppDesignResourceMap(Project project) { String appClassName = AppFrameworkSupport.getApplicationClassName(project); if (appClassName != null) { String bundleName = getBundleName(appClassName); ClassPath cp = AppFrameworkSupport.getSourcePath(project); FileObject fo = cp.findResource(appClassName.replace('.', '/') + ".java"); // NOI18N return new DesignResourceMap(null, cp.getClassLoader(true), fo, new String[] { bundleName }, DesignResourceMap.APP_LEVEL); } return null; }
private static FileObject findUnitTestInTestRoot(ClassPath cp, FileObject selectedFO, URL testRoot) { ClassPath testClassPath = null; if (testRoot == null) { //no tests, use sources instead testClassPath = cp; } else { try { List<PathResourceImplementation> cpItems = new ArrayList<PathResourceImplementation>(); cpItems.add(ClassPathSupport.createResource(testRoot)); testClassPath = ClassPathSupport.createClassPath(cpItems); } catch (IllegalArgumentException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); testClassPath = cp; } } String testName = getTestName(cp, selectedFO); return testClassPath.findResource(testName+".java"); }
protected void addJerseySpringJar() throws IOException { FileObject srcRoot = MiscUtilities.findSourceRoot(getProject()); if (srcRoot != null) { ClassPath cp = ClassPath.getClassPath(srcRoot, ClassPath.COMPILE); if (cp ==null ||cp.findResource( "com/sun/jersey/api/spring/Autowire.class") == null) //NOI18N { File jerseyRoot = InstalledFileLocator.getDefault().locate(JERSEY_API_LOCATION, null, false); if (jerseyRoot != null && jerseyRoot.isDirectory()) { File[] jerseyJars = jerseyRoot.listFiles(new MiscPrivateUtilities.JerseyFilter(JERSEY_SPRING_JAR_PATTERN)); if (jerseyJars != null && jerseyJars.length>0) { URL url = FileUtil.getArchiveRoot(jerseyJars[0].toURI().toURL()); ProjectClassPathModifier.addRoots(new URL[] {url}, srcRoot, ClassPath.COMPILE); } } } } }
public static boolean hasResource(Project project, String resource) { SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); if (sgs.length < 1) { return false; } FileObject sourceRoot = sgs[0].getRootFolder(); ClassPath classPath = ClassPath.getClassPath(sourceRoot, ClassPath.COMPILE); if (classPath == null) { return false; } FileObject resourceFile = classPath.findResource(resource); if (resourceFile != null) { return true; } return false; }
private static boolean hasResource(Project project, String resource) { SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); if (sgs.length < 1) { return false; } FileObject sourceRoot = sgs[0].getRootFolder(); ClassPath classPath = ClassPath.getClassPath(sourceRoot, ClassPath.COMPILE); if (classPath == null) { return false; } FileObject resourceFile = classPath.findResource(resource); if (resourceFile != null) { return true; } return false; }
private static @CheckForNull FileObject findFile(FileObject manifest, String path) { Project prj = FileOwnerQuery.getOwner(manifest); if (prj == null) { return null; } Sources srcs = ProjectUtils.getSources(prj); SourceGroup[] grps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); if (grps.length == 0) // #143157: there needn't to be source group (yet) return null; ClassPath cp = ClassPath.getClassPath(grps[0].getRootFolder(), ClassPath.SOURCE); if (cp == null) { return null; } path = path.trim(); return cp.findResource(path); }
@Override protected void projectOpened() { final ClassPath classPath = getTestClassPath(p); if (classPath != null) { if (classPath.findResource(JUNIT3_SPECIFIC) != null || classPath.toString().contains("${libs.junit.classpath}")) { getJUnitProjectProblemsProvider(p).setProblem(ProjectProblem.createError( Bundle.Error_display_name_junit(), Bundle.Error_description_junit(), new JUnitProblemResolver(new UpdateToJUnit4Action(p, true), MISSING_JUNIT_BINARIES))); } if (classPath.findResource(JUNIT4_SPECIFIC) != null && classPath.findResource(HAMCREST_SPECIFIC) == null) { getJUnitProjectProblemsProvider(p).setProblem(ProjectProblem.createError( Bundle.Error_display_name_junit4(), Bundle.Error_description_junit4(), new JUnitProblemResolver(new UpdateToJUnit4Action(p, false), MISSING_JUNIT_BINARIES))); } } }
private void refreshLocation(String fqn) { String cpBase = fqn.replace('.', '/'); //NOI18N ClassPath sourceCP = getHelper().getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE); FileObject classFO = sourceCP.findResource(cpBase + ".java"); //NOI18N if (classFO == null) { ClassPath compileCP = getHelper().getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE); classFO = searchForFile(compileCP, cpBase); } if (classFO != null) { location = new SpringAnnotatedBeanLocation(classFO); } }