站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

URLMapper (File System API) - NetBeans API Javadoc (Current Development Version)

org.openide.filesystems 7.1

org.openide.filesystems
Class URLMapper

java.lang.Object
  extended by org.openide.filesystems.URLMapper

public abstract class URLMapper
extends Object

Mapper from FileObject -> URL. Should be registered in default lookup. For details see Lookup.getDefault(). For all methods, if the passed-in file object is the root folder of some filesystem, then it is assumed that any valid file object in that filesystem may also have a URL constructed for it by means of appending the file object's resource path to the URL of the root folder. If this cannot work for all file objects on the filesystem, the root folder must not be assigned a URL of that type. nbfs: URLs of course always work correctly in this regard.

Since:
2.16

Field Summary
static int EXTERNAL
          URL which works inside this machine.
static int INTERNAL
          URL which works inside this VM.
static int NETWORK
          URL which works from networked machines.
 
Constructor Summary
URLMapper()
           
 
Method Summary
static FileObject findFileObject(URL url)
          Find an appropriate instance of FileObject that addresses this URL
static FileObject[] findFileObjects(URL url)
          Deprecated. Use findFileObject(java.net.URL) instead.
static URL findURL(FileObject fo, int type)
          Find a good URL for this file object which works according to type: inside this VM inside this machine from networked machines
abstract  FileObject[] getFileObjects(URL url)
          Get an array of FileObjects for this URL.
abstract  URL getURL(FileObject fo, int type)
          Get a good URL for this file object which works according to type: inside this VM inside this machine from networked machines The implementation can't use neither FileUtil.toFile(org.openide.filesystems.FileObject) nor FileUtil.toFileObject(java.io.File) otherwise StackOverflowError maybe thrown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERNAL

public static final int INTERNAL
URL which works inside this VM. Not guaranteed to work outside the VM (though it may).

See Also:
Constant Field Values

EXTERNAL

public static final int EXTERNAL
URL which works inside this machine. Not guaranteed to work from other machines (though it may).
Typical protocols used: file for disk files (see File.toURI()); jar to wrap other URLs (e.g. jar:file:/some/thing.jar!/some/entry).

See Also:
Constant Field Values

NETWORK

public static final int NETWORK
URL which works from networked machines.

See Also:
Constant Field Values
Constructor Detail

URLMapper

public URLMapper()
Method Detail

findURL

public static URL findURL(FileObject fo,
                          int type)
Find a good URL for this file object which works according to type:
  • inside this VM
  • inside this machine
  • from networked machines

Returns:
a suitable URL, or null

getURL

public abstract URL getURL(FileObject fo,
                           int type)
Get a good URL for this file object which works according to type:
  • inside this VM
  • inside this machine
  • from networked machines
The implementation can't use neither FileUtil.toFile(org.openide.filesystems.FileObject) nor FileUtil.toFileObject(java.io.File) otherwise StackOverflowError maybe thrown.

Returns:
a suitable URL, or null

findFileObjects

@Deprecated
public static FileObject[] findFileObjects(URL url)
Deprecated. Use findFileObject(java.net.URL) instead.

Find an array of FileObjects for this URL. Zero or more FOs may be returned. For each returned FO, it must be true that FO -> URL gives the exact URL which was passed in, but depends on appropriate type findURL(FileObject fo, int type) .

Parameters:
url - to wanted FileObjects
Returns:
a suitable array of FileObjects, or empty array if not successful
Since:
2.22

findFileObject

public static FileObject findFileObject(URL url)
Find an appropriate instance of FileObject that addresses this URL

Parameters:
url - URL to be converted to file object
Returns:
file object corresponding to URL or null if no one was found
Since:
4.29

getFileObjects

public abstract FileObject[] getFileObjects(URL url)
Get an array of FileObjects for this URL. There is no reason to return array with size greater than one because method findFileObject uses just the first element (subsequent elements will not be accepted anyway). The implementation cannot use either FileUtil.toFile(org.openide.filesystems.FileObject) nor FileUtil.toFileObject(java.io.File) or StackOverflowError may be thrown.

The only reason to return an array here is for backward compatibility.

Parameters:
url - to wanted FileObjects
Returns:
an array of FileObjects with size no greater than one, or null
Since:
2.22

org.openide.filesystems 7.1

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.