|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.runtime.FileLocator
public final class FileLocator
This class contains collection of helper methods aimed at finding files in bundles. This class can only be used if OSGi plugin is available.
The class is not intended to be subclassed or instantiated by clients.
Method Summary | |
---|---|
static java.net.URL |
find(Bundle bundle,
IPath path,
java.util.Map override)
Returns a URL for the given path in the given bundle. |
static java.net.URL[] |
findEntries(Bundle bundle,
IPath path)
Same as findEntries(Bundle, IPath) except multiple entries
can be returned if more than one entry matches the path in the host
any of its fragments. |
static java.net.URL[] |
findEntries(Bundle bundle,
IPath path,
java.util.Map override)
Same as findEntries(Bundle, IPath, Map) except multiple entries
can be returned if more than one entry matches the path in the host and
any of its fragments. |
static java.io.InputStream |
openStream(Bundle bundle,
IPath file,
boolean substituteArgs)
Returns an input stream for the specified file. |
static java.net.URL |
resolve(java.net.URL url)
Converts a URL that uses a client-defined protocol into a URL that uses a protocol which is native to the Java class library (file, jar, http, etc). |
static java.net.URL |
toFileURL(java.net.URL url)
Converts a URL that uses a user-defined protocol into a URL that uses the file protocol. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.net.URL find(Bundle bundle, IPath path, java.util.Map override)
null
if the URL
could not be computed or created.
find looks for this path in given bundle and any attached fragments.
null
is returned if no such entry is found. Note that
there is no specific order to the fragments.
The following arguments may also be used
$nl$ - for language specific information $os$ - for operating system specific information $ws$ - for windowing system specific information
A path of $nl$/about.properties in an environment with a default locale of en_CA will return a URL corresponding to the first place about.properties is found according to the following order:
plugin root/nl/en/CA/about.properties fragment1 root/nl/en/CA/about.properties fragment2 root/nl/en/CA/about.properties ... plugin root/nl/en/about.properties fragment1 root/nl/en/about.properties fragment2 root/nl/en/about.properties ... plugin root/about.properties fragment1 root/about.properties fragment2 root/about.properties ...
The current environment variable values can be overridden using
the override map argument or null
can be specified
if this is not desired.
bundle
- the bundle in which to searchpath
- file path relative to plug-in installation locationoverride
- map of override substitution arguments to be used for
any $arg$ path elements. The map keys correspond to the substitution
arguments (eg. "$nl$" or "$os$"). The resulting
values must be of type java.lang.String. If the map is null
,
or does not contain the required substitution argument, the default
is used.
null
. The actual form
of the returned URL is not specified.public static java.net.URL[] findEntries(Bundle bundle, IPath path, java.util.Map override)
findEntries(Bundle, IPath, Map)
except multiple entries
can be returned if more than one entry matches the path in the host and
any of its fragments.
bundle
- the bundle in which to searchpath
- file path relative to plug-in installation locationoverride
- map of override substitution arguments to be used for
any $arg$ path elements. The map keys correspond to the substitution
arguments (eg. "$nl$" or "$os$"). The resulting
values must be of type java.lang.String. If the map is null
,
or does not contain the required substitution argument, the default
is used.
public static java.net.URL[] findEntries(Bundle bundle, IPath path)
findEntries(Bundle, IPath)
except multiple entries
can be returned if more than one entry matches the path in the host
any of its fragments.
bundle
- the bundle in which to searchpath
- file path relative to plug-in installation location
public static java.io.InputStream openStream(Bundle bundle, IPath file, boolean substituteArgs) throws java.io.IOException
find(Bundle, IPath, Map)
.
The caller must close the returned stream when done.
bundle
- the bundle in which to searchfile
- path relative to plug-in installation locationsubstituteArgs
- true
to process substitution arguments,
and false
for the file exactly as specified without processing any
substitution arguments.
java.io.IOException
- if the given path cannot be found in this plug-inpublic static java.net.URL toFileURL(java.net.URL url) throws java.io.IOException
If the protocol for the given URL is not recognized by this converter, the original URL is returned as-is.
url
- the original URL
java.io.IOException
- if an error occurs during the conversionpublic static java.net.URL resolve(java.net.URL url) throws java.io.IOException
Note however that users of this API should not assume too much about the results of this method. While it may consistently return a file: URL in certain installation configurations, others may result in jar: or http: URLs.
If the protocol is not recognized by this converter, then the original URL is returned as-is.
url
- the original URL
java.io.IOException
- if unable to resolve URL
java.io.IOException
- if an error occurs during the resolution
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |