|
Jive Forums API (5.5.20.2-oracle) Developer Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jivesoftware.util.LocaleUtils
public class LocaleUtils
A set of methods for retrieving and converting locale specific strings and numbers.
Method Summary | |
---|---|
static java.lang.String |
getDateFormatPattern(java.util.Locale locale)
Returns the DateFormat pattern for the given locale |
static java.util.Map |
getISO639LanguageMap()
Returns a map of ISO-639 languages. |
static java.lang.String |
getLocaleAlignment(java.util.Locale locale)
Returns the alignment direction for a given locale. |
static java.lang.String |
getLocalizedNumber(double number)
Returns a number formatted to the rules of the default Jive Forums locale. |
static java.lang.String |
getLocalizedNumber(double number,
java.util.Locale locale)
Returns a number formatted to the rules of the given locale. |
static java.lang.String |
getLocalizedNumber(long number)
Returns a number formatted to the rules of the default Jive Forums locale. |
static java.lang.String |
getLocalizedNumber(long number,
java.util.Locale locale)
Returns a number formatted to the rules of the given locale. |
static java.lang.String |
getLocalizedString(java.lang.String key)
Returns an internationalized string loaded from a resource bundle. |
static java.lang.String |
getLocalizedString(java.lang.String key,
java.util.List arguments)
Returns an internationalized string loaded from a resource bundle using the locale specified by JiveGlobals.getLocale() substituting the passed in arguments. |
static java.lang.String |
getLocalizedString(java.lang.String key,
java.util.Locale locale)
Returns an internationalized string loaded from a resource bundle using the passed in Locale. |
static java.lang.String |
getLocalizedString(java.lang.String key,
java.util.Locale locale,
java.util.List arguments)
Returns an internationalized string loaded from a resource bundle using the passed in Locale substituting the passed in arguments. |
static java.lang.String |
getLocalizedString(java.lang.String key,
java.util.Locale locale,
java.util.List arguments,
java.util.ResourceBundle bundle)
Returns an internationalized string loaded from a resource bundle using the passed in Locale substituting the passed in arguments. |
static java.lang.String |
getLocalizedString(java.lang.String key,
java.lang.String pluginName)
Returns an internationalized string loaded from a resource bundle from the passed in plugin. |
static java.lang.String |
getLocalizedString(java.lang.String key,
java.lang.String pluginName,
java.util.List arguments)
Returns an internationalized string loaded from a resource bundle from the passed in plugin. |
static java.util.ResourceBundle |
getResourceBundle(java.lang.String baseName)
Wrapper method to get a resource bundle for the default locale. |
static java.util.ResourceBundle |
getResourceBundle(java.lang.String baseName,
java.util.Locale locale)
Deprecated. Use just ResourceBundle.getBundle(String,Locale) instead. |
static java.lang.String |
getShortDateFormatPattern(java.util.Locale locale)
|
static java.util.TimeZone |
getTimeZone(javax.servlet.http.HttpServletRequest request,
User user)
Returns the time zone for a user according to their time zone preferences (if they exist). |
static java.lang.String[][] |
getTimeZoneList()
Returns a list of all available time zone's as a String [][]. |
static java.lang.String[][] |
getTimeZoneList(java.util.Locale locale)
Returns the list of all available time zone's as a String [][], based on the specified locale. |
static java.util.Locale |
getUserLocale(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String sessionKey)
Returns the user's locale. |
static java.util.Locale |
getUserLocale(javax.servlet.http.HttpServletRequest request,
User user)
Returns the page user's locale. |
static java.util.Locale |
getUserLocale(java.lang.String sessionKey)
Returns the user's locale using the authtoken from the HttpSession. |
static boolean |
isValidCharacterEncoding(java.lang.String encoding)
Returns true if the given character encoding is valid, false otherwise. |
static java.util.Locale |
localeCodeToLocale(java.lang.String localeCode)
Converts a locale string like "en", "en_US" or "en_US_win" to a Java locale object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.util.Locale localeCodeToLocale(java.lang.String localeCode)
localeCode
- the locale code for a Java locale. See the Locale
class for more details.public static boolean isValidCharacterEncoding(java.lang.String encoding)
encoding
- the encoding to test.
public static java.util.Map getISO639LanguageMap()
public static java.lang.String[][] getTimeZoneList()
The list of time zones attempts to be inclusive of all of the worlds zones while being as concise as possible. For "en" language locales the name is a friendly english name. For non-"en" language locales the standard JDK name is used for the given Locale. The GMT+/- time is also included for readability.
public static java.lang.String[][] getTimeZoneList(java.util.Locale locale)
getTimeZoneList()
.
locale
- for localizing the time zone.
public static java.util.Locale getUserLocale(javax.servlet.http.HttpServletRequest request, User user)
If any locale lookups fail, the default Jive locale will be used.
JiveGlobals.getLocale()
,
Locale
public static java.util.Locale getUserLocale(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String sessionKey)
request
- the current request.response
- the current response.sessionKey
- the key to the HttpSession for the authToken to be obtained from.
JiveGlobals.getLocale()
,
Locale
public static java.util.Locale getUserLocale(java.lang.String sessionKey)
sessionKey
- the key to the HttpSession for the authToken to be obtained from.
JiveGlobals.getLocale()
,
Locale
public static java.util.TimeZone getTimeZone(javax.servlet.http.HttpServletRequest request, User user)
request
- the servlet request object for looking up a timezone cookie for anonymous
users. This can be null.user
- the User that the date is being formatted for, or null if an anonymous user.
public static java.lang.String getLocalizedString(java.lang.String key)
By default, this loads the resource bundle with the basename of 'jive_forums_i18n' to preserve backwards compatibility. To override this, call
ResourceBundle.getBundle(String)
and specify the name of bundle to load.
Then call the getString() method on returned bundle object.
key
- the key to use for retrieving the string from the
appropriate resource bundle.
public static java.lang.String getLocalizedString(java.lang.String key, java.lang.String pluginName)
key
- the key to use for retrieving the string from the
appropriate resource bundle.pluginName
- the name of the plugin to load the require resource bundle from.
public static java.lang.String getLocalizedString(java.lang.String key, java.lang.String pluginName, java.util.List arguments)
key
- the key to use for retrieving the string from the
appropriate resource bundle.pluginName
- the name of the plugin to load the require resource bundle from.arguments
- a list of objects to use which are formatted, then
inserted into the pattern at the appropriate places.
public static java.lang.String getLocalizedString(java.lang.String key, java.util.Locale locale, java.util.List arguments, java.util.ResourceBundle bundle)
MessageFormat
class.
key
- the key to use for retrieving the string from the
appropriate resource bundle.locale
- the locale to use for retrieving the appropriate
locale-specific string.arguments
- a list of objects to use which are formatted, then
inserted into the pattern at the appropriate places.
public static java.lang.String getLocalizedString(java.lang.String key, java.util.Locale locale)
By default, this loads the resource bundle with the basename of 'jive_forums_i18n' to preserve backwards compatibility. To override this, call
ResourceBundle.getBundle(String,Locale)
and specify the name of bundle to load.
Then call the getString() method on returned bundle object.
key
- the key to use for retrieving the string from the
appropriate resource bundle.locale
- the locale to use for retrieving the appropriate
locale-specific string.
public static java.lang.String getLocalizedString(java.lang.String key, java.util.List arguments)
MessageFormat
class.
By default, this loads the resource bundle with the basename of 'jive_forums_i18n'
to preserve backwards compatibility. To override this, call
ResourceBundle.getBundle(String,Locale)
and specify the name of bundle to load.
Then call the getString() method on returned bundle object. To handle the argument
list, see the MessageFormat
class.
key
- the key to use for retrieving the string from the
appropriate resource bundle.arguments
- a list of objects to use which are formatted, then
inserted into the pattern at the appropriate places.
public static java.lang.String getLocalizedString(java.lang.String key, java.util.Locale locale, java.util.List arguments)
MessageFormat
class.
key
- the key to use for retrieving the string from the
appropriate resource bundle.locale
- the locale to use for retrieving the appropriate
locale-specific string.arguments
- a list of objects to use which are formatted, then
inserted into the pattern at the appropriate places.
public static java.lang.String getLocalizedNumber(long number)
number
- the number to format.
public static java.lang.String getLocalizedNumber(long number, java.util.Locale locale)
number
- the number to format.locale
- the locale to use when formatting this number.
public static java.lang.String getLocalizedNumber(double number)
number
- the number to format.
public static java.lang.String getLocalizedNumber(double number, java.util.Locale locale)
number
- the number to format.locale
- the locale to use when formatting this number.
public static java.util.ResourceBundle getResourceBundle(java.lang.String baseName, java.util.Locale locale)
ResourceBundle.getBundle(String,Locale)
instead.
baseName
- the name of the resource bundle to load.locale
- the desired Locale.
public static java.util.ResourceBundle getResourceBundle(java.lang.String baseName)
baseName
- the base name of the resource bundle to lookup
public static java.lang.String getDateFormatPattern(java.util.Locale locale)
locale
- Java locale for which to lookup the DateFormat
pattern
DateFormat
public static java.lang.String getShortDateFormatPattern(java.util.Locale locale)
public static java.lang.String getLocaleAlignment(java.util.Locale locale)
locale
- the locale to check the all
|
Jive Forums Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |