|
Oracle® Globalization Development Kit Java API Reference 10g Release 2 (10.2) Part No. B14224-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.i18n.servlet.localesource.LocaleSource
The LocaleSource
class is the abstract base class for locale source objects. A locale source represents an entity that can provide certain locale specific preferences like a locale name, encoding name, etc. There can be many types of sources of pertinent locale preferences, for instance a database table can contain locale specific parameters and can be a locale source. A user action can result in generation of an HTML POST request with query parameters that can be a basis of locale source. Even the HTTP protocol's headers can be yet another source of these locale parameters.
The user locale is determined according to the list of LocaleSource
class declarations in the GDK application configuration file. The GDK examines each LocaleSource
class declaration, in the list using the declared order of the list. The first available LocaleSource
is used for the user locale.
The GDK provides the following pre-defined LocaleSource
implementations:
HttpAcceptLanguage
- the locale preference set by the web client in the HTTP header.UserInput
- the locale preference in the parameters of GET
and POST
methods.DBLocaleSource
- the locale preference stored in the Oracle database.ApplicationDefault
- the default locale for the application.Note ApplicationDefault
locale source is implicitly registered in the end of the locale source. If no other locale source is available, the ApplicationDefault
locale source is used.
Using the GDK configuration, the language of an application (User Interface) can be configured in many ways. The GDK configuration example below, illustrates configuration for a scenario where the language of an initial application page will be determined based on the language setting of the browser. Additionally, the user will be able to override this language by choosing from the available list of locales displayed in a Locale Selection drop-down. For example, if the browser language setting is Chinese, then pointing your browser to this application will display the User Interface in the Chinese language. Furthermore, the user can select Swiss (German) locale from the Locale Selection dropdown to change the application user interface to display German. The configuration below (from a gdkapp.xml) is used by the GDK to first try to use the Accept-Language HTTP header as the source of the locale, unless it is overridden by user input, which in the application's case is the selection of the locale from a Locale Selection dropdown. When the user picks the locale from the dropdown, the JSP posts a locale parameter value containing the selected locale. The GDK then sends a response, with the contents in the selected language.
<locale-determine-rule> <locale-source> oracle.i18n.servlet.localesource.UserInput </locale-source> <locale-source> oracle.i18n.servlet.localesource.HttpAcceptLanguage </locale-source> </locale-determine-rule>
To create a custom locale source object, extend this class. The custom object for instance, may access the Oracle database to fetch and update the user locale preference, or it may access the LDAP server to get and set the language preference elements. Three methods must be implemented in the custom locale source:
public static LocaleSource getInstance(HttpServletRequest)
- used to instantiate the object. It returns the object if it succeeds, otherwise null
.public boolean load()
- used to load the locale and its attributes from the locale source.public boolean store()
- used to store the locale and its attributes into the locale source. If the locale source is read-only, this method should do nothing but return true
.Implement the following method if the locale source can be cached:
public static boolean isAccessible(HttpServletRequest)
- used to check if the locale source is accessible before using the cached object. It returns true
if the locale source is accessible, otherwise false
. If this method is not implemented, the GDK assumes that the locale source is always accessible.In the constructor, the following parameters must be specified:
cache flag
- indicates whether the locale source can be cached. If the access cost to the locale source is not trivial, such as LDAP server, this flag should be true
, otherwise false
.read-only flag
- indicates whether the locale source is read-only. If the locale source cannot be updated, such as the Accept-Language
item in the HTTP header, this flag is true
, otherwise false
.For example, the locale source accessing the LDAP server should be cached so that the GDK keeps the locale information while the user is valid. Once the user logs out, the locale information is no longer valid.
Nested Class Summary | |
static class |
LocaleSource.Alignment The LocaleSource.Alignment class represents the alignment of text elements. |
static class |
LocaleSource.Parameter The LocaleSource.Parameter class represents locale and attribute variable names. |
static class |
LocaleSource.WritingDirection The LocaleSource.WritingDirection class represents the writing direction of the locale. |
Constructor Summary | |
protected |
LocaleSource(boolean isCached, boolean isReadOnly) Constructs a LocaleSource object. |
Method Summary | |
boolean |
equals(Object o) Determines if a specific object is equal to this object. |
protected Object |
getAttribute(String key) Returns the attribute object. |
String |
getCharacterSet() Returns the character set name in this object. |
oracle.i18n.text.OraCollator |
getCollator() Returns the Oracle collator object. |
oracle.i18n.text.OraNumberFormat |
getCurrencyFormat() Returns the Oracle currency format in this object. |
oracle.i18n.text.OraDateFormat |
getDateFormat(int style) Returns the Oracle date format of the specified style in this object. |
oracle.i18n.text.OraDateFormat |
getDateTimeFormat(int style) Returns the Oracle date and time format of the specified style in this object. |
String |
getISOCurrency() Returns the ISO 4217 currency ID in this object. |
Locale |
getLocale() Returns the Locale object in this object. |
Class |
getLocaleSourceClass() Returns the locale source class. |
oracle.i18n.text.OraNumberFormat |
getNumberFormat() Returns the Oracle number format in this object. |
oracle.i18n.text.OraDateFormat |
getTimeFormat() Returns the Oracle time format in this object. |
TimeZone |
getTimeZone() Returns the time zone in this object. |
LocaleSource.WritingDirection |
getWritingDirection() Returns the writing direction in this object. |
int |
hashCode() Returns the hash value of this object. |
boolean |
isCached() Checks if the LocaleSource object is cached. |
boolean |
isReadOnly() Checks if the LocaleSource object is read-only. |
abstract boolean |
load() Loads the locale and all attributes from the actual locale source into this object. |
protected void |
setAttribute(String key, Object object) Registers an attribute object in the locale source. |
void |
setCharacterSet(String charset) Registers the Oracle character set name to store in the actual LocaleSource class. |
void |
setCollator(oracle.i18n.text.OraCollator ocol) Registers the Oracle collator to store in the actual LocaleSource class. |
void |
setCurrencyFormat(oracle.i18n.text.OraNumberFormat nfmt) Registers the Oracle currency format object to store in the actual LocaleSource class. |
void |
setDateFormat(int style, oracle.i18n.text.OraDateFormat dtfmt) Registers the Oracle date format object to store in the actual LocaleSource class. |
void |
setDateTimeFormat(int dtstyle, oracle.i18n.text.OraDateFormat dtfmt) Registers the Oracle date time format object to store in the actual LocaleSource class. |
void |
setISOCurrency(String currency) Registers the ISO currency to store in the actual LocaleSource class. |
void |
setLocale(Locale locale) Registers the Locale object with this object. |
void |
setLocale(Locale locale, oracle.i18n.servlet.ApplicationContext appctx) Registers the locale object in this object. |
void |
setLocaleSourceClass(Class loccls) Registers the locale source class object. |
void |
setNumberFormat(oracle.i18n.text.OraNumberFormat nfmt) Registers the Oracle number format object to store in the actual LocaleSource class. |
void |
setTimeFormat(oracle.i18n.text.OraDateFormat tmfmt) Registers the Oracle time format object to store in the actual LocaleSource class. |
void |
setTimeZone(TimeZone tz) Registers the TimeZone ID to store in the actual LocaleSource class. |
void |
setWritingDirection(LocaleSource.WritingDirection wdir) Registers the writing direction to store in the actual LocaleSource class. |
abstract boolean |
store() Stores the locale and all attributes of the object in the actual LocaleSource class. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected LocaleSource(boolean isCached, boolean isReadOnly)
LocaleSource
object.isCached
- true
if the locale source can be cachedisReadOnly
- true
if the locale source is read-onlyMethod Detail |
public final boolean isCached()
LocaleSource
object is cached.true
if this object is cached; false
otherwise.public final boolean isReadOnly()
LocaleSource
object is read-only.
If this is true
, creation and update operations on this object are omitted.
true
if this object is read-only; false
otherwise.public abstract boolean store()
LocaleSource
class.
This method must be implemented by the concrete classes.
true
if the storing operation is successful; false
otherwisepublic abstract boolean load()
This method must be implemented by the concrete classes.
true
if the loading operation is successful; false
otherwisepublic final void setLocale(Locale locale)
Locale
object with this object.locale
- the Locale
objectpublic final void setLocale(Locale locale, oracle.i18n.servlet.ApplicationContext appctx)
locale
- the Locale
objectappctx
- the ApplicationContext
objectpublic final void setISOCurrency(String currency)
LocaleSource
class.currency
- the ISO currency ID defined in ISO 4217public final void setCharacterSet(String charset)
LocaleSource
class.charset
- the Oracle character set namepublic final void setLocaleSourceClass(Class loccls)
loccls
- a Class
objectpublic final void setTimeZone(TimeZone tz)
TimeZone
ID to store in the actual LocaleSource
class. For example: America/Los_Angeles
tz
- a TimeZone
object to registerpublic final void setDateTimeFormat(int dtstyle, oracle.i18n.text.OraDateFormat dtfmt)
LocaleSource
class.dtstyle
- the date format style defined in the OraDateFormat
classdtfmt
- an OraDateFormat
objectpublic final void setDateFormat(int style, oracle.i18n.text.OraDateFormat dtfmt)
LocaleSource
class.style
- the date format style defined in the OraDateFormat
classdtfmt
- an OraDateFormat
objectpublic final void setTimeFormat(oracle.i18n.text.OraDateFormat tmfmt)
LocaleSource
class.tmfmt
- an OraDateFormat
objectpublic final void setWritingDirection(LocaleSource.WritingDirection wdir)
LocaleSource
class.wdir
- a writing direction of text on displaypublic final void setCurrencyFormat(oracle.i18n.text.OraNumberFormat nfmt)
LocaleSource
class.nfmt
- an OraNumberFormat
object to registerpublic final void setNumberFormat(oracle.i18n.text.OraNumberFormat nfmt)
LocaleSource
class.nfmt
- an OraNumberFormat
object to registerpublic final void setCollator(oracle.i18n.text.OraCollator ocol)
LocaleSource
class.ocol
- an OraCollator
object to registerprotected final void setAttribute(String key, Object object)
Used in the concrete classes to set custom attributes.
Note the attribute object must be Serializable
.
key
- a String
key of objectobject
- an objectpublic final Locale getLocale()
Locale
object in this object.Locale
objectpublic final String getISOCurrency()
public final String getCharacterSet()
public final Class getLocaleSourceClass()
public final TimeZone getTimeZone()
TimeZone
objectpublic final oracle.i18n.text.OraDateFormat getDateTimeFormat(int style)
style
- the Date
format styleOraDateFormat
objectpublic final oracle.i18n.text.OraDateFormat getDateFormat(int style)
style
- the Date
format styleOraDateFormat
objectpublic final oracle.i18n.text.OraDateFormat getTimeFormat()
public final LocaleSource.WritingDirection getWritingDirection()
WritingDirection
objectpublic final oracle.i18n.text.OraNumberFormat getCurrencyFormat()
OraNumberFormat
objectpublic final oracle.i18n.text.OraNumberFormat getNumberFormat()
OraNumberFormat
objectpublic final oracle.i18n.text.OraCollator getCollator()
OraCollator
objectprotected final Object getAttribute(String key)
Used in the concrete classes to retrieve custom attributes. Note the attribute object must be Serializable
.
key
- a String
key of objectObject
associated with the key
public boolean equals(Object o)
equals
in class Object
o
- an Object
to be comparedtrue
if the objects are equal; false
otherwisepublic int hashCode()
hashCode
in class Object
|
Oracle® Globalization Development Kit Java API Reference 10g Release 2 (10.2) Part No. B14224-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |