站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBOSS Portal 2.6 API 英文版文档

LocaleInfo - JBOSS Portal 2.6 API 英文版文档


org.jboss.portal.migration.model24.identity
Class LocaleInfo

java.lang.Object
  extended byorg.jboss.portal.migration.model24.identity.LocaleInfo

public final class LocaleInfo
extends java.lang.Object

Additional infos about a locale.

Version:
$Revision: 5449 $
Author:
Julien Viet

Nested Class Summary
private static class LocaleInfo.Infos
          Hold the several ways to retrieve infos object.
 
Field Summary
private static java.util.Comparator c
           
private  java.util.Locale locale
          The relaled locale.
private static org.apache.log4j.Logger log
          The logger.
private  LocaleInfo parent
          The parent locale info or null if no parent.
private static java.util.regex.Pattern RFC3066_COMPOUND_LANG_PATTERN
          Valid language tag matcher (see IETF RFC 3066).
private static java.lang.String RFC3066_SEPARATOR
          Separator.
private  java.lang.String rfc3066LangageTag
          The RFC3066 language tag.
private static LocaleInfo.Infos sharedInfos
          The locale info map.
private static java.lang.String[] SORTED_ISO_COUNTRIES
          Sorted valid ISO country codes (needed for Arrays.binarySearch).
private static java.lang.String[] SORTED_ISO_LANGUAGES
          Sorted valid ISO language codes (needed for Arrays.binarySearch).
private  java.lang.String trailingName
          The trailing name used to compute resource bundle name.
 
Constructor Summary
private LocaleInfo(LocaleInfo parent, java.util.Locale locale)
           
 
Method Summary
static java.lang.String computeTrailingName(java.util.Locale locale)
          Compute the trailing name for a given locale.
private static LocaleInfo.Infos createFromAvailableLocales()
          Create an infos object from the set of locales returned by Locale.getAvailableLocales().
static LocaleInfo decodeLocaleInfo(java.util.Locale locale)
          Return the locale info for a specific locale.
static LocaleInfo decodeLocaleInfo(java.lang.String code)
          Return the locale info for a specific code.
static LocaleInfo decodeLocaleInfoFromRFC3066LanguageTag(java.lang.String languageIdentificationTag)
          Returns an info object based on the given language identification tag as defined by IETF RFC 3066 limited to 2-letter language code per ISO standard 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes.
static java.util.Collection getAll()
          Return a collection of all available locale info for the platform.
private static LocaleInfo getInfo(java.util.Locale locale, LocaleInfo.Infos infos)
          Get an info object.
 java.util.Locale getLocale()
           
 LocaleInfo getParent()
           
 java.lang.String getRFC3066LanguageTag()
          Retrieves the language identification tag associated to this LocaleInfo as defined by IETF RFC 3066 limited to 2-letter language code per ISO standard 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes.
static java.lang.String getRFC3066LanguageTagFor(java.util.Locale locale)
          Retrieves the language identification tag associated to the specified Locale as defined by IETF RFC 3066 limited to 2-letter language code per ISO standard 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes.
 java.lang.String getTrailingName()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Logger log
The logger.


sharedInfos

private static volatile LocaleInfo.Infos sharedInfos
The locale info map.


RFC3066_SEPARATOR

private static final java.lang.String RFC3066_SEPARATOR
Separator.

See Also:
Constant Field Values

RFC3066_COMPOUND_LANG_PATTERN

private static final java.util.regex.Pattern RFC3066_COMPOUND_LANG_PATTERN
Valid language tag matcher (see IETF RFC 3066).


SORTED_ISO_COUNTRIES

private static final java.lang.String[] SORTED_ISO_COUNTRIES
Sorted valid ISO country codes (needed for Arrays.binarySearch).


SORTED_ISO_LANGUAGES

private static final java.lang.String[] SORTED_ISO_LANGUAGES
Sorted valid ISO language codes (needed for Arrays.binarySearch).


c

private static final java.util.Comparator c

parent

