|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.websphere.i18n.localizabletext.LocalizableTextFormatter
The LocalizableTextFormatter object is the main class used in the Localizable service.
The Localizable Text function is the infrastructure to enable the retrieval of translated text to any
desired locale/time zone in a distributed environment. With the use of a LocalizableTextFormatter object,
the user can set the needed information in a language neutral way. When the information is needed to be
displayed to a user, the LocalizableTextFormatter object can be formatted into the locale/time zone of the
user. Typical uses will be to hold error and exception information, inform users of invalid
parameters in a request, log data, GUI screen information or just about anything a user may want to have
displayed. Text strings, numbers, currency, dates, times, and time zones are all specific to the user's
language/country and need to be processed correctly.
Arguments
In any LocalizableTextFormatter, arguments are optional. The dependency for arguments falls completely
on the pattern key. In addition to the normal arguments that are used with pattern keys, the Localizable
Text function adds a few extra options. The four interfaces, LocalizableText, LocalizableTextL,
LocalizableTextTZ and LocalizableTextLTZ allow additional objects to be used as arguments. The object
LocalizableTextDateTimeArgument is an example class of what can be done when using one of the four
interfaces. Any one or more of the interfaces can be implemented by another class. When multiple
interfaces are implemented, there is a specific order in which the class will be evaluated so that
the proper format method is called.
The order of evaluation is:
...
...
catch (Exception exp) {
   String className = this.getClass().getName();
   LocalizableTextFormatter messageLTF = new LocalizableTextFormatter("Error_125", "resources.Messages");
   Object[] args = {className, messageLTF};
   LocalizableTextFormatter exceptionLTF = new LocalizableTextFormatter("General_Error", "resources.Exceptions", args);
}
...
...
...
// Exception was caused by a problem with foo,
// change pattern key in messageLTF to reflect this
messageLTF.setPatternKey("Error_235");
//Display exception to user
System.out.println(exceptionLTF.format(myLocale));
...
...
...
...
// Exception was caused by a problem with foo,
// change pattern key in messageLTF to reflect this
messageLTF.setPatternKey("Error_235");
exceptionLTF.setArguments(className, messageLTF);
//Display exception to user
System.out.println(exceptionLTF.format(myLocale));
...
...
...
...
public void displayText(LocalizableTextFormatter ltf, Locale desiredLocale) {
try {
   System.out.println(ltf.format(desiredLocale));
}
catch (LocalizableException le) {
   System.out.println(ltf.getFallBackText());
}
return;
}
...
...
LocalizableText
,
LocalizableTextL
,
LocalizableTextTZ
,
LocalizableTextLTZ
,
LocalizableTextDateTimeArgument
, Serialized FormConstructor Summary | |
LocalizableTextFormatter()
Default constructor. |
|
LocalizableTextFormatter(java.lang.String resourceBundleName,
java.lang.String patternKey,
java.lang.Object[] arguments,
java.lang.String applicationName)
Constructs a LocalizableTextFormatter object with the package qualified ResourceBundle name, the String of the pattern key in the ResourceBundle, the Object[] of arguments and the name of the server application. |
|
LocalizableTextFormatter(java.lang.String resourceBundleName,
java.lang.String patternKey,
java.lang.String applicationName)
Constructors a LocalizableTextFormatter object with the package qualified ResourceBundle name and the String of the pattern key to use from the ResourceBundle. |
Method Summary | |
void |
clearCache()
Clears the contents of the LocalizableTextFormatters cache. |
void |
clearLocalizableTextFormatter()
Resets the state of the LocalizableTextFormatter object back to a new instance state. |
boolean |
equals(java.lang.Object obj)
Determines whether the object passed in is "equal to" this LocalizableTextFormatter. |
java.lang.String |
format()
Formats this object with the set pattern key from the specified Resource Bundle and any optional arguments to produce a String. |
java.lang.String |
format(java.util.Locale loc)
Formats this object with the pattern key from the specified Resource Bundle and any optional arguments to produce a String. |
java.lang.String |
format(java.util.Locale localeIn,
java.util.TimeZone timeZoneIn)
Formats this object with the pattern key from the specified Resource Bundle and any optional arguments to produce a String. |
java.lang.String |
format(java.util.TimeZone timeZone)
Formats this object with the pattern key from the specified Resource Bundle and any optional arguments to produce a String. |
java.lang.String |
getApplicationName()
Returns the application name associated with this LocalizableTextFormatter. |
java.lang.Object[] |
getArguments()
Returns an array of objects that were set for use with this LocalizableTextFormatter. |
java.lang.String |
getCacheEntry(java.util.Locale locale,
java.util.TimeZone timeZone)
Returns a previously formatted String from the cache based on the Locale and TimeZone passed. |
boolean |
getCacheSetting()
Used to get the setting for cacheing. |
java.util.Locale |
getFallBackLocale()
Used to get the FallBackLocale. |
java.lang.String |
getFallBackString()
Used to get the FallBack String. |
java.util.TimeZone |
getFallBackTimeZone()
Used to get the FallBackTimeZone. |
java.lang.String |
getPatternKey()
Returns the pattern key for this LocalizableTextFormatter. |
java.lang.String |
getResourceBundleName()
Returns the name of the ResourceBundle to use for this LocalizableTextFormatter. |
int |
hashCode()
Generates a HashCode for this LocalizableTextFormatter object. |
java.lang.String |
localFormat(java.util.Locale localeIn,
java.util.TimeZone timeZoneIn)
Formats the LocalizableTextFormatter object locally. |
void |
setApplicationName(java.lang.String appName)
Set the application name for the LocalizableTextFormatter object. |
void |
setArguments(java.lang.Object[] args)
Sets the arguments for the LocalizableTextFormatter to use with the set pattern key. |
void |
setCacheSetting(boolean setting)
Sets the cache behavior of this LocalizableTextFormatter object. |
void |
setFallBackLocale(java.util.Locale newFallBackLocale)
Sets a Locale object to use with this LocalizableTextFormatter object. |
void |
setFallBackString(java.lang.String newFallBackString)
Sets a String object to use with this LocalizableTextFormatter object. |
void |
setFallBackTimeZone(java.util.TimeZone newFallBackTimeZone)
Sets a TimeZone object to use with this LocalizableTextFormatter object. |
void |
setPatternKey(java.lang.String patternKey)
Sets the pattern key to use. |
void |
setResourceBundleName(java.lang.String bundleName)
Sets the ResourceBundle name to use for this message. |
java.lang.String |
toString()
Displays all of the current information in the object. |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public LocalizableTextFormatter()
public LocalizableTextFormatter(java.lang.String resourceBundleName, java.lang.String patternKey, java.lang.Object[] arguments, java.lang.String applicationName)
resourceBundleName
- The name of the fully package qualified ResourceBundle to be used.patternKey
- The key to be used to get the pattern from the ResourceBundle.arguements
- An array of objects to be used as arguments for the pattern (in any).applicationName
- The name of the application running on the application server(s) where the ResourceBundle can be found.public LocalizableTextFormatter(java.lang.String resourceBundleName, java.lang.String patternKey, java.lang.String applicationName)
resourceBundleName
- The name of the fully package qualified ResourceBundle to be used.patternKey
- The key to be used to get the pattern from the ResourceBundle.Method Detail |
public void clearLocalizableTextFormatter()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object with which to compare this one to.public java.lang.String format() throws LocalizableException
format
in interface LocalizableText
public java.lang.String format(java.util.Locale loc) throws LocalizableException
format
in interface LocalizableTextL
loc
- The Locale to format the LocalizableTextFormatter into.public java.lang.String format(java.util.Locale localeIn, java.util.TimeZone timeZoneIn) throws LocalizableException
format
in interface LocalizableTextLTZ
localeIn
- A Locale representing the language to format this LocalizableTextFormatter into.timeZoneIn
- A TimeZone for any date / time sensitative arguments.LocalizableTextDateTimeArgument
public java.lang.String format(java.util.TimeZone timeZone) throws LocalizableException
format
in interface LocalizableTextTZ
format(Locale, TimeZone)
public java.lang.Object[] getArguments() throws LocalizableException
public boolean getCacheSetting()
public java.util.Locale getFallBackLocale()
public java.lang.String getFallBackString()
public java.util.TimeZone getFallBackTimeZone()
public java.lang.String getPatternKey()
public java.lang.String getResourceBundleName()
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String localFormat(java.util.Locale localeIn, java.util.TimeZone timeZoneIn) throws LocalizableException
locale
- java.util.LocaletimeZone
- java.util.TimeZonepublic void setArguments(java.lang.Object[] args)
LocalizableText
,
LocalizableTextL
,
LocalizableTextTZ
,
LocalizableTextLTZ
public void setCacheSetting(boolean setting)
setting
- booleanpublic void setFallBackLocale(java.util.Locale newFallBackLocale)
newFallBackLocale
- java.util.LocaleLocalizableTextFormatter
public void setFallBackString(java.lang.String newFallBackString)
newFallBackString
- java.lang.StringLocalizableTextFormatter
public void setFallBackTimeZone(java.util.TimeZone newFallBackTimeZone)
newFallBackTimeZone
- java.util.TimeZoneLocalizableTextFormatter
public void setPatternKey(java.lang.String patternKey)
java.lang.String
- public void setResourceBundleName(java.lang.String bundleName)
java.lang.String
- public java.lang.String toString()
toString
in class java.lang.Object
public void clearCache()
public java.lang.String getCacheEntry(java.util.Locale locale, java.util.TimeZone timeZone)
locale
- Locale to use when looking for a cache entry.timeZone
- TimeZone to use when looking for a cache entry.public java.lang.String getApplicationName()
public void setApplicationName(java.lang.String appName)
applicationName
- java.lang.String
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |