Package lumis.util
Class LocaleUtil
- java.lang.Object
-
- lumis.util.LocaleUtil
-
@StableMinor(version="16.1", sinceVersion="4.0") public abstract class LocaleUtil extends java.lang.Object
Utility class for Locale related operations- Since:
- 4.0.0
- Version:
- $Revision: 26156 $ $Date: 2024-01-13 10:26:46 -0300 (Sat, 13 Jan 2024) $
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.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 java.util.Locale
fromRequest(HttpServletRequest request)
Returns the locale requested by the givenHttpServletRequest
, or the default locale if none was specified in the request.static java.util.Locale
fromRequest(HttpServletRequest request, boolean fallbackToDefault)
Returns the locale requested by the givenHttpServletRequest
.static java.util.Locale
fromString(java.lang.String locale)
Returns the locale represented by the given string.static java.util.Locale
FromString(java.lang.String locale)
Deprecated.since 8.1.0 replaced byfromString(String)
.static java.util.Locale
fromXMLLang(java.lang.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 java.lang.String LOCALE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
FromString
@Deprecated public static java.util.Locale FromString(java.lang.String locale) throws PortalException
Deprecated.since 8.1.0 replaced byfromString(String)
.- Throws:
PortalException
-
fromString
public static java.util.Locale fromString(java.lang.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 java.util.Locale fromXMLLang(java.lang.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:
java.lang.IllegalArgumentException
- if xmlLang isnull
or is an invalid locale identifier.- Since:
- 5.5.0
-
fromRequest
public static java.util.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 java.util.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
-
-