|
Oracle® Globalization Development Kit Java API Reference 10g Release 1(10.1) B10971-01 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.i18n.servlet.Localizer
Localizer
is an all-in-on object class that enables to access all necessary globalization information.
The Localizer
instance derived from ServletHelper.getLocalizerInstance(HttpServletRequest)
that is associated with the current user locale. The user may change the current locale on each page;therefore, the scope of Localizer is page
.
By using Localizer
, the user doesn't have to deal with the locale sensitive operation manually. Instead, all information can be obtained from one Localizer
object. The following functionalities of classes are included:
oracle.i18n.text.OraDateFormat
oracle.i18n.text.OraNumberFormat
oracle.i18n.text.OraCollator
oracle.i18n.util.OraLocaleInfo
oracle.i18n.util.LocaleMapper
Method Summary | |
int |
compareString(String source, String target) Compares two strings using the current linguistic sort/collator object. |
int |
compareStringWithDefaultCollator(String source, String target) Compares two strings using the default linguistic sort/collator object. |
String |
decodeURL(String source) Decodes a URL string based on the current user character set using the page character encoding. |
String |
encodeURL(String source) Encodes a URL string based on the current user character set using the page character set encoding. |
String |
formatCurrency(double nm) Translates a double value into a text representation of the currency amount. |
String |
formatCurrency(long nm) Translates a long value into a text representation of the currency amount. |
String |
formatCurrency(Number nm) Translates a Number object into a text representation of the currency amount. |
String |
formatDate(Date dt, int style) Translates a Date object into a text representation of the date. |
String |
formatDateTime(Date dt, int datestyle) Translates a Date object into a text representation of the date and time. |
String |
formatNumber(double nm) Translates a double value into a text representation of the number. |
String |
formatNumber(long nm) Translates a long value into a text representation of the number. |
String |
formatNumber(Number nm) Translates a Number object into a text representation of the number. |
String |
formatTime(Date dt) Translates a Date object into a text representation of the time. |
String |
getAlignment(LocaleSource.Alignment alignment) Returns the current text alignment Here is an example to specify the text alignment value; if LTR mode, the "Text Data" is aligned to right , otherwise left . |
String |
getCurrencyPattern() Returns the currency format pattern used. |
String |
getDatePattern(int style) Returns the date format pattern used in the specified style. |
String |
getDateTimePattern(int datestyle) Returns the date and time format pattern used in the specified style. |
String |
getDisplayCharacterSet(String charset) Returns a translated character set name |
String |
getDisplayCountry(Locale locale) Returns a translated country/territory name |
String |
getDisplayCountry(String country) Returns a translated country/territory name |
String |
getDisplayCurrency(String currencySymbol) Returns a translated currency name |
String |
getDisplayLanguage(Locale locale) Returns a translated language name |
String |
getDisplayLanguage(String language) Returns a translated language name |
String |
getDisplayLinguisticSort(String linguisticSort) Returns a translated Linguistic sorting name |
String |
getDisplayLocale(Locale locale) Returns a translated locale name. |
String |
getDisplayLocale(String oraLanguage, String oraTerritory) Returns a translated locale name |
String |
getDisplayTerritory(String territory) Returns a translated country/territory name |
String |
getDisplayTimeZone(TimeZone tz) Returns a translated TimeZone name. |
String |
getIANACharacterSet() Returns the IANA character set name used for the client. |
String |
getIANAPageCharacterSet() Returns the page character set encoding. |
String |
getISOCurrency() Returns the ISO 4217 currency code for the current locale's country |
Locale |
getLocale() Returns the Locale representing the current locale. |
Class[] |
getLocaleSources() Returns locale sources examined in this order to determine the current locale. |
String[] |
getLocalIANACharacterSets() Returns an array of local character sets for the current language. |
String[] |
getLocalLinguisticSorts() Returns an array of local Oracle Linguistic sort names for the current language. |
String[] |
getLocalOraLanguages() Returns an array of local languages for the current territory. |
String[] |
getLocalOraTerritories() Returns an array of local territories for the current language. |
TimeZone[] |
getLocalTimeZones() Returns an array of local TimeZone for the current territory. |
String |
getMessage(String key) Returns a localized message associated with the key for the current locale. |
String |
getMessage(String key, Class base) Returns a localized message associated with the key for the current locale |
String |
getMessage(String key, String baseKeyName) Returns a localized message associated with the key for the current locale |
String |
getNumberPattern() Returns the number format pattern used. |
String |
getOraCharacterSet() Returns the Oracle character set name used for the client and decoding URLs. |
String |
getOraLanguage() Returns the Oracle language name |
String |
getOraShortLanguage() Returns the short form of Oracle language name. |
String |
getOraTerritory() Returns the Oracle territory name |
String |
getParameterName(LocaleSource.Parameter parameter) Returns a String representing the parameter name used to specify locale attributes. |
String[] |
getSupportedIANACharacterSets() Returns supported IANA character sets |
Locale[] |
getSupportedLocales() Returns locales supported in the application. |
String[] |
getSupportedOraLanguages() Returns supported Oracle languages. |
String[] |
getSupportedOraLanguages(String oraTerritory) Returns supported Oracle languages given Oracle territory The supported languages are determined by the supported locale. |
String[] |
getSupportedOraTerritories() Returns supported Oracle territories. |
String[] |
getSupportedOraTerritories(String oraLanguage) Returns supported Oracle territories given Oracle language The supported territories are determined by the supported locale. |
String |
getTimePattern() Returns the time format pattern |
TimeZone |
getTimeZone() Returns the current TimeZone . |
LocaleSource.WritingDirection |
getWritingDirection() Returns the current text display writing direction. |
Number |
parseCurrency(String str) Translates a text representation of the currency amount into Number . |
Date |
parseDate(String str, int style) Translates a text representation of the date into a Date . |
Date |
parseDateTime(String str, int datestyle) Translates a Date object into a text representation of the date and time. |
Number |
parseNumber(String str) Translates a text representation of the number into a Number . |
Date |
parseTime(String str) Translates a text representation of the time into a Date . |
boolean |
synchronizeLocale(Connection con) Synchronizes the database session NLS parameters with this object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public Locale getLocale()
Locale
representing the current locale.
The same value is returned by HttpServletRequest.getLocale
method in JSP/Java Servlet application code.
Locale
objectpublic String getOraLanguage()
String
representing the Oracle language namepublic String getOraTerritory()
String
representing the Oracle territory namepublic String getOraCharacterSet()
String
representing the Oracle character set namepublic String getOraShortLanguage()
String
representing the short form of Oracle language namepublic TimeZone getTimeZone()
TimeZone
.
If the TimeZone
is not set for the current user, returns the default TimeZone
object for the user locale.
TimeZone
objectpublic LocaleSource.WritingDirection getWritingDirection()
The return value LocaleSource.WritingDirection
is used as follows:
<% Localizer localizer = ServletHelper.getLocalizerInstance(request); %> <table dir="<%=localizer.getWritingDirection()%>" ... > ... </table>
LocaleSource.WritingDirection
objectpublic String getAlignment(LocaleSource.Alignment alignment)
Here is an example to specify the text alignment value; if LTR mode, the "Text Data"
is aligned to right
, otherwise left
.
<% Localizer localizer = ServletHelper.getLocalizerInstance(request); %> <table ... > <tr> <td align="<%=localizer.getAlignment(LocaleSource.Alignment.END)%>"> Text Data</td></tr> ... </table>
alignment
- LocaleSource.Alignment.START
or LocaleSource.Alignment.END
String
object either "left"
or "right"
public String getISOCurrency()
public String getIANACharacterSet()
public String formatDate(Date dt, int style)
Date
object into a text representation of the date. The required text format is specified by method arguments.dt
- java.util.Date
object to formatstyle
- Format of text data; either OraDateFormat.LONG
, OraDateFormat.SHORT
, or OraDateFormat.DEFAULT
.String
representing the date.public Date parseDate(String str, int style) throws ParseException
Date
.str
- String
be parsed.style
- Format of text data, either OraDateFormat.LONG
, OraDateFormat.SHORT
, or OraDateFormat.DEFAULT
.Date
parsed from the string.ParseException
- if the specified string cannot be parsed.public String getDatePattern(int style)
style
- Format of text data, either OraDateFormat.LONG
, OraDateFormat.SHORT
, or OraDateFormat.DEFAULT
.public String formatTime(Date dt)
Date
object into a text representation of the time.dt
- java.util.Date
object to formatString
representing the time.public Date parseTime(String str) throws ParseException
Date
.str
- String
be parsed.Date
parsed from the string.ParseException
- if the specified string cannot be parsed.public String getTimePattern()
public String formatDateTime(Date dt, int datestyle)
Date
object into a text representation of the date and time. The required text format is specified by method arguments.dt
- java.util.Date
object to formatdatestyle
- Format of text data for the date, either OraDateFormat.LONG
, OraDateFormat.SHORT
, or OraDateFormat.DEFAULT
. Time element doesn't have style.String
representing the date and time.public Date parseDateTime(String str, int datestyle) throws ParseException
Date
object into a text representation of the date and time. The required text format is specified by method arguments.str
- String
be parsed.datestyle
- Format of text data for the date, either] OraDateFormat.LONG
, OraDateFormat.SHORT
or, OraDateFormat.DEFAULT
. Time element doesn't have style.Date
parsed from the string.ParseException
- if the specified string cannot be parsed.public String getDateTimePattern(int datestyle)
You cannot specify the style of time
datestyle
- Format of text data either OraDateFormat.LONG
, OraDateFormat.SHORT
, or OraDateFormat.DEFAULT
public String formatNumber(Number nm)
Number
object into a text representation of the number.nm
- Number
object to formatString
representing the number.public Number parseNumber(String str) throws ParseException
Number
.str
- String
be parsed.Number
parsed from the string.ParseException
- if the specified string cannot be parsed.public String getNumberPattern()
public String formatNumber(double nm)
double
value into a text representation of the number.nm
- double
value to formatString
representing the number.public String formatNumber(long nm)
long
value into a text representation of the number.nm
- long
value to formatString
representing the number.public String formatCurrency(Number nm)
Number
object into a text representation of the currency amount.nm
- Number
object to formatString
representing the currency amount.public Number parseCurrency(String str) throws ParseException
Number
.str
- String
be parsed.Number
parsed from the string.ParseException
- if the specified string cannot be parsed.public String getCurrencyPattern()
public String formatCurrency(double nm)
double
value into a text representation of the currency amount.nm
- double
value to format.String
representing the currency amount.public String formatCurrency(long nm)
long
value into a text representation of the currency amount.nm
- long
value to format.String
representing the currency amount.public int compareString(String source, String target)
source
- the source string to be comparedtarget
- the target string to be comparedOraCollator.EQUAL
if equals,OraCollator.LESS
if source collation values are smaller than target's, orOraCollator.GREATER
if source collation values are larger than target's.public int compareStringWithDefaultCollator(String source, String target)
This method is provided for the compatible operations.
source
- the source string to be comparedtarget
- the target string to be comparedOraCollator.EQUAL
if equals,OraCollator.LESS
if source collation values are smaller than target's, orOraCollator.GREATER
if source collation values are larger than target's.public String getMessage(String key, Class base)
key
- a key stringbase
- a base class name of the message resource bundlepublic String getMessage(String key, String baseKeyName)
key
- a key stringbaseKeyName
- a base key class name of the message resource bundlepublic String getMessage(String key)
key
- a key stringpublic String[] getLocalOraLanguages()
public String[] getLocalOraTerritories()
public String[] getLocalIANACharacterSets()
public TimeZone[] getLocalTimeZones()
TimeZone
for the current territory.TimeZone
public String[] getLocalLinguisticSorts()
String
containing Oracle linguistic sort names.public String getDisplayLocale(Locale locale)
locale
- a locale to be translated.public String getDisplayLocale(String oraLanguage, String oraTerritory)
oraLanguage
- an Oracle language nameoraTerritory
- an Oracle territory namepublic String getDisplayLanguage(Locale locale)
locale
- a locale that includes the language to be translatedpublic String getDisplayLanguage(String language)
language
- a language namepublic String getDisplayCountry(Locale locale)
locale
- a locale that includes the country to be translatedpublic String getDisplayCountry(String country)
country
- a country name to be translatedpublic String getDisplayTerritory(String territory)
territory
- a country name to be translatedpublic String getDisplayTimeZone(TimeZone tz)
If the translation is not found, the return value is composed using getRawOffset() value in the form of (SHH:MM)
where S
for a sign of the value, HH
represents the hours of the offset, and MI
represents the minutes of the offiset.
tz
- a TimeZone to be translated.public String getDisplayLinguisticSort(String linguisticSort)
linguisticSort
- an Oracle linguistic sorting name to be translatedpublic String getDisplayCharacterSet(String charset)
charset
- a character set name to be translatedpublic String getDisplayCurrency(String currencySymbol)
currencySymbol
- a character set symbol ISO 4217public String encodeURL(String source)
source
- a source string to encodepublic String decodeURL(String source)
source
- a source string to decodepublic boolean synchronizeLocale(Connection con) throws SQLException
This executes ALTER SESSION
SQL commands to set NLS session parameters to synchronize the locale and attributes in this object. The following session parameters will be updated:
con
- the connection object for the database. Make sure connection is established, othewise you will get an SQLException
.SQLException
public String getParameterName(LocaleSource.Parameter parameter)
String
representing the parameter name used to specify locale attributes. For example, if you want to get the locale value, use LocaleSource.LOCALE
as an input:
ApplicationContext appctx = ServletHelper.getApplicationContextInstance( request); String plocale = request.getParameter( appctx.getParameterName(LocaleSource.LOCALE));
parameter
- a parameter type.public Locale[] getSupportedLocales()
The supported locale can be specified in the application configration file.
Locale
representing supported locales in the application.public String getIANAPageCharacterSet()
If this object is obtained by ServletHelper.getLocalizerInstance
,
public Class[] getLocaleSources()
public String[] getSupportedOraLanguages(String oraTerritory)
The supported languages are determined by the supported locale. Sorting order is in English.
oraTerritory
- Oracle territory nameString
representing the supported languages in the application.public String[] getSupportedOraLanguages()
The supported languages are determined by the supported locale. Sorting order is in English.
String
representing the supported languages in the application.public String[] getSupportedOraTerritories(String oraLanguage)
The supported territories are determined by the supported locale. Sorting order is in English.
oraLanguage
- Oracle langauge nameString
representing the supported territories in the application.public String[] getSupportedOraTerritories()
The supported territories are determined by the supported locale. Sorting order is in English.
String
representing the supported territories in the application.public String[] getSupportedIANACharacterSets()
|
Oracle® Globalization Development Kit Java API Reference 10g Release 1(10.1) B10971-01 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |