|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface ResourceProvider
ResourceProvider is used to access resources
provided by bundles installed on the OSGi Framework.
Such resource bundles should have the following manifest header
to determine the resources configuration file:
Resource-Config: xxx_config.xml
Example of resource configuration file:
<resource-provider>
<resource>
<type>ICQ.oven</type>
<file>/resources/oven</file>
</resource>
</resource-provider>
There are two kinds of resources:
file tag has to contain the file pathname and
the file name without the ".properties" file extension and
without language and contry suffix.
For example:
You have following files
java.util.Locale-s which have language "en"
java.util.Locale.US
<file>/resources/oven</file>
The bundle that uses the ResourceProvider has to describe in its
manifest header the used resource types:
Resource-Type: ICQ.oven, xxxIf there is a duplicate resource id in the property files of different types then the first found will be used.
For example:
In the properties file from type ICQ.oven there is:
1=YESIn the properties file from type xxx there is:
1=NOYou want the resource with id 1. The result will be "YES" because ICQ.oven is before the xxx in the manifest header.
The resource ids of the property files can be Strings or numbers.
Strings are deprecated.
If there are numbers, the XML has to contain one or more range tags.
For example:
....
<resource>
<type>...</type>
<file>...</file>
<range>1:99</range>
<range>200:500</range>
</resource>
...
If the desired resource is a String with dynamic parameters, this method
may format the resource according to the given resource parameters (if not null) and
java.text.MessageFormat will be used.
The supported parameter format is:
resource_id = <message_part_0> {0} <message_part_1> {1} ... <messane_part_n> {n} ...
Where {n} (n >= 0) defines the user parameters.
Let's have the following resource example:
"The file with location XXX will be deleted. Are you sure?"For English we will have the following message template:
1 = The file with location {0} will be deleted. Are you sure?
For French we will have the following message template:
1 = Le fichier avec le nom "{0}" sera supprime. Etes-vous sur?
And for German we will have the following message template:
1 = Die Akte mit relativer Satznummer {0} wird gelöscht. Sind Sie sicher?
When the user want to use this message he/she must invoke the following:String formatted = resourceProvider.getString(1, new Object[] {"d:\\my_files\\my_file.del"});
If you know that one language will be used for the entire system
the method setLocale can be used to set the new Locale for the entire system.
After that you can use other methods to get the resources without to give the current Locale.
Of course when the language in the entire system is changed,
the method setLocale has to be called again.
| Method Summary | |
|---|---|
java.lang.Object |
getResource(boolean isURL,
java.lang.String resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Get resource from resource providers, represented as bundles, installed on the OSGi Framework. |
java.lang.Object |
getResource(java.lang.String resourceType,
java.lang.String resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Get resource from resource providers, represented as bundles, installed on the OSGi Framework. |
java.lang.String |
getString(int resourceID)
Get resource according to specific id. |
java.lang.String |
getString(int resourceID,
java.util.Locale locale)
Get resource according to specific id. |
java.lang.String |
getString(int resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Get resource according to specific id. |
java.lang.String |
getString(int resourceID,
java.lang.Object[] params)
Get resource according to specific id. |
java.lang.String |
getString(java.lang.String resourceID)
Get resource according to specific id. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
int resourceID)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale locale)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale[] locale,
java.lang.Object[] params)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
int resourceID,
java.lang.Object[] params)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
java.lang.String resourceID)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale locale)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale[] locale,
java.lang.Object[] params)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.lang.Object[] params)
Get resource according to specific id and resource types. |
java.lang.String |
getString(java.lang.String resourceID,
java.util.Locale locale)
Get resource according to specific id. |
java.lang.String |
getString(java.lang.String resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Get resource according to specific id. |
java.lang.String |
getString(java.lang.String resourceID,
java.lang.Object[] params)
Get resource according to specific id. |
java.lang.String[] |
getTypes()
You can get the types which are described in the manifest |
java.net.URL |
getURL(int resourceID)
Get resource according to specific id from the bundle which contains this id. |
java.net.URL |
getURL(int resourceID,
java.util.Locale locale)
Get resource according to specific id from the bundle which contains this id. |
java.net.URL |
getURL(java.lang.String resourceID)
Get resource according to specific id from the bundle which contains this id. |
java.net.URL |
getURL(java.lang.String[] resourceTypes,
int resourceID)
Get resource according to specific id and types from the bundle which contains this id. |
java.net.URL |
getURL(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale locale)
Get resource according to specific id and types from the bundle which contains this id. |
java.net.URL |
getURL(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale[] locale)
Get resource according to specific id and types from the bundle which contains this id. |
java.net.URL |
getURL(java.lang.String[] resourceTypes,
java.lang.String resourceID)
Get resource according to specific id and types from the bundle which contains this id. |
java.net.URL |
getURL(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale locale)
Get resource according to specific id and types from the bundle which contains this id. |
java.net.URL |
getURL(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale[] locale)
Get resource according to specific id and types from the bundle which contains this id. |
java.net.URL |
getURL(java.lang.String resourceID,
java.util.Locale locale)
Get resource according to specific id from the bundle which contains this id. |
void |
setLocale(java.util.Locale locale)
You can set locale for the entire system and the Resource Provider will use it when you get a resource whitout locale. |
| Method Detail |
|---|
java.lang.Object getResource(boolean isURL,
java.lang.String resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Locale.getDefault()).
isURL - the type of the resource. If it's true then java.net.URL
will be returned otherwise - java.lang.StringresourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.params - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
String or
URL, it depends on the parameter isString.
java.lang.Object getResource(java.lang.String resourceType,
java.lang.String resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Locale.getDefault()).
resourceType - the type of the resource. If it starts with url: then java.net.URL
will be returned otherwise - java.lang.StringresourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.params - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
String or
URL, it depends on the parameter isString.java.lang.String getString(java.lang.String resourceID)
resourceID - the id of the resource
java.lang.String getString(java.lang.String resourceID,
java.util.Locale locale)
Locale.getDefault()).
resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.
java.lang.String getString(java.lang.String resourceID,
java.lang.Object[] params)
resourceID - the id of the resourceparams - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.String getString(java.lang.String resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Locale.getDefault()).
resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.params - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.String getString(java.lang.String[] resourceTypes,
java.lang.String resourceID)
null.
resourceTypes - the resource types.resourceID - the id of the resource
java.lang.NullPointerException - if the resourceTypes is null.
java.lang.String getString(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale locale)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.
java.lang.NullPointerException - if the resourceTypes is null.
java.lang.String getString(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.lang.Object[] params)
null.
resourceTypes - the resource types.resourceID - the id of the resourceparams - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.NullPointerException - if the resourceTypes is null.
java.lang.String getString(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.params - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.NullPointerException - if the resourceTypes is null.
java.lang.String getString(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale[] locale,
java.lang.Object[] params)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locales of the resource, if null then the
locale for the entire system will be used.params - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.NullPointerException - if the resourceTypes is null.java.lang.String getString(int resourceID)
resourceID - the id of the resource
java.lang.String getString(int resourceID,
java.util.Locale locale)
Locale.getDefault()).
resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.
java.lang.String getString(int resourceID,
java.lang.Object[] params)
resourceID - the id of the resourceparams - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.String getString(int resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Locale.getDefault()).
resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.params - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.String getString(java.lang.String[] resourceTypes,
int resourceID)
null.
resourceTypes - the resource types.resourceID - the id of the resource
java.lang.NullPointerException - if the resourceTypes is null.
java.lang.String getString(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale locale)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.
java.lang.NullPointerException - if the resourceTypes is null.
java.lang.String getString(java.lang.String[] resourceTypes,
int resourceID,
java.lang.Object[] params)
null.
resourceTypes - the resource types.resourceID - the id of the resourceparams - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.NullPointerException - if the resourceTypes is null.
java.lang.String getString(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale locale,
java.lang.Object[] params)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.params - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.NullPointerException - if the resourceTypes is null.
java.lang.String getString(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale[] locale,
java.lang.Object[] params)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locales of the resource, if null then the
locale for the entire system will be used.params - the set of arguments, that will be used to format the
dynamic parameters of the string resource. If no formatting is necessary or
this is not a string resource, pass a null value.
java.lang.NullPointerException - if the resourceTypes is null.java.net.URL getURL(java.lang.String resourceID)
resourceID - the id of the resource
java.net.URL or null.
java.net.URL getURL(java.lang.String resourceID,
java.util.Locale locale)
Locale.getDefault()).
resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.
java.net.URL or null.
java.net.URL getURL(java.lang.String[] resourceTypes,
java.lang.String resourceID)
null.
resourceTypes - the resource types.resourceID - the id of the resource
java.net.URL or null.
java.lang.NullPointerException - if the resourceTypes is null.
java.net.URL getURL(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale locale)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.
java.net.URL or null.
java.lang.NullPointerException - if the resourceTypes is null.
java.net.URL getURL(java.lang.String[] resourceTypes,
java.lang.String resourceID,
java.util.Locale[] locale)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locales of the resource, if null then the
locale for the entire system will be used.
java.net.URL or null.
java.lang.NullPointerException - if the resourceTypes is null.java.net.URL getURL(int resourceID)
resourceID - the id of the resource
java.net.URL or null.
java.net.URL getURL(int resourceID,
java.util.Locale locale)
Locale.getDefault()).
resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.
java.net.URL or null.
java.net.URL getURL(java.lang.String[] resourceTypes,
int resourceID)
null.
resourceTypes - the resource types.resourceID - the id of the resource
java.net.URL or null.
java.lang.NullPointerException - if the resourceTypes is null.
java.net.URL getURL(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale locale)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locale of the resource, if null then the
locale for the entire system will be used.
java.net.URL or null.
java.lang.NullPointerException - if the resourceTypes is null.
java.net.URL getURL(java.lang.String[] resourceTypes,
int resourceID,
java.util.Locale[] locale)
Locale.getDefault()).
The resourceTypes can not be null.
resourceTypes - the resource types.resourceID - the id of the resourcelocale - the desired locales of the resource, if null then the
locale for the entire system will be used.
java.net.URL or null.
java.lang.NullPointerException - if the resourceTypes is null.java.lang.String[] getTypes()
void setLocale(java.util.Locale locale)
locale - the locale for the entire system
|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||