Java Code Examples for org.openide.filesystems.URLMapper#getURL()
The following examples show how to use
org.openide.filesystems.URLMapper#getURL() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileBasedURLMapperTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testGetURL64012() throws Exception { int type = URLMapper.NETWORK; FileObject fo = FileUtil.toFileObject(getWorkDir()); assertNotNull(fo); URLMapper instance = new FileBasedURLMapper(); URL result = instance.getURL(fo, type); assertNull(result);//NOI18N }
Example 2
Source File: FileBasedURLMapperTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testGetURL155742() throws Exception { clearWorkDir(); File f = new File(getWorkDir(), "dummy"); assertTrue(f.mkdir()); FileObject fo = FileUtil.toFileObject(f); assertNotNull(fo); f.delete(); URLMapper instance = new FileBasedURLMapper(); URL result = instance.getURL(fo, URLMapper.INTERNAL); assertTrue("Folder URL must always end with slash.", result.toExternalForm().endsWith("/")); }
Example 3
Source File: URLUtil.java From netbeans with Apache License 2.0 | 5 votes |
/** Returns a URL for the given file object that can be correctly interpreted * by usual web browsers (including Netscape 4.71, IE and Mozilla). * First attempts to get an EXTERNAL URL, if that is a suitable URL, it is used; * otherwise a NETWORK URL is used. */ private static URL getURLOfAppropriateType(FileObject fo, boolean allowJar) { // PENDING - there is still the problem that the HTTP server will be started // (because the HttpServerURLMapper.getURL(...) method starts it), // even when it is not needed URL retVal; URL suitable = null; Iterator instances = result.allInstances ().iterator(); while (instances.hasNext()) { URLMapper mapper = (URLMapper) instances.next(); retVal = mapper.getURL (fo, URLMapper.EXTERNAL); if ((retVal != null) && isAcceptableProtocol(retVal, allowJar)) { // return if this is a 'file' or 'jar' URL String p = retVal.getProtocol().toLowerCase(); if ("file".equals(p) || "jar".equals(p)) { // NOI18N return retVal; } suitable = retVal; } } // if we found a suitable URL, return it if (suitable != null) { return suitable; } URL url = URLMapper.findURL(fo, URLMapper.NETWORK); if (url == null){ Logger.getLogger("global").log(Level.SEVERE, "URLMapper.findURL() failed for " + fo); //NOI18N return null; } return makeURLLocal(url); }
Example 4
Source File: URLMapperTest.java From netbeans with Apache License 2.0 | 5 votes |
/** simple test case */ public void testFileURLMapping() throws Exception { FileObject fo = getTestFSRoot().getFileObject("org/netbeans/test/httpserver/testResource.txt"); URLMapper mapper = getMapper(); URL url = mapper.getURL(fo, URLMapper.NETWORK); checkFileObjectURLMapping(fo, url, getMapper()); }
Example 5
Source File: URLMapperTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testEmptyFileURLMapping() throws Exception { FileObject fo = getTestFSRoot().getFileObject("org/netbeans/test/httpserver/empty"); URLMapper mapper = getMapper(); URL url = mapper.getURL(fo, URLMapper.NETWORK); checkFileObjectURLMapping(fo, url, getMapper()); }
Example 6
Source File: URLMapperTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testDirURLMapping() throws Exception { FileObject fo = getTestFSRoot().getFileObject("org/netbeans/test/httpserver"); URLMapper mapper = getMapper(); URL url = mapper.getURL(fo, URLMapper.NETWORK); checkFileObjectURLMapping(fo, url, getMapper()); }
Example 7
Source File: URLMapperTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testFileWithSpacesURLMapping() throws Exception { FileObject fo = getTestFSRoot().getFileObject("org/netbeans/test/httpserver/dir with spaces/file with spaces.txt"); URLMapper mapper = getMapper(); URL url = mapper.getURL(fo, URLMapper.NETWORK); if (url != null) { // the case that the URL is null will be caught anyhow later if (url.toExternalForm().indexOf(' ') != -1) { fail("External URL contains spaces: " + url); } } checkFileObjectURLMapping(fo, url, getMapper()); }
Example 8
Source File: URLMapperTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testInternalMapping() throws Exception { FileObject fo = getTestFSRoot().getFileObject("org/netbeans/test/httpserver/testResource.txt"); assertNotNull("File tested is null " + fo, fo); URLMapper mapper = getMapper(); URL url = mapper.getURL(fo, URLMapper.INTERNAL); // our mapper does not provide mapping for these assertNull("Internal mapping for file " + fo + " should be null: " + url, url); }