|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jasig.portal.i18n.LocaleManager
public class LocaleManager
Manages locales on behalf of a user.
This class currently keeps track of locales at the following levels:
Field Summary | |
---|---|
private java.util.Locale[] |
browserLocales
|
static boolean |
DEFAULT_LOCALE_AWARE
Default value for localeAware. |
private static java.util.Locale |
jvmLocale
|
private static boolean |
localeAware
|
private static org.apache.commons.logging.Log |
log
|
private IPerson |
person
|
private static java.util.Locale[] |
portalLocales
|
private java.util.Locale[] |
sessionLocales
|
private java.util.Locale[] |
userLocales
|
Constructor Summary | |
---|---|
LocaleManager(IPerson person)
Constructor that associates a locale manager with a user. |
|
LocaleManager(IPerson person,
java.lang.String acceptLanguage)
Constructor that sets up locales according to the Accept-Language request header
from a user's browser. |
Method Summary | |
---|---|
private void |
addToLocaleList(java.util.List localeList,
java.util.Locale[] locales)
Add locales to the locale list if they aren't in there already |
java.util.Locale[] |
getBrowserLocales()
|
static java.util.Locale |
getJvmLocale()
|
java.util.Locale[] |
getLocales()
Produces a sorted list of locales according to locale preferences obtained from several places. |
static java.util.Locale[] |
getPortalLocales()
|
java.util.Locale[] |
getSessionLocales()
|
java.util.Locale[] |
getUserLocales()
|
static boolean |
isLocaleAware()
|
private java.util.Locale[] |
loadPortalLocales()
Read and parse portal_locales from portal.properties. |
static java.util.Locale |
parseLocale(java.lang.String localeString)
Helper method to produce a java.util.Locale object from
a locale string such as en_US or ja_JP. |
static java.util.Locale[] |
parseLocales(java.lang.String localeStringList)
Helper method to produce a java.util.Locale array from
a comma-delimited locale string list, e.g. |
void |
persistUserLocales(java.util.Locale[] userLocales)
Stores the user locales persistantly. |
void |
setBrowserLocales(java.util.Locale[] browserLocales)
|
static void |
setJvmLocale(java.util.Locale jvmLocale)
|
static void |
setPortalLocales(java.util.Locale[] portalLocales)
|
void |
setSessionLocales(java.util.Locale[] sessionLocales)
|
void |
setUserLocales(java.util.Locale[] userLocales)
|
static java.lang.String |
stringValueOf(java.util.Locale[] locales)
Constructs a comma-delimited list of locales that could be parsed back into a Locale array with parseLocales(String localeStringList). |
java.lang.String |
toString()
|
static org.w3c.dom.Document |
xmlValueOf(java.util.Locale[] locales)
Creates an XML representation of a list of locales. |
static org.w3c.dom.Document |
xmlValueOf(java.util.Locale[] locales,
java.util.Locale selectedLocale)
Creates an XML representation of a list of locales. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final org.apache.commons.logging.Log log
public static final boolean DEFAULT_LOCALE_AWARE
private IPerson person
private static boolean localeAware
private static java.util.Locale jvmLocale
private static java.util.Locale[] portalLocales
private java.util.Locale[] sessionLocales
private java.util.Locale[] browserLocales
private java.util.Locale[] userLocales
Constructor Detail |
---|
public LocaleManager(IPerson person)
person
- the userpublic LocaleManager(IPerson person, java.lang.String acceptLanguage)
Accept-Language
request header
from a user's browser.
person
- the useracceptLanguage
- the Accept-Language request header from a user's browserMethod Detail |
---|
public static boolean isLocaleAware()
public static java.util.Locale getJvmLocale()
public static java.util.Locale[] getPortalLocales()
public java.util.Locale[] getBrowserLocales()
public java.util.Locale[] getUserLocales()
public java.util.Locale[] getSessionLocales()
public static void setJvmLocale(java.util.Locale jvmLocale)
public static void setPortalLocales(java.util.Locale[] portalLocales)
public void setBrowserLocales(java.util.Locale[] browserLocales)
public void setUserLocales(java.util.Locale[] userLocales)
public void setSessionLocales(java.util.Locale[] sessionLocales)
private java.util.Locale[] loadPortalLocales()
public java.util.Locale[] getLocales()
private void addToLocaleList(java.util.List localeList, java.util.Locale[] locales)
public static java.util.Locale[] parseLocales(java.lang.String localeStringList)
java.util.Locale
array from
a comma-delimited locale string list, e.g. "en_US,ja_JP"
localeStringList
- the locales to parse
public static java.util.Locale parseLocale(java.lang.String localeString)
java.util.Locale
object from
a locale string such as en_US or ja_JP.
localeString
- a locale string such as en_US
public static java.lang.String stringValueOf(java.util.Locale[] locales)
locales
- the list of locales
public void persistUserLocales(java.util.Locale[] userLocales) throws java.lang.Exception
userLocales
- the user locales preference
java.lang.Exception
public static org.w3c.dom.Document xmlValueOf(java.util.Locale[] locales)
locales
- the locale list
public static org.w3c.dom.Document xmlValueOf(java.util.Locale[] locales, java.util.Locale selectedLocale)
locales
- the locale listselectedLocale
- a locale that should be selected if it is in the list
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |