oracle.ifs.common
Class Localizer


java.lang.Object

  |

  +--oracle.ifs.common.Localizer


public final class Localizer
extends java.lang.Object

A Localizer encapsulates internationalization information.

Many methods in the iFS API require internationalization information, such as the appropriate locale, date format, time format, or number format. This data is encapsulated in a Localizer instance, which is made available to such methods.

Each LibrarySession has a Localizer based on arguments supplied to LibraryService.connect.

A Localizer also encapsulates the iFS resource bundle. The getResourceString methods of LibrarySession and LibraryObject use this resource bundle to generate localized messages. An application can override some or all of these messages, or introduce its own messages, by invoking setExtendedResourceBundles on the Localizer returned by LibrarySession.getLocalizer.


Constructor Summary
Localizer()
          Constructs a Localizer.
Localizer(java.util.Locale locale)
          Constructs a Localizer for the specified locale.
Localizer(java.util.Locale locale, LibrarySession session)
          Constructs a Localizer for the specified locale.
 
Method Summary
 java.util.Calendar getCalendar()
          Gets the Calendar of this Localizer.
 java.lang.String getCharEncoding()
          Gets the Java naming character encoding of this Localizer.
 java.text.DateFormat getDateFormatter()
          Gets the date formatter of this Localizer.
static Localizer getDefault()
          Gets the default US English Localizer.
 java.lang.String[] getExtendedResourceBundles()
          Gets the extended resource bundles for this Localizer.
 java.lang.String getLanguage()
          Returns the language for this LibrarySession in English.
 java.util.Locale getLocale()
          Gets the locale of this Localizer.
 java.text.NumberFormat getNumberFormatter()
          Gets the number formatter of this Localizer.
 java.lang.String getResourceString(java.lang.String key)
          Gets the resource string for the specified key.
 java.lang.String getResourceString(java.lang.String key, java.lang.Object[] params)
          Gets the resource string for the specified key, and substitutes the specified parameters into that resource string.
 java.text.DateFormat getTimeFormatter()
          Gets the time formatter of this Localizer.
 java.util.TimeZone getTimeZone()
          Gets the time zone of this Localizer.
 void setCharEncoding(java.lang.String charEncoding)
          Sets the character encoding of this Localizer.
 void setDateFormatter(java.text.DateFormat dateFormatter)
          Sets the date formatter of this Localizer.
 void setExtendedResourceBundles(java.lang.String[] baseNames)
          Sets the extended resource bundles for this Localizer.
 void setLanguage(java.lang.String language)
          Sets the language to be used by context search.
 void setLocale(java.util.Locale locale)
          Sets the locale of this Localizer.
 void setNumberFormatter(java.text.NumberFormat numberFormatter)
          Sets the number formatter of this Localizer.
 void setTimeFormatter(java.text.DateFormat timeFormatter)
          Sets the time formatter of this Localizer.
 void setTimeZone(java.util.TimeZone timeZone)
          Sets the time zone of this Localizer.
 

Constructor Detail


Localizer


public Localizer()
          throws IfsException
Constructs a Localizer.

The Localizer's locale is the default locale of the Java VM. The Localizer has default number, date, and time formatters for that locale, and uses 8859_1 (ISO Latin1) character encoding.

Throws:
IfsException - (IFS-12000) if the operation fails

Localizer


public Localizer(java.util.Locale locale)
          throws IfsException
Constructs a Localizer for the specified locale.

The Localizer has default number, date, time formatters; and default Timezone and character encoding settings.

Parameters:
locale - the locale of the Localizer. If null, the default locale of the Java VM is used.
Throws:
IfsException - (IFS-12000) if the operation fails

Localizer


public Localizer(java.util.Locale locale,
                 LibrarySession session)
          throws IfsException
Constructs a Localizer for the specified locale.

The Localizer has default number, date, time formatters; and default Timezone and character encoding settings.

Parameters:
locale - the locale of the Localizer. If null, the default locale of the Java VM is used.
session - the LibrarySession to which the Localizer is bound; any changes to this Localizer will trigger identical changes in the Localizer of the corresponding S_LibrarySession
Throws:
IfsException - (IFS-12000) if the operation fails
Method Detail

getLocale


public java.util.Locale getLocale()
                           throws IfsException
Gets the locale of this Localizer.
Returns:
the locale
Throws:
IfsException - if the operation fails

setLocale


public void setLocale(java.util.Locale locale)
               throws IfsException
Sets the locale of this Localizer.

The number formatter, date formatter, and time formatter are set to default formatters for the specified locale.

Parameters:
locale - the locale
Throws:
IfsException - if the operation fails

getDefault


public static Localizer getDefault()
Gets the default US English Localizer.

This default is used by IfsException.getMessage.

Returns:
the default Localizer

setCharEncoding


public void setCharEncoding(java.lang.String charEncoding)
                     throws IfsException
