Package org.exoplatform.commons.utils
Class I18N
java.lang.Object
org.exoplatform.commons.utils.I18N
Various I18N utility methods.
- Author:
- Julien Viet
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic LocaleReturns the parent locale of a locale or null when it does not have one.static LocaleParse the java string representation and returns a locale.static LocaleParse the http://www.ietf.org/rfc/rfc1766.txt string representation and returns a locale.static StringtoJavaIdentifier(Locale locale) Provide a string representation of the locale argument to theLocale.toString()method.static StringtoTagIdentifier(Locale locale) Provide a string representation of the locale argument according to the http://www.ietf.org/rfc/rfc1766.txt : locale with a language only will return the language string otherwise it returns the language and country separated by an hyphen '-'
-
Constructor Details
-
I18N
public I18N()
-
-
Method Details
-
toJavaIdentifier
Provide a string representation of the locale argument to theLocale.toString()method.- Parameters:
locale- the locale- Returns:
- the java representation
- Throws:
NullPointerException- if the locale argument is null
-
parseJavaIdentifier
public static Locale parseJavaIdentifier(String s) throws NullPointerException, IllegalArgumentException Parse the java string representation and returns a locale. SeetoJavaIdentifier(java.util.Locale)method for more details.- Parameters:
s- the java representation to parse- Returns:
- the corresponding locale
- Throws:
NullPointerException- if the locale argument is nullIllegalArgumentException- if the string cannot be parsed to a locale
-
toTagIdentifier
Provide a string representation of the locale argument according to the http://www.ietf.org/rfc/rfc1766.txt :- locale with a language only will return the language string
- otherwise it returns the language and country separated by an hyphen '-'
- Parameters:
locale- the locale- Returns:
- the RFC1766 representation
- Throws:
NullPointerException- if the locale argument is null
-
parseTagIdentifier
public static Locale parseTagIdentifier(String s) throws NullPointerException, IllegalArgumentException Parse the http://www.ietf.org/rfc/rfc1766.txt string representation and returns a locale. SeetoTagIdentifier(java.util.Locale)method for more details.- Parameters:
s- the RFC1766 representation to parse- Returns:
- the corresponding locale
- Throws:
NullPointerException- if the locale argument is nullIllegalArgumentException- if the string cannot be parsed to a locale
-
getParent
Returns the parent locale of a locale or null when it does not have one.- Parameters:
locale- the locale- Returns:
- the parent locale
- Throws:
NullPointerException- if the specified locale is null
-