本文整理汇总了Java中org.openide.filesystems.URLMapper.getURL方法的典型用法代码示例。如果您正苦于以下问题:Java URLMapper.getURL方法的具体用法?Java URLMapper.getURL怎么用?Java URLMapper.getURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.URLMapper
的用法示例。
在下文中一共展示了URLMapper.getURL方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getURLOfAppropriateType
import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
/** 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);
}
示例2: testFileURLMapping
import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
/** 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());
}
示例3: testEmptyFileURLMapping
import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
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());
}
示例4: testDirURLMapping
import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
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());
}
示例5: testFileWithSpacesURLMapping
import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
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());
}
示例6: testInternalMapping
import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
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);
}
示例7: testGetURL64012
import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
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
}
示例8: testGetURL155742
import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
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("/"));
}