Sets the character encoding of this Localizer.
Parameters:
charEncoding - the Java-naming character encoding.
Throws:
IfsException - if the operation fails

getCharEncoding


public java.lang.String getCharEncoding()
                                 throws IfsException
Gets the Java naming character encoding of this Localizer.
Returns:
the character encoding
Throws:
IfsException - if the operation fails

setLanguage


public void setLanguage(java.lang.String language)
                 throws IfsException
Sets the language to be used by context search. If none set, the default is the value of DefaultLanguage from the properties file. The serverside code will determine the default to use.
Parameters:
language - the Oracle language name.

getLanguage


public java.lang.String getLanguage()
                             throws IfsException
Returns the language for this LibrarySession in English.
Returns:
the Oracle IMT language name. Defaults to property, DefaultLanguage, in properties file.

setNumberFormatter


public void setNumberFormatter(java.text.NumberFormat numberFormatter)
                        throws IfsException
Sets the number formatter of this Localizer.
Parameters:
numberFormatter - the number formatter. If null, a default number formatter for the locale of this Localizer is used.
Throws:
IfsException - (IFS-12002) if the operation fails

getNumberFormatter


public java.text.NumberFormat getNumberFormatter()
                                          throws IfsException
Gets the number formatter of this Localizer.
Returns:
the number formatter
Throws:
IfsException - if the operation fails

setDateFormatter


public void setDateFormatter(java.text.DateFormat dateFormatter)
                      throws IfsException
Sets the date formatter of this Localizer.
Parameters:
dateFormatter - the date formatter. If null, a default date formatter for the locale of this Localizer is used.
Throws:
IfsException - (IFS-12003) if the operation fails

getDateFormatter


public java.text.DateFormat getDateFormatter()
                                      throws IfsException
Gets the date formatter of this Localizer.
Returns:
the date formatter
Throws:
IfsException - if the operation fails

setTimeFormatter


public void setTimeFormatter(java.text.DateFormat timeFormatter)
                      throws IfsException
Sets the time formatter of this Localizer.
Parameters:
timeFormatter - the time formatter. If null, a default time formatter for the locale of this Localizer is used.
Throws:
IfsException - (IFS-12004) if the operation fails

getTimeFormatter


public java.text.DateFormat getTimeFormatter()
                                      throws IfsException
Gets the time formatter of this Localizer.
Returns:
the time formatter
Throws:
IfsException - if the operation fails

setTimeZone


public void setTimeZone(java.util.TimeZone timeZone)
                 throws IfsException
Sets the time zone of this Localizer.
Parameters:
timezone - the time zone. If null, a default time zone for the locale of this Localizer is used.
Throws:
IfsException - (IFS-12005) if the operation fails

getTimeZone


public java.util.TimeZone getTimeZone()
                               throws IfsException
Gets the time zone of this Localizer.
Returns:
the time zone
Throws:
IfsException - if the operation fails

getCalendar


public java.util.Calendar getCalendar()
                               throws IfsException
Gets the Calendar of this Localizer.
Returns:
the Calendar
Throws:
IfsException - if the operation fails

setExtendedResourceBundles


public void setExtendedResourceBundles(java.lang.String[] baseNames)
                                throws IfsException
Sets the extended resource bundles for this Localizer.
Parameters:
baseNames - an array of resource bundle names. Each resource bundle name must be a valid argument to ResourceBundle.getBundle(String).
Throws:
IfsException - if the operation fails

getExtendedResourceBundles


public java.lang.String[] getExtendedResourceBundles()
                                              throws IfsException
Gets the extended resource bundles for this Localizer.
Returns:
an array of resource bundle names. Each resource bundle name is a valid argument to ResourceBundle.getBundle(String).
Throws:
IfsException - if the operation fails

getResourceString


public java.lang.String getResourceString(java.lang.String key)
                                   throws IfsException
Gets the resource string for the specified key.

The method looks-up the key in each extended resource bundle, in the order specified by the array in setExtendedResourceBundles, until it finds a bundle containing the key. If no extended resource bundle contains the key, the default resource bundle (LibraryResources) is used.

Parameters:
key - the resource bundle key
Returns:
the resource string
Throws:
IfsException - IFS-12001 if the operation fails

getResourceString


public java.lang.String getResourceString(java.lang.String key,
                                          java.lang.Object[] params)
                                   throws IfsException
Gets the resource string for the specified key, and substitutes the specified parameters into that resource string.

The method looks-up the key using getResourceString(key). Next, java.text.MessageFormat is used to substitute the parameters specified by params into the key's value. If a string element of params is delimited by brackets, i.e. "{param}", then that element is replaced with the value returned by getResourceString("param") before being passed to MessageFormat.

Parameters:
key - the resource bundle key
params - an array of Objects to be substituted into the resource bundle message using using java.text.MessageFormat
Returns:
the formatted resource string
Throws:
IfsException - IFS-12006 if the operation fails