|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.globalization.LocaleNegotiator
Adapted from com.oreilly.servlet.LocaleNegotiator. Determines the appropriate Locale, Charset, and ResourceBundle for a request.
The Locale for a request is determined in one of four ways in order of precedence:
User's preferred Locale as determined by the Accept-Language header. For a definition of the format for the Accept-Language HTTP header look at RFC 2616.
We handle quality values (or q values) for the Accept-Language HTTP header. This is how we interpret q-values:
The Charset for a request Charset is determined in one of three ways in order of precedence:
The ResourceBundle is determined by the targetBundle as determined by the application and the selected Locale.
Field Summary | |
static String |
versionId
|
Constructor Summary | |
LocaleNegotiator(String targetBundle,
String acceptLanguages,
String acceptCharsets,
Locale packageLocale)
Select appropriate Locale, Charset, and ResourceBundle for a request. |
Method Summary | |
static LocaleProvider |
getApplicationLocaleProvider()
Get the application LocaleProvider. |
ResourceBundle |
getBundle()
The negotiated ResourceBundle for this request |
String |
getCharset()
The negotiated character set for this request |
protected String |
getCharsetForLocale(Locale locale,
String acceptCharsets)
Get the character set associated with a request. |
static LocaleProvider |
getClientLocaleProvider()
Get the client LocaleProvider. |
Locale |
getLocale()
The negotiated Locale for this request |
static LocaleProvider |
getSystemLocaleProvider()
Get the system LocaleProvider. |
static LocaleProvider |
getUserLocaleProvider()
Get the user LocaleProvider. |
static void |
setApplicationLocaleProvider(LocaleProvider lp)
Set the LocaleProvider for the application. |
static void |
setClientLocaleProvider(LocaleProvider lp)
Set the LocaleProvider for the client. |
static void |
setSystemLocaleProvider(LocaleProvider lp)
Set the LocaleProvider for the system. |
static void |
setUserLocaleProvider(LocaleProvider lp)
Set the LocaleProvider for the user. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
public LocaleNegotiator(String targetBundle, String acceptLanguages, String acceptCharsets, Locale packageLocale)
Select appropriate Locale, Charset, and ResourceBundle for a request.
targetBundle
- The target ResourceBundle for this request.acceptLanguages
- Acceptable languages according to the client.acceptCharsets
- Acceptable character sets according to the client.Method Detail |
public Locale getLocale()
The negotiated Locale for this request
public String getCharset()
The negotiated character set for this request
public ResourceBundle getBundle()
The negotiated ResourceBundle for this request
protected String getCharsetForLocale(Locale locale, String acceptCharsets)
Get the character set associated with a request. XXX We ignore the client charsets for now. Need to add this!
locale
- The Locale object representing the language we want.acceptCharsets
- Accpetable character sets according to the client.public static LocaleProvider getApplicationLocaleProvider()
Get the application LocaleProvider.
public static void setApplicationLocaleProvider(LocaleProvider lp)
Set the LocaleProvider for the application. This type of provider has the highest priority.
public static LocaleProvider getUserLocaleProvider()
Get the user LocaleProvider.
public static void setUserLocaleProvider(LocaleProvider lp)
Set the LocaleProvider for the user. This type of provider has the second highest priority.
public static LocaleProvider getClientLocaleProvider()
Get the client LocaleProvider.
public static void setClientLocaleProvider(LocaleProvider lp)
Set the LocaleProvider for the client. This type of provider has the third highest priority.
public static LocaleProvider getSystemLocaleProvider()
Get the system LocaleProvider.
public static void setSystemLocaleProvider(LocaleProvider lp)
Set the LocaleProvider for the system. This type of provider has the lowest priority.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |