ariba.util.i18n
Class LocalizedJavaString

java.lang.Object
  extended by ariba.util.i18n.LocalizedJavaString
All Implemented Interfaces:
LocalizedStringInterface

public final class LocalizedJavaString
extends java.lang.Object
implements LocalizedStringInterface

Class LocalizedJavaString provides a way to strings in Java classes that should be localized.


Nested Class Summary
static interface LocalizedJavaString.Localizer
          A Localizer knows how to return a localized string given the key and class name.
static interface LocalizedJavaString.LocalizerWithSourceOfTruthLocale
          A Localizer knows how to return a localized string given the key and class name.
 
Constructor Summary
LocalizedJavaString(java.lang.String className, int key, java.lang.String originalString)
           
LocalizedJavaString(java.lang.String className, java.lang.String keyString, java.lang.String originalString)
           
 
Method Summary
 java.lang.String getClassName()
          Returns the classname associated with the original string
 java.lang.String getKey()
          Returns the key associated with the original string
 java.lang.String getLocalizedString(java.util.Locale locale)
           
static java.lang.String getLocalizedString(java.lang.String className, int key, java.lang.String originalString, java.util.Locale locale)
          Static method to return an aribaweb-style localized package string for the given arguments, without needless allocations.
static java.lang.String getLocalizedString(java.lang.String className, java.lang.String keyString, java.lang.String originalString, java.util.Locale locale)
          Static method to return an aribaweb-style localized package string for the given arguments, without needless allocations.
 java.lang.String getOriginalString()
          Returns the original string
 java.util.Locale getSourceOfTruthLocale()
           
 java.lang.String getString(java.util.Locale locale)
          Implementations of the single parameter getString should always just call getString with a second parameter of true, for useDefaulting.
 java.lang.String getString(java.util.Locale locale, boolean useDefaulting)
           
static void registerLocalizer(LocalizedJavaString.Localizer localizer)
          Register an instance of Localizer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalizedJavaString

public LocalizedJavaString(java.lang.String className,
                           int key,
                           java.lang.String originalString)
Parameters:
className - name of the class in which the string is created
key - integer key unique within the class
originalString - string in en_US

LocalizedJavaString

public LocalizedJavaString(java.lang.String className,
                           java.lang.String keyString,
                           java.lang.String originalString)
Parameters:
className - name of the class in which the string is created
keyString - String key unique within the class
originalString - string in en_US
Method Detail

getLocalizedString

public java.lang.String getLocalizedString(java.util.Locale locale)
Parameters:
locale - locale
Returns:
localized string

getOriginalString

public java.lang.String getOriginalString()
Returns the original string

Returns:
the string in en_US locale

getKey

public java.lang.String getKey()
Returns the key associated with the original string

Returns:
String the key

getClassName

public java.lang.String getClassName()
Returns the classname associated with the original string

Returns:
the classname

getString

public java.lang.String getString(java.util.Locale locale)
Implementations of the single parameter getString should always just call getString with a second parameter of true, for useDefaulting. Part of LocalizedStringSource interface.

Specified by:
getString in interface LocalizedStringInterface

getString

public java.lang.String getString(java.util.Locale locale,
                                  boolean useDefaulting)
Specified by:
getString in interface LocalizedStringInterface
Returns:
String value in given locale for localized/multiLocale/multiLingual string. If useDefaulting is false, we return null if the locale is not the source of truth, yet the value is the same as the source of truth value. Part of the LocalizedStringSource interface.

getSourceOfTruthLocale

public java.util.Locale getSourceOfTruthLocale()
Specified by:
getSourceOfTruthLocale in interface LocalizedStringInterface
Returns:
Locale which is the "source of truth" for this localized/multiLocale/multiLingual string. This has also been known as the "OriginalLocale", and as the BaseLocale. It is the source of truth for translating this string into other locales. For a LocalizedJavaString, this will always return the Locale "en_US", since the source of truth is the strings is the originalString in the Java code, which is always in American English. For a MultiLocaleString it is the OriginalLocale, and for a MultiLingualString it is probably the default locale of the realm/partition. Part of LocalizedStringSource interface.

registerLocalizer

public static void registerLocalizer(LocalizedJavaString.Localizer localizer)
Register an instance of Localizer. This should be done at app startup time. if this is invoked multiple times, the last one wins.

Parameters:
localizer - the localize to register.

getLocalizedString

public static java.lang.String getLocalizedString(java.lang.String className,
                                                  int key,
                                                  java.lang.String originalString,
                                                  java.util.Locale locale)
Static method to return an aribaweb-style localized package string for the given arguments, without needless allocations.

Parameters:
className - String full class path, with package name followed by dot and bare class name.
key - int secondary key within the class.
originalString - String value that appears as a literal in the source code call to localizedJavaStringHere, or equivalent.
locale - Locale for the string
Returns:
String localized. if localized string is not found, return the originalString.

getLocalizedString

public static java.lang.String getLocalizedString(java.lang.String className,
                                                  java.lang.String keyString,
                                                  java.lang.String originalString,
                                                  java.util.Locale locale)
Static method to return an aribaweb-style localized package string for the given arguments, without needless allocations.

Parameters:
className - String full class path, with package name followed by dot and bare class name.
keyString - String secondary key within the class.
originalString - String value that appears as a literal in the source code call to localizedJavaStringHere, or equivalent.
locale - Locale for the string
Returns:
String localized. if localized string is not found, return the originalString.


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.