|
xmlgraphics-commons 1.5 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.xmlgraphics.util.i18n.LocalizableSupport
public class LocalizableSupport
This class provides a default implementation of the Localizable interface. You can use it as a base class or as a member field and delegates various work to it.
For example, to implement Localizable, the following code can be used:
package mypackage;
...
public class MyClass implements Localizable {
// This code fragment requires a file named
// 'mypackage/resources/Messages.properties', or a
// 'mypackage.resources.Messages' class which extends
// java.util.ResourceBundle, accessible using the current
// classpath.
LocalizableSupport localizableSupport =
new LocalizableSupport("mypackage.resources.Messages");
public void setLocale(Locale l) {
localizableSupport.setLocale(l);
}
public Local getLocale() {
return localizableSupport.getLocale();
}
public String formatMessage(String key, Object[] args) {
return localizableSupport.formatMessage(key, args);
}
}
The algorithm for the Locale lookup in a LocalizableSupport object is:
Note: if no group is specified a LocalizableSupport object belongs to a default group common to each instance of LocalizableSupport.
| Field Summary | |
|---|---|
protected String |
bundleName
The resource bundle classname. |
protected ClassLoader |
classLoader
The classloader to use to create the resource bundle. |
protected Locale |
locale
The current locale. |
protected LocaleGroup |
localeGroup
The locale group to which this object belongs. |
protected ResourceBundle |
resourceBundle
The resources |
protected Locale |
usedLocale
The locale in use. |
| Constructor Summary | |
|---|---|
LocalizableSupport(String s)
Same as LocalizableSupport(s, null). |
|
LocalizableSupport(String s,
ClassLoader cl)
Creates a new Localizable object. |
|
| Method Summary | |
|---|---|
String |
formatMessage(String key,
Object[] args)
Implements Localizable.formatMessage(String,Object[]). |
Locale |
getDefaultLocale()
Implements ExtendedLocalizable.getDefaultLocale(). |
Locale |
getLocale()
Implements Localizable.getLocale(). |
LocaleGroup |
getLocaleGroup()
Implements ExtendedLocalizable.getLocaleGroup(). |
ResourceBundle |
getResourceBundle()
Implements ExtendedLocalizable.getResourceBundle(). |
void |
setDefaultLocale(Locale l)
Implements ExtendedLocalizable.setDefaultLocale(Locale). |
void |
setLocale(Locale l)
Implements Localizable.setLocale(Locale). |
void |
setLocaleGroup(LocaleGroup lg)
Implements ExtendedLocalizable.setLocaleGroup(LocaleGroup). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected LocaleGroup localeGroup
protected String bundleName
protected ClassLoader classLoader
protected Locale locale
protected Locale usedLocale
protected ResourceBundle resourceBundle
| Constructor Detail |
|---|
public LocalizableSupport(String s)
public LocalizableSupport(String s,
ClassLoader cl)
s - must be the name of the class to use to get the appropriate
resource bundle given the current locale.cl - is the classloader used to create the resource bundle,
or null.ResourceBundle| Method Detail |
|---|
public void setLocale(Locale l)
Localizable.setLocale(Locale).
setLocale in interface Localizablel - The locale to set.public Locale getLocale()
Localizable.getLocale().
getLocale in interface Localizablepublic void setLocaleGroup(LocaleGroup lg)
ExtendedLocalizable.setLocaleGroup(LocaleGroup).
public LocaleGroup getLocaleGroup()
ExtendedLocalizable.getLocaleGroup().
public void setDefaultLocale(Locale l)
ExtendedLocalizable.setDefaultLocale(Locale).
Later invocations of the instance methods will lead to update the
resource bundle used.
public Locale getDefaultLocale()
ExtendedLocalizable.getDefaultLocale().
public String formatMessage(String key,
Object[] args)
Localizable.formatMessage(String,Object[]).
formatMessage in interface Localizablekey - The key used to retreive the message from the resource
bundle.args - The objects that compose the message.public ResourceBundle getResourceBundle()
ExtendedLocalizable.getResourceBundle().
|
xmlgraphics-commons 1.5 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||