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

LocalizedString - JBOSS Portal 2.6 API 英文版文档


org.jboss.portal.common.util
Class LocalizedString

java.lang.Object
  extended byorg.jboss.portal.common.util.LocalizedString

public class LocalizedString
extends java.lang.Object

An immutable localized string.

Version:
$Revision: 5451 $
Author:
Julien Viet, Chris Laprun

Nested Class Summary
static class LocalizedString.Value
          A localized value.
 
Field Summary
private  java.util.Locale defaultLocale
          The default locale.
private static org.jboss.logging.Logger log
          The logger.
private  java.util.Map values
          The descriptions.
 
Constructor Summary
LocalizedString(java.util.Locale defaultLocale)
           
LocalizedString(java.util.Map values, java.util.Locale defaultLocale)
           
LocalizedString(java.lang.String defaultValue, java.util.Locale defaultLocale)
          Convenience constructor for simple localized strings with only one value using the default locale.
 
Method Summary
private  void addValueForLocale(java.util.Map values, java.util.Locale locale, java.lang.String value)
          Adds a new value for the specified locale to this LocalizedString.
 java.util.Locale getDefaultLocale()
          Return the default locale of this description.
 java.lang.String getDefaultString()
          Return the string for the default locale.
 LocalizedString.Value getDefaultValue()
          Return the value for the default locale.
 java.lang.String getMostAppropriateValueFor(java.lang.String[] desiredLocales)
          Retrieves the localized value most appropriate based on the given desired locales.
 LocalizedString.Value getPreferredOrBestLocalizedMappingFor(java.lang.String[] desiredLocales)
          Retrieves the Locale-String mapping most appropriate based on the given desired locales, which are ordered according to locale preferences.
 java.lang.String getString(java.util.Locale locale, boolean resolve)
          Return the string of the localized value of the description.
 LocalizedString.Value getValue(java.util.Locale locale, boolean resolve)
          Return a localized value of the description.
 boolean hasValues()
          Determines if this LocalizedString contains any values.
 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 final org.jboss.logging.Logger log
The logger.


values

private final java.util.Map values
The descriptions.


defaultLocale

private final java.util.Locale defaultLocale
The default locale.

Constructor Detail

LocalizedString

public LocalizedString(java.lang.String defaultValue,
                       java.util.Locale defaultLocale)
                throws java.lang.IllegalArgumentException
Convenience constructor for simple localized strings with only one value using the default locale.

Parameters:
defaultValue - the localized value using the specified default locale
defaultLocale - the default locale
Since:
2.4

LocalizedString

public LocalizedString(java.util.Locale defaultLocale)
                throws java.lang.IllegalArgumentException

LocalizedString

public LocalizedString(java.util.Map values,
                       java.util.Locale defaultLocale)
                throws java.lang.IllegalArgumentException
Method Detail

addValueForLocale

private void addValueForLocale(java.util.Map values,
                               java.util.Locale locale,
                               java.lang.String value)
Adds a new value for the specified locale to this LocalizedString. Note that if a value existed for this Locale, it will be overwritten.

Parameters:
locale - the locale of the value
value - the value
Since:
2.4

hasValues

public boolean hasValues()
Determines if this LocalizedString contains any values.

Returns:
true if this LocalizedString contains localized values, false otherwise.
Since:
2.4

getDefaultString

public java.lang.String getDefaultString()
Return the string for the default locale.

Returns:
the string for the default locale

getDefaultValue

public LocalizedString.Value getDefaultValue()
Return the value for the default locale.

Returns:
the value for the default locale

getString

public java.lang.String getString(java.util.Locale locale,
                                  boolean resolve)
Return the string of the localized value of the description.

Parameters:
locale - the desired locale for the description
resolve - true if the locale must be resolved to the most appropriate
Returns:
the description string or null if it is not found when resolving is false

getValue

public LocalizedString.Value getValue(java.util.Locale locale,
                                      boolean resolve)
Return a localized value of the description.

Parameters:
locale - the desired locale for the description
resolve - true if the locale must be resolved to the most appropriate
Returns:
the description value or null if it is not found when resolving is false

getDefaultLocale

public java.util.Locale getDefaultLocale()
Return the default locale of this description.


getMostAppropriateValueFor

public java.lang.String getMostAppropriateValueFor(java.lang.String[] desiredLocales)
                                            throws java.lang.IllegalArgumentException
Retrieves the localized value most appropriate based on the given desired locales.

Parameters:
desiredLocales - an array of compound language tags (as defined by IETF RFC 3066) ordered according to locale preferences.
Returns:
the most appropriate localized value based on locale preferences.
Throws:
java.lang.IllegalArgumentException - if the array is null or one of the array string is null or invalid (see #getLocaleFromRFC3066LanguageTag(String))
Since:
2.4

getPreferredOrBestLocalizedMappingFor

public LocalizedString.Value getPreferredOrBestLocalizedMappingFor(java.lang.String[] desiredLocales)
                                                            throws java.lang.IllegalArgumentException
Retrieves the Locale-String mapping most appropriate based on the given desired locales, which are ordered according to locale preferences.

Parameters:
desiredLocales - an array of compound language tags (as defined by IETF RFC 3066) ordered according to locale preferences.
Returns:
a Map.Entry representing the most appropriate mapping between Locale and localized value, based on locale preferences.
Throws:
java.lang.IllegalArgumentException - if the array is null or one of the array string is null or invalid (see LocaleInfo.decodeLocaleInfoFromRFC3066LanguageTag(String)
Since:
2.4

toString

public java.lang.String toString()