jp.cssj.sakae.sac.i18n
クラス LocalizableSupport

java.lang.Object
  拡張jp.cssj.sakae.sac.i18n.LocalizableSupport
すべての実装インタフェース:
Localizable

public class LocalizableSupport
extends Object
implements Localizable

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: This offers the possibility to have a different Locale for each object, a Locale for a group of object and/or a Locale for the JVM instance.

Note: if no group is specified a LocalizableSupport object belongs to a default group common to each instance of LocalizableSupport.

バージョン:
$Id: LocalizableSupport.java,v 1.2 2007-05-06 04:24:06 miyabe Exp $
作成者:
Stephane Hillion

フィールドの概要
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.
 
コンストラクタの概要
LocalizableSupport(String s)
          Same as LocalizableSupport(s, null).
LocalizableSupport(String s, ClassLoader cl)
          Creates a new Localizable object.
 
メソッドの概要
 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) .
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

localeGroup

protected LocaleGroup localeGroup
The locale group to which this object belongs.


bundleName

protected String bundleName
The resource bundle classname.


classLoader

protected ClassLoader classLoader
The classloader to use to create the resource bundle.


locale

protected Locale locale
The current locale.


usedLocale

protected Locale usedLocale
The locale in use.


resourceBundle

protected ResourceBundle resourceBundle
The resources

コンストラクタの詳細

LocalizableSupport

public LocalizableSupport(String s)
Same as LocalizableSupport(s, null).


LocalizableSupport

public LocalizableSupport(String s,
                          ClassLoader cl)
Creates a new Localizable object. The resource bundle class name is required allows the use of custom classes of resource bundles.

パラメータ:
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
メソッドの詳細

setLocale

public void setLocale(Locale l)
Implements Localizable.setLocale(Locale) .

定義:
インタフェース Localizable 内の setLocale
パラメータ:
l - The locale to set.

getLocale

public Locale getLocale()
Implements Localizable.getLocale().

定義:
インタフェース Localizable 内の getLocale

setLocaleGroup

public void setLocaleGroup(LocaleGroup lg)
Implements ExtendedLocalizable.setLocaleGroup(LocaleGroup) .


getLocaleGroup

public LocaleGroup getLocaleGroup()
Implements ExtendedLocalizable.getLocaleGroup() .


setDefaultLocale

public void setDefaultLocale(Locale l)
Implements ExtendedLocalizable.setDefaultLocale(Locale) . Later invocations of the instance methods will lead to update the resource bundle used.


getDefaultLocale

public Locale getDefaultLocale()
Implements ExtendedLocalizable.getDefaultLocale() .


formatMessage

public String formatMessage(String key,
                            Object[] args)
Implements Localizable.formatMessage(String,Object[]) .

定義:
インタフェース Localizable 内の formatMessage
パラメータ:
key - The key used to retreive the message from the resource bundle.
args - The objects that compose the message.

getResourceBundle

public ResourceBundle getResourceBundle()
Implements ExtendedLocalizable.getResourceBundle() .



(c)2009 GNN & Co.,Ltd.