Package lumis.util
Class LocaleUtil
- java.lang.Object
-
- lumis.util.LocaleUtil
-
@StableMinor(version="14.2", sinceVersion="4.0") public abstract class LocaleUtil extends Object
Utility class for Locale related operations- Since:
- 4.0.0
- Version:
- $Revision: 24985 $ $Date: 2022-05-02 23:04:30 -0300 (Mon, 02 May 2022) $
-
-
Field Summary
Fields Modifier and Type Field Description static String
LOCALE_ATTRIBUTE_NAME
-
Constructor Summary
Constructors Constructor Description LocaleUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Locale
fromRequest(HttpServletRequest request)
Returns the locale requested by the givenHttpServletRequest
, or the default locale if none was specified in the request.static Locale
fromRequest(HttpServletRequest request, boolean fallbackToDefault)
Returns the locale requested by the givenHttpServletRequest
.static Locale
fromString(String locale)
Returns the locale represented by the given string.static Locale
FromString(String locale)
Deprecated.since 8.1.0 replaced byfromString(String)
.static Locale
fromXMLLang(String xmlLang)
Returns the locale corresponding to a String following XML lang syntax (e.g.: en-US).
-
-
-
Field Detail
-
LOCALE_ATTRIBUTE_NAME
public static final String LOCALE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
FromString
@Deprecated public static Locale FromString(String locale) throws PortalException
Deprecated.since 8.1.0 replaced byfromString(String)
.- Throws:
PortalException
-
fromString
public static Locale fromString(String locale) throws PortalException
Returns the locale represented by the given string. Expects a string with the following format:
_ _ - <language>
- is the language code
- <country>
- is the country code
- <variant>
- is the variant part
For more information, refer to
Locale
.- Parameters:
locale
- the locale string.- Returns:
- the locale represented by the given string.
- Throws:
PortalException
- Since:
- 8.1.0
- See Also:
Locale(String, String, String)
-
fromXMLLang
public static Locale fromXMLLang(String xmlLang)
Returns the locale corresponding to a String following XML lang syntax (e.g.: en-US).- Parameters:
xmlLang
- the XML lang value, according to the RFC3066.- Returns:
- the locale.
- Throws:
IllegalArgumentException
- if xmlLang isnull
or is an invalid locale identifier.- Since:
- 5.5.0
-
fromRequest
public static Locale fromRequest(HttpServletRequest request) throws PortalException
Returns the locale requested by the givenHttpServletRequest
, or the default locale if none was specified in the request.- Parameters:
request
- the request.- Returns:
- the locale.
- Throws:
PortalException
- Since:
- 4.0
-
fromRequest
public static Locale fromRequest(HttpServletRequest request, boolean fallbackToDefault) throws PortalException
Returns the locale requested by the givenHttpServletRequest
.- Parameters:
request
- the request.fallbackToDefault
- iftrue
the default locale is returned instead ofnull
when no locale is specified in the request.- Returns:
- the requested locale. If no locale is specified in the request, returns the
default locale if
fallbackToDefault
istrue
or returnsnull
if it isfalse
. - Throws:
PortalException
- Since:
- 12.5.0
-
-