|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IPluginResourceLoader
This class presents an abstraction layer for accessing resources from within a platform plugin. The idea is you do not need to know how to absolutely resolve the resources you need. For example: You don't need to know the absolute path if your resources are on a file-system. All you need to know in order to obtain a resource is the relative path to the resource. "Relative" means relative to the base location of your plugin. For a filesystem example, let's say that your plugin is installed in "/home/user/plugins/myplugin" and you need the file "/home/user/plugins/myplugin/html/my.html", you would ask this class for the resource "html/my.html"
Method Summary | |
---|---|
List<URL> |
findResources(Class<?> pluginClass,
String namePattern)
A searching method, yielding a list of plugin-related resources as URLs. |
List<URL> |
findResources(ClassLoader classLoader,
String namePattern)
|
String |
getPluginSetting(Class<?> pluginClass,
String key)
Searches for the plugin setting with the specified key. |
String |
getPluginSetting(Class<?> pluginClass,
String key,
String defaultValue)
Searches for the plugin setting with the specified key. |
String |
getPluginSetting(ClassLoader pluginClassLoader,
String key,
String defaultValue)
Searches for the plugin setting with the specified key. |
byte[] |
getResourceAsBytes(Class<? extends Object> pluginClass,
String resourcePath)
Gets a plugin-related resource in the form of an array of bytes. |
InputStream |
getResourceAsStream(Class<?> pluginClass,
String resourcePath)
Gets a plugin-related resource in the form of an InputStream. |
InputStream |
getResourceAsStream(ClassLoader classLoader,
String resourcePath)
Gets a plugin-related resource in the form of an InputStream. |
String |
getResourceAsString(Class<? extends Object> pluginClass,
String resourcePath)
Gets a plugin-related resource in the form of a String. |
String |
getResourceAsString(Class<? extends Object> pluginClass,
String resourcePath,
String charsetName)
Gets a plugin-related resource in the form of a String. |
ResourceBundle |
getResourceBundle(Class<?> pluginClass,
String baseName)
Retrieves a localized resource bundle for the plugin represented by pluginClass. |
Method Detail |
---|
byte[] getResourceAsBytes(Class<? extends Object> pluginClass, String resourcePath)
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
pluginClass
- a class that is part of the plugin package, used to identify the pluginresourcePath
- the (relative) path to a resource
String getResourceAsString(Class<? extends Object> pluginClass, String resourcePath) throws UnsupportedEncodingException
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
This method defaults the character encoding (how this default is chosen is up to the implementor).
pluginClass
- a class that is part of the plugin package, used to identify the pluginresourcePath
- the (relative) path to a resource
String
or null if the resource is not found
UnsupportedEncodingException
- if there is a problem encoding the stringString getResourceAsString(Class<? extends Object> pluginClass, String resourcePath, String charsetName) throws UnsupportedEncodingException
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
pluginClass
- a class that is part of the plugin package, used to identify the pluginresourcePath
- the (relative) path to a resourcecharsetName
- the character set to encode the string
String
or null if the resource is not found
UnsupportedEncodingException
- if there is a problem encoding the stringInputStream getResourceAsStream(Class<?> pluginClass, String resourcePath)
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
pluginClass
- a class that is part of the plugin package, used to identify the pluginresourcePath
- the (relative) path to a resource
InputStream
or null if the resource is not foundInputStream getResourceAsStream(ClassLoader classLoader, String resourcePath)
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
classLoader
- the ClassLoader which was used to load a pluginresourcePath
- the (relative) path to a resource
InputStream
or null if the resource is not foundList<URL> findResources(Class<?> pluginClass, String namePattern)
pluginClass
- namePattern
- a resource name pattern supporting wildcards
List<URL> findResources(ClassLoader classLoader, String namePattern)
findResources(Class, String)
ResourceBundle getResourceBundle(Class<?> pluginClass, String baseName)
getResourceBundle(Class, String)
should behave similar to ResourceBundle.getBundle(String)
pluginClass
- a class that is part of the plugin package, used to identify the pluginbaseName
- points to a particular resource bundle
ResourceBundle
MissingResourceException
- if resource bundle not foundResourceBundle
String getPluginSetting(Class<?> pluginClass, String key)
null
if the setting is not found.
pluginClass
- a class that is part of the plugin package, used to identify the pluginkey
- the setting key
String getPluginSetting(Class<?> pluginClass, String key, String defaultValue)
pluginClass
- a class that is part of the plugin package, used to identify the pluginkey
- the setting keydefaultValue
- the value to return if no value is found for the setting key
String getPluginSetting(ClassLoader pluginClassLoader, String key, String defaultValue)
pluginClassLoader
- the classloader that was used to load the plugin, must be a PluginClassLoaderkey
- the setting keydefaultValue
- the value to return if no value is found for the setting key
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |