@Override public boolean isVirtual() { return delegate.isVirtual(); }
public boolean isVirtual() { return leader.isVirtual(); }
/** * Tests if a URL represents a JAR or ZIP archive. * If there is no such file object, the test is done by heuristic: any URL with an extension is * treated as an archive. * @param url a URL to a file * @return true if the URL seems to represent a ZIP-format archive * @since 4.48 */ public static boolean isArchiveFile(URL url) { Parameters.notNull("url", url); //NOI18N if ("jar".equals(url.getProtocol())) { //NOI18N //Already inside archive, return false return false; } FileObject fo = URLMapper.findFileObject(url); if ((fo != null) && !fo.isVirtual()) { if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "isArchiveFile_FILE_RESOLVED", fo); //NOI18N, used by FileUtilTest.testIsArchiveFileRace } return isArchiveFile(fo); } else { return isArchiveFile(url.getPath()); } }
if (fo.isVirtual()) { return isArchiveFile(fo.getPath());
public boolean isVirtual () { return leader.isVirtual (); }
public boolean isVirtual () { return leader.isVirtual (); }
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); } } }
private boolean foldingEnabled() { FileObject fileObject = getFileObject(); if (fileObject != null) { return !fileObject.isVirtual(); } return false; }
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); } } }
/** * Tests if a URL represents a JAR or ZIP archive. * If there is no such file object, the test is done by heuristic: any URL with an extension is * treated as an archive. * @param url a URL to a file * @return true if the URL seems to represent a ZIP-format archive * @since 4.48 */ public static boolean isArchiveFile (URL url) { if (url == null) { throw new NullPointerException("Cannot pass null URL to FileUtil.isArchiveFile"); // NOI18N } if ("jar".equals(url.getProtocol())) { //NOI18N //Already inside archive, return false return false; } FileObject fo = URLMapper.findFileObject(url); if (fo!=null && !fo.isVirtual()) { return isArchiveFile(fo); } else { String urlPath = url.getPath(); int index = urlPath.lastIndexOf('.'); return index != -1 && index > urlPath.lastIndexOf('/'); } }
CompilationInfo(final Source javaSource, final FileObject fo, final ParserTaskImpl javacTask) throws IOException { super(fo); assert javaSource != null; this.javaSource = javaSource; //this.jfo = fo != null ? javaSource.jfoProvider.createJavaFileObject(fo) : null; if (fo.isValid() && !fo.isVirtual()) { this.jfo = new SourceFileObject(fo, true); } else { this.jfo = null; } this.javacTask = javacTask; }
/** * Tests if a URL represents a JAR or ZIP archive. * If there is no such file object, the test is done by heuristic: any URL with an extension is * treated as an archive. * @param url a URL to a file * @return true if the URL seems to represent a ZIP-format archive * @since 4.48 */ public static boolean isArchiveFile (URL url) { if (url == null) { throw new NullPointerException("Cannot pass null URL to FileUtil.isArchiveFile"); // NOI18N } if ("jar".equals(url.getProtocol())) { //NOI18N //Already inside archive, return false return false; } FileObject fo = URLMapper.findFileObject(url); if (fo!=null && !fo.isVirtual()) { return isArchiveFile(fo); } else { String urlPath = url.getPath(); int index = urlPath.lastIndexOf('.'); return index != -1 && index > urlPath.lastIndexOf('/'); } }
public static Document getDocument(FileObject fo) { if (fo != null && fo.isValid()) { try { DataObject dob = DataObject.find(fo); if (dob != null && dob.isValid()) { EditorCookie ec = dob.getLookup().lookup(EditorCookie.class); if (ec != null) { return ec.getDocument(); } } } catch (IOException ex) { // file can be removed or became invalid // we catch IOException, because FileStateInvalidException is IOException // but is not declared to be thrown from DataObject.find if (fo.isValid() && !fo.isVirtual()) { Exceptions.printStackTrace(ex); } } } return null; }
private static void collectFiles(FileObject parent, Collection<FileObject> accepted, SharabilityQuery.Sharability parentSharab) { for (FileObject fo : parent.getChildren()) { if (!VisibilityQuery.getDefault().isVisible(fo)) { // #66765: ignore invisible files/folders, like CVS subdirectory continue; } SharabilityQuery.Sharability sharab; if (parentSharab == SharabilityQuery.Sharability.UNKNOWN || parentSharab == SharabilityQuery.Sharability.MIXED) { sharab = SharabilityQuery.getSharability(fo); } else { sharab = parentSharab; } if (sharab == SharabilityQuery.Sharability.NOT_SHARABLE) { continue; } if (fo.isData() && !fo.isVirtual()) { accepted.add(fo); } else if (fo.isFolder()) { accepted.add(fo); collectFiles(fo, accepted, sharab); } } }
/** * Creates {@link JavaFileObject} for a NetBeans {@link FileObject} * Any client which needs to create {@link JavaFileObject} for java * source file should use this factory method. * @param {@link FileObject} for which the {@link JavaFileObject} should be created * @param {@link FileObject} root owning the file * @param renderNow if true the snap shot of the file is taken immediately * @return {@link JavaFileObject}, never returns null * @exception {@link IOException} may be thrown */ public static AbstractSourceFileObject sourceFileObject (final FileObject file, final FileObject root, JavaFileFilterImplementation filter, boolean renderNow) throws IOException { assert file != null; if (!file.isValid() || file.isVirtual()) { throw new InvalidFileException (file); } return AbstractSourceFileObject.getFactory().createJavaFileObject( new AbstractSourceFileObject.Handle(file, root), filter, null, renderNow); }
/** * Creates {@link JavaFileObject} for a NetBeans {@link FileObject} * Any client which needs to create {@link JavaFileObject} for java * source file should use this factory method. * @param {@link FileObject} for which the {@link JavaFileObject} should be created * @param {@link FileObject} root owning the file * @param renderNow if true the snap shot of the file is taken immediately * @return {@link JavaFileObject}, never returns null * @exception {@link IOException} may be thrown */ public static AbstractSourceFileObject sourceFileObject (final FileObject file, final FileObject root, final JavaFileFilterImplementation filter, final CharSequence content) throws IOException { assert file != null; if (!file.isValid() || file.isVirtual()) { throw new InvalidFileException (file); } return AbstractSourceFileObject.getFactory().createJavaFileObject( new AbstractSourceFileObject.Handle(file, root), filter, content, true); }
protected FileObject getLocalFileObject(FileObject fileObject) { if(fileObject == null) { return null; } // What does virtual actually mean, should I handle these as well ? if (fileObject.isVirtual()) return null; File file = FileUtil.toFile(fileObject); if (file == null) { return null; } //Check if the file is non sharable if (SharabilityQuery.getSharability(file) == SharabilityQuery.NOT_SHARABLE) { return null; } if (hasActiveLockFileSigns(fileObject)) { return null; } FileObject projectRoot = getProject().getProjectDirectory(); if (projectRoot == null || !FileUtil.isParentOf(projectRoot, fileObject)) { return null; } return fileObject; }
/** Fired when a file is changed. * @param fe the event describing context where action has taken place */ public void fileChanged(FileEvent fe) { Env env = (Env)this.env.get (); if (env == null || env.getFileImpl () != fe.getFile ()) { // the Env change its file and we are not used // listener anymore => remove itself from the list of listeners fe.getFile ().removeFileChangeListener (this); return; } // #16403. Added handling for virtual property of the file. if(fe.getFile().isVirtual()) { // Remove file event coming as consequence of this change. fe.getFile().removeFileChangeListener(this); // File doesn't exist on disk -> simulate env is invalid, // even the fileObject could be valid, see VCS FS. env.fileRemoved(true); fe.getFile().addFileChangeListener(this); } else { env.fileChanged (fe.isExpected (), fe.getTime ()); } }
private void handleCopyFileToDestDir(FileObject fo) throws IOException { if (fo.isVirtual()) { return; } FileObject persistenceXmlDir = getWebModule().getPersistenceXmlDir(); if (persistenceXmlDir != null && FileUtil.isParentOf(persistenceXmlDir, fo) && "persistence.xml".equals(fo.getNameExt())) { // NOI18N handleCopyFileToDestDir("WEB-INF/classes/META-INF", persistenceXmlDir, fo); // NOI18N return; } FileObject webInf = getWebModule().resolveWebInf(docBaseValue, webInfValue, true, true); FileObject docBase = getWebModule().resolveDocumentBase(docBaseValue, false); if (webInf != null && FileUtil.isParentOf(webInf, fo) && !(webInf.getParent() != null && webInf.getParent().equals(docBase))) { handleCopyFileToDestDir("WEB-INF", webInf, fo); // NOI18N return; } if (docBase != null && FileUtil.isParentOf(docBase, fo)) { handleCopyFileToDestDir(null, docBase, fo); return; } }