/** Get URL that can be used to access this file. * If the file object does not correspond to a disk file or JAR entry, * the URL will only be usable within NetBeans as it uses a special protocol handler. * Otherwise an attempt is made to produce an external URL. * @return URL of this file object * @see URLMapper#findURL * @see URLMapper#INTERNAL * @since 7.57 */ public final URL toURL() { return URLMapper.findURL(this, URLMapper.INTERNAL); }
/** Finds appropriate java.io.File to FileObject if possible. * If not possible then null is returned. * This is the inverse operation of {@link #toFileObject}. * @param fo FileObject whose corresponding File will be looked for * @return java.io.File or null if no corresponding File exists. * @since 1.29 */ public static File toFile(FileObject fo) { File retVal = (File) fo.getAttribute("java.io.File"); // NOI18N; if (retVal == null) { URL fileURL = URLMapper.findURL(fo, URLMapper.INTERNAL); if (fileURL == null || !"file".equals(fileURL.getProtocol())) { //NOI18N fileURL = URLMapper.findURL(fo, URLMapper.EXTERNAL); } if ((fileURL != null) && "file".equals(fileURL.getProtocol())) { retVal = Utilities.toFile(URI.create(fileURL.toExternalForm())); } } if (retVal != null) { retVal = normalizeFile(retVal); } assert assertNormalized(retVal); return retVal; }
/** * Returns a FileObject representing the root folder of an archive. * Clients may need to first call {@link #isArchiveFile(FileObject)} to determine * if the file object refers to an archive file. * @param fo a ZIP- (or JAR-) format archive file * @return a virtual archive root folder, or null if the file is not actually an archive * @since 4.48 */ public static FileObject getArchiveRoot(FileObject fo) { URL archiveURL = URLMapper.findURL(fo, URLMapper.EXTERNAL); if (archiveURL == null) { return null; } return URLMapper.findFileObject(getArchiveRoot(archiveURL)); }
/** Get URL that can be used to access this file. * If the file object does not correspond to a disk file or JAR entry, * the URL will only be usable within the IDE as it uses a special protocol handler. * Otherwise an attempt is made to produce an external URL. * @return URL of this file object * @exception FileStateInvalidException if the file is not valid * @see URLMapper#findURL * @see URLMapper#INTERNAL */ public final URL getURL() throws FileStateInvalidException { // XXX why does this still throw FSIE? need not return URLMapper.findURL(this, URLMapper.INTERNAL); }
/** Get URL that can be used to access this file. * If the file object does not correspond to a disk file or JAR entry, * the URL will only be usable within the IDE as it uses a special protocol handler. * Otherwise an attempt is made to produce an external URL. * @return URL of this file object * @exception FileStateInvalidException if the file is not valid * @see URLMapper#findURL * @see URLMapper#INTERNAL */ public final URL getURL() throws FileStateInvalidException { // XXX why does this still throw FSIE? need not return URLMapper.findURL(this, URLMapper.INTERNAL); }
private static URL getSampleHTTPServerURL() { FileObject fo = FileUtil.getConfigFile("HTTPServer_DUMMY"); if (fo == null) { return null; } URL u = URLMapper.findURL(fo, URLMapper.NETWORK); return u; }
/** Finds appropriate java.io.File to FileObject if possible. * If not possible then null is returned. * This is the inverse operation of {@link #toFileObject}. * @param fo FileObject whose coresponding File will be looked for * @return java.io.File or null if no corresponding File exists. * @since 1.29 */ public static java.io.File toFile (FileObject fo) { File retVal = (File)fo.getAttribute("java.io.File"); // NOI18N; if (retVal == null) { URL fileURL = null; int[] types = new int [] {URLMapper.INTERNAL, URLMapper.EXTERNAL}; for (int i = 0; (fileURL == null || "file".equals(fileURL.getProtocol())) && i < types.length; i++) { // NOI18N fileURL = URLMapper.findURL(fo, types[i]); } if (fileURL != null && "file".equals(fileURL.getProtocol())) { retVal = new File(URI.create(fileURL.toExternalForm())); } retVal = (retVal != null) ? normalizeFile(retVal) : null; } return retVal; }
private static void constructTrie(ByteArray array, List<URL> sources) throws IOException { SortedSet<CharSequence> data = new TreeSet<CharSequence>(); for (URL u : sources) { FileObject f = URLMapper.findFileObject(u); u = f != null ? URLMapper.findURL(f, URLMapper.EXTERNAL) : u; BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream(), "UTF-8")); try { String line; while ((line = in.readLine()) != null) { data.add(CharSequences.create(line)); } } finally { //TODO: wrap in try - catch: in.close(); } } constructTrieData(array, data); }
/** Finds appropriate java.io.File to FileObject if possible. * If not possible then null is returned. * This is the inverse operation of {@link #toFileObject}. * @param fo FileObject whose coresponding File will be looked for * @return java.io.File or null if no corresponding File exists. * @since 1.29 */ public static java.io.File toFile (FileObject fo) { File retVal = (File)fo.getAttribute("java.io.File"); // NOI18N; if (retVal == null) { URL fileURL = null; int[] types = new int [] {URLMapper.INTERNAL, URLMapper.EXTERNAL}; for (int i = 0; (fileURL == null || "file".equals(fileURL.getProtocol())) && i < types.length; i++) { // NOI18N fileURL = URLMapper.findURL(fo, types[i]); } if (fileURL != null && "file".equals(fileURL.getProtocol())) { retVal = new File(URI.create(fileURL.toExternalForm())); } retVal = (retVal != null) ? normalizeFile(retVal) : null; } return retVal; }
URL u2 = URLMapper.findURL(f, URLMapper.NETWORK); if (u2 == null) {
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); } }
/** * Returns a FileObject representing the root folder of an archive. * Clients may need to first call {@link #isArchiveFile(FileObject)} to determine * if the file object refers to an archive file. * @param fo a ZIP- (or JAR-) format archive file * @return a virtual archive root folder, or null if the file is not actually an archive * @since 4.48 */ public static FileObject getArchiveRoot (FileObject fo) { URL archiveURL = URLMapper.findURL(fo, URLMapper.EXTERNAL); if (archiveURL == null) { return null; } return URLMapper.findFileObject(getArchiveRoot(archiveURL)); }
/** * Returns a FileObject representing the root folder of an archive. * Clients may need to first call {@link #isArchiveFile(FileObject)} to determine * if the file object refers to an archive file. * @param fo a ZIP- (or JAR-) format archive file * @return a virtual archive root folder, or null if the file is not actually an archive * @since 4.48 */ public static FileObject getArchiveRoot (FileObject fo) { URL archiveURL = URLMapper.findURL(fo, URLMapper.EXTERNAL); if (archiveURL == null) { return null; } return URLMapper.findFileObject(getArchiveRoot(archiveURL)); }
private FileElementQuery(final PHPParseResult result) { super(QueryScope.FILE_SCOPE); this.result = result; this.fileObject = result.getSnapshot().getSource().getFileObject(); this.url = fileObject != null ? URLMapper.findURL(fileObject, URLMapper.INTERNAL) : null; }
public void outputLineAction(OutputEvent arg0) { File javadoc = FileUtil.normalizeFile(new File(root)); FileObject fo = FileUtilities.toFileObject(javadoc); if (fo != null) { FileObject index = fo.getFileObject("index.html"); //NOI18N if (index != null) { URL link = URLMapper.findURL(index, URLMapper.EXTERNAL); HtmlBrowser.URLDisplayer.getDefault().showURL(link); } } }
if (resource != null) { FileObject root = classPath.findOwnerRoot(resource); URL url = URLMapper.findURL(root, URLMapper.INTERNAL); SourceForBinaryQuery.Result res = SourceForBinaryQuery.findSourceRoots(url); FileObject[] rootz = res.getRoots();
public static ClasspathInfo getClasspathInfoFor(FileObject ... files) { assert files.length >0; Set<URL> dependentRoots = new HashSet(); for (FileObject fo: files) { Project p = null; if (fo!=null) p=FileOwnerQuery.getOwner(fo); if (p!=null) { URL sourceRoot = URLMapper.findURL(ClassPath.getClassPath(fo, ClassPath.SOURCE).findOwnerRoot(fo), URLMapper.INTERNAL); dependentRoots.addAll(SourceUtils.getDependentRoots(sourceRoot)); for (SourceGroup root:ProjectUtils.getSources(p).getSourceGroups("java")) { dependentRoots.add(URLMapper.findURL(root.getRootFolder(), URLMapper.INTERNAL)); } } else { for(ClassPath cp: GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE)) { for (FileObject root:cp.getRoots()) { dependentRoots.add(URLMapper.findURL(root, URLMapper.INTERNAL)); } } } } ClassPath rcp = ClassPathSupport.createClassPath(dependentRoots.toArray(new URL[dependentRoots.size()])); // ClassPath nullPath = ClassPathSupport.createClassPath(new FileObject[0]); ClassPath boot = ClassPath.getClassPath(files[0], ClassPath.BOOT); ClassPath compile = ClassPath.getClassPath(files[0], ClassPath.COMPILE); ClasspathInfo cpInfo = ClasspathInfo.create(boot, compile, rcp); return cpInfo; }
private Problem setParameters(boolean checkOnly) { if (panel==null) return null; URL url = URLMapper.findURL(panel.getTargeFolder(), URLMapper.EXTERNAL); try { refactoring.setTarget(Lookups.singleton(new URL(url.toExternalForm()))); } catch (MalformedURLException ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } if (checkOnly) { return refactoring.fastCheckParameters(); } else { return refactoring.checkParameters(); } }
public void outputLineAction(OutputEvent arg0) { File site = FileUtil.normalizeFile(root); FileObject fo = FileUtilities.toFileObject(site); if (fo != null) { FileObject index = fo.getFileObject("index.html"); //NOI18N if (index != null) { URL link = URLMapper.findURL(index, URLMapper.EXTERNAL); HtmlBrowser.URLDisplayer.getDefault().showURL(link); } } }
public void actionPerformed(ActionEvent event) { File javadocFile = getJavadocFile(); FileObject fo = FileUtil.toFileObject(javadocFile); if (fo != null) { FileObject jarfo = FileUtil.getArchiveRoot(fo); if (jarfo != null) { FileObject index = jarfo.getFileObject("apidocs/index.html"); //NOI18N if (index == null) { index = jarfo.getFileObject("index.html"); //NOI18N } if (index == null) { index = jarfo; } URL link = URLMapper.findURL(index, URLMapper.EXTERNAL); HtmlBrowser.URLDisplayer.getDefault().showURL(link); } } }