/** * @throws FileStateInvalidException never * @deprecated Use {@link #toURL} instead. */ @Deprecated public final URL getURL() throws FileStateInvalidException { return toURL(); }
/** * Gets a URI for this file. * Similar to {@link #toURL}. * @return an absolute URI representing this file location * @since 7.57 */ public final URI toURI() { try { URI uri = toURL().toURI(); assert uri.isAbsolute() : uri; assert uri.equals(uri.normalize()) : uri + " == " + uri.normalize() + " from " + this; return uri; } catch (URISyntaxException x) { throw new IllegalStateException(x); } }
@SuppressWarnings("deprecation") // FileSystem.systemName historical part of serial form private void writeObject(ObjectOutputStream oos) throws IOException { fsname = f.getFileSystem().getSystemName(); path = f.getPath(); url = f.toURL(); assert url != null : "No URL for " + path; oos.defaultWriteObject(); }
is = fo.getInputStream(); in.setByteStream(is); in.setSystemId(fo.toURL().toExternalForm()); customizeInputSource(in);
/** * Creates URLs for file objects. * @param roots file roots * @return array of URLs */ private static URL[] createRootURLs(FileObject[] roots) { URL[] urls = new URL[roots.length]; for (int i = 0; i < roots.length; i++) { urls[i] = roots[i].toURL(); } return urls; }
@Override public URL[] getRoots() { List<URL> l = new ArrayList<URL>(2); FileObject sourcesFolder = project.getSiteRootFolder(); if (sourcesFolder != null) { l.add(sourcesFolder.toURL()); } FileObject testsFolder = project.getTestsFolder(false); if (testsFolder != null) { l.add(testsFolder.toURL()); } return l.toArray(new URL[l.size()]); }
@Override public String getName() { return getProjectDirectory().toURL().toExternalForm(); }
@NonNull private static Set<URL> mapToURLs( @NonNull final Collection<? extends FileObject> fos) { final Set<URL> res = new HashSet<>(fos.size()); for (FileObject fo : fos) { res.add(fo.toURL()); } return res; }
@Override public void run() { IndexingManager.getDefault().refreshIndex( root.toURL(), Collections.<URL>emptyList(), false); } });
@Override public String getRelativePath() { String relativePath = super.getRelativePath(); if (relativePath == null) { try { relativePath = FileObjects.getRelativePath(root.toURL(), path); } catch (URISyntaxException ex) { Exceptions.printStackTrace(ex); } } return relativePath; }
@Override public URL getURL() { if (line instanceof FutureLine) { return ((FutureLine) line).getURL(); } return line.getLookup().lookup(FileObject.class).toURL(); }
public URL getSourceFile(String name, int hash, String content) throws IOException { String path = Integer.toHexString(hash) + '/' + name; FileObject fo = fs.findResource(path); if (fo == null) { fo = fs.createFile(path, content); } return fo.toURL(); }
private ArtifactsUpdatedImpl addArtifactsUpdateListenerFor(JPDADebugger debugger, FileObject src) { URL url = src.toURL(); ArtifactsUpdatedImpl l = new ArtifactsUpdatedImpl(debugger, url, src); BuildArtifactMapper.addArtifactsUpdatedListener(url, l); return l; }
@CheckForNull protected URL map(@NonNull final FileObject fo) { return fo.toURL(); }
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); }
@Override public void fileDeleted(FileEvent fe) { if (fe.getFile().toURL().equals(url)) { NbProject project = projectRef.get(); if (project != null) { project.notifyDeleted(); } else { fe.getFile().removeFileChangeListener(this); } } } }
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; }
@Override public void run() { //Todo: display some progress for (SourceGroup sg : createdSourceRoots) { IndexingManager.getDefault().refreshIndexAndWait(sg.getRootFolder().toURL(), null); } Mutex.EVENT.readAccess(new Runnable() { @Override public void run() { provider.getInstance().createTests(context); } }); } });
private static IDEProject createIDEProject(Project p) { ProjectInformation pi = ProjectUtils.getInformation(p); return new NbProject(pi.getDisplayName(), pi.getIcon(), p.getProjectDirectory().toURL()); }
@Override @CheckForNull protected URL map(@NonNull final FileObject fo) { final String relative = FileObjects.convertFolder2Package( FileObjects.stripExtension(FileObjects.getRelativePath(cacheRoot, FileUtil.toFile(fo))), File.separatorChar); final FileObject sourceFile = SourceUtils.getFile( ElementHandleAccessor.getInstance().create(ElementKind.CLASS, relative), resolveCps); return sourceFile == null ? null : sourceFile.toURL(); } }