|
|||||||||
| Home >> All >> org >> apache >> batik >> [ i18n overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.batik.i18n
Class LocalizableSupport

java.lang.Objectorg.apache.batik.i18n.LocalizableSupport
- All Implemented Interfaces:
- Localizable
- public class LocalizableSupport
- extends java.lang.Object
- implements Localizable
- extends java.lang.Object
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:
- if a Locale has been set by a call to setLocale(), use this Locale, else,
- if a Locale has been set by a call to the setDefaultLocale() method of a LocalizableSupport object in the current LocaleGroup, use this Locale, else,
- use the object returned by Locale.getDefault() (and set by Locale.setDefault()).
Note: if no group is specified a LocalizableSupport object belongs to a default group common to each instance of LocalizableSupport.
- Version:
- $Id: LocalizableSupport.java,v 1.7 2004/08/18 07:14:45 vhardy Exp $
| Field Summary | |
protected java.lang.String |
bundleName
The resource bundle classname. |
protected java.lang.ClassLoader |
classLoader
The classloader to use to create the resource bundle. |
protected java.util.Locale |
locale
The current locale. |
protected LocaleGroup |
localeGroup
The locale group to which this object belongs. |
protected java.util.ResourceBundle |
resourceBundle
The resources |
protected java.util.Locale |
usedLocale
The locale in use. |
| Constructor Summary | |
LocalizableSupport(java.lang.String s)
Same as LocalizableSupport(s, null). |
|
LocalizableSupport(java.lang.String s,
java.lang.ClassLoader cl)
Creates a new Localizable object. |
|
| Method Summary | |
java.lang.String |
formatMessage(java.lang.String key,
java.lang.Object[] args)
Implements Localizable.formatMessage(String,Object[]) 55 . |
java.util.Locale |
getDefaultLocale()
Implements ExtendedLocalizable.getDefaultLocale() 55 . |
java.util.Locale |
getLocale()
Implements Localizable.getLocale() 55 . |
LocaleGroup |
getLocaleGroup()
Implements ExtendedLocalizable.getLocaleGroup() 55 . |
java.util.ResourceBundle |
getResourceBundle()
Implements ExtendedLocalizable.getResourceBundle() 55 . |
void |
setDefaultLocale(java.util.Locale l)
Implements ExtendedLocalizable.setDefaultLocale(Locale) 55 . |
void |
setLocale(java.util.Locale l)
Implements Localizable.setLocale(Locale) 55 . |
void |
setLocaleGroup(LocaleGroup lg)
Implements ExtendedLocalizable.setLocaleGroup(LocaleGroup) 55 . |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
localeGroup
protected LocaleGroup localeGroup
- The locale group to which this object belongs.
bundleName
protected java.lang.String bundleName
- The resource bundle classname.
classLoader
protected java.lang.ClassLoader classLoader
- The classloader to use to create the resource bundle.
locale
protected java.util.Locale locale
- The current locale.
usedLocale
protected java.util.Locale usedLocale
- The locale in use.
resourceBundle
protected java.util.ResourceBundle resourceBundle
- The resources
| Constructor Detail |
LocalizableSupport
public LocalizableSupport(java.lang.String s)
- Same as LocalizableSupport(s, null).
LocalizableSupport
public LocalizableSupport(java.lang.String s, java.lang.ClassLoader cl)
- Creates a new Localizable object.
The resource bundle class name is required allows the use of custom
classes of resource bundles.
| Method Detail |
setLocale
public void setLocale(java.util.Locale l)
- Implements
Localizable.setLocale(Locale)55 .- Specified by:
setLocalein interfaceLocalizable
getLocale
public java.util.Locale getLocale()
- Implements
Localizable.getLocale()55 .- Specified by:
getLocalein interfaceLocalizable
setLocaleGroup
public void setLocaleGroup(LocaleGroup lg)
- Implements
ExtendedLocalizable.setLocaleGroup(LocaleGroup)55 .
getLocaleGroup
public LocaleGroup getLocaleGroup()
- Implements
ExtendedLocalizable.getLocaleGroup()55 .
setDefaultLocale
public void setDefaultLocale(java.util.Locale l)
- Implements
ExtendedLocalizable.setDefaultLocale(Locale)55 . Later invocations of the instance methods will lead to update the resource bundle used.
getDefaultLocale
public java.util.Locale getDefaultLocale()
- Implements
ExtendedLocalizable.getDefaultLocale()55 .
formatMessage
public java.lang.String formatMessage(java.lang.String key, java.lang.Object[] args)
- Implements
Localizable.formatMessage(String,Object[])55 .- Specified by:
formatMessagein interfaceLocalizable
getResourceBundle
public java.util.ResourceBundle getResourceBundle()
- Implements
ExtendedLocalizable.getResourceBundle()55 .
|
|||||||||
| Home >> All >> org >> apache >> batik >> [ i18n overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.batik.i18n.LocalizableSupport