|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractInternationalString
ResourceInternationalString
@Immutable public class ResourceInternationalString
An international string backed by a resource bundle. A resource bundle can be a Java class or a properties
file, one for each language. The constructor expects the fully qualified class name of the base
resource bundle (the one used when no resource was found in the client's language). The appropriate
resource bundle is loaded at runtime for the client's language by looking for a class or a
properties file with the right suffix, for example "_en" for English or "_fr"
for French. This mechanism is explained in J2SE javadoc for the
getBundle static method.
Example: If a file named "MyResources.properties" exists in the package
org.geotoolkit.mypackage and contains a line like "MyKey = some value",
then an international string for "some value" can be created using the following
code:
InternationalString value =
new ResourceInternationalString("org.geotoolkit.mypackage.MyResources", "MyKey");
The "some value" string will be localized if the required properties files exist, for
example "MyResources_fr.properties" for French, "MyResources_it.properties"
for Italian, etc.
| utility/geotk-utility (download) | View source code for this class |
| Constructor Summary | |
|---|---|
ResourceInternationalString(String resources,
String key)
Creates a new international string from the specified resource bundle and key. |
|
ResourceInternationalString(String resources,
String key,
ClassLoader loader)
Creates a new international string from the specified resource bundle, key and class loader. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object object)
Compares this international string with the specified object for equality. |
protected ResourceBundle |
getBundle(Locale locale)
Returns the resource bundle for the given locale. |
int |
hashCode()
Returns a hash code value for this international text. |
String |
toString(Locale locale)
Returns a string in the specified locale. |
| Methods inherited from class AbstractInternationalString |
|---|
charAt, compareTo, formatTo, length, subSequence, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ResourceInternationalString(String resources,
String key)
resources - The name of the resource bundle, as a fully qualified class name.key - The key for the resource to fetch.
public ResourceInternationalString(String resources,
String key,
ClassLoader loader)
resources - The name of the resource bundle, as a fully qualified class name.key - The key for the resource to fetch.loader - The class loader to use for loading the resources file,
or null for the default class loader.| Method Detail |
|---|
public String toString(Locale locale)
throws MissingResourceException
locale, then this method search for a string in an other locale as
specified in the ResourceBundle class description.
toString in interface InternationalStringtoString in class AbstractInternationalStringlocale - The locale to look for, or null for an unlocalized version.
MissingResourceException - is the key given to the constructor is invalid.protected ResourceBundle getBundle(Locale locale)
locale - The locale for which to get the resource bundle.
ResourceBundle.getBundle(String,Locale)public boolean equals(Object object)
equals in class Objectobject - The object to compare with this international string.
true if the given object is equal to this string.public int hashCode()
hashCode in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||