private LocaleInfo parent
The parent locale info or null if no parent.


locale

private java.util.Locale locale
The relaled locale.


trailingName

private java.lang.String trailingName
The trailing name used to compute resource bundle name.


rfc3066LangageTag

private java.lang.String rfc3066LangageTag
The RFC3066 language tag.

Constructor Detail

LocaleInfo

private LocaleInfo(LocaleInfo parent,
                   java.util.Locale locale)
Method Detail

getParent

public LocaleInfo getParent()

getLocale

public java.util.Locale getLocale()

getTrailingName

public java.lang.String getTrailingName()

getRFC3066LanguageTag

public java.lang.String getRFC3066LanguageTag()
Retrieves the language identification tag associated to this LocaleInfo as defined by IETF RFC 3066 limited to 2-letter language code per ISO standard 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes. E.g. "en-US" for American English, "en-GB" for British English, etc.

Returns:
a IETF RFC 3066-compatible language tag.
Throws:
java.lang.IllegalArgumentException - if the given locale is not valid
Since:
2.4

getRFC3066LanguageTagFor

public static java.lang.String getRFC3066LanguageTagFor(java.util.Locale locale)
Retrieves the language identification tag associated to the specified Locale as defined by IETF RFC 3066 limited to 2-letter language code per ISO standard 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes. E.g. "en-US" for American English, "en-GB" for British English, etc.

Parameters:
locale - the locale which language tag is wanted
Returns:
a IETF RFC 3066-compatible language tag.
Throws:
java.lang.IllegalArgumentException - if the given locale is not valid
Since:
2.4

toString

public java.lang.String toString()

computeTrailingName

public static java.lang.String computeTrailingName(java.util.Locale locale)
                                            throws java.lang.IllegalArgumentException
Compute the trailing name for a given locale.

Parameters:
locale - the locale
Returns:
the trailing name
Throws:
java.lang.IllegalArgumentException - if locale is null

getInfo

private static LocaleInfo getInfo(java.util.Locale locale,
                                  LocaleInfo.Infos infos)

Get an info object.

Whenever the info object cannot be found then it creates a new one and possibly several since each info object may have a non null parent.

If the infos argument is null, then the static shared infos is used to perform a lookup. If the lookup returns null then the shared infos is cloned and updated with the newly created info objects. The operation performed is a copy on write and is thread safe. Note that concurrent updates may cause the lost of info object in the shared infos.

If the infos argument is not null, then it is used to perform a lookup first. If the lookup returns null then the infos object udpated with the newly created info objects. Note that no cloning of the infos object is performed.

Parameters:
locale - the locale
infos - the infos
Returns:
A info object for the given locale

createFromAvailableLocales

private static LocaleInfo.Infos createFromAvailableLocales()
Create an infos object from the set of locales returned by Locale.getAvailableLocales().


getAll

public static java.util.Collection getAll()
Return a collection of all available locale info for the platform.


decodeLocaleInfo

public static LocaleInfo decodeLocaleInfo(java.lang.String code)
                                   throws java.lang.IllegalArgumentException
Return the locale info for a specific code.

Throws:
java.lang.IllegalArgumentException - if the locale info is not found for the code

decodeLocaleInfo

public static LocaleInfo decodeLocaleInfo(java.util.Locale locale)
Return the locale info for a specific locale.

Throws:
java.lang.IllegalArgumentException - if the locale is not found for the code

decodeLocaleInfoFromRFC3066LanguageTag

public static LocaleInfo decodeLocaleInfoFromRFC3066LanguageTag(java.lang.String languageIdentificationTag)
Returns an info object based on the given language identification tag as defined by IETF RFC 3066 limited to 2-letter language code per ISO standard 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes. E.g. "en-US" for American English, "en-GB" for British English, etc.

Parameters:
languageIdentificationTag - the language tag to build the Locale from
Returns:
a LocaleInfo associated to the given compound language tag
Throws:
java.lang.IllegalArgumentException - if the given compound language is not a valid one or null
Since:
2.4