Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.portal.common.i18n
Class LocalizedString

    java.lang.Object
      org.jboss.portal.common.i18n.LocalizedString

    public final class LocalizedString

extends java.lang.Object

An immutable locale sensitive object that returns strings.

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

Nested Class Summary
`static class` | `LocalizedString.Value` A localized string value.

Constructor Summary
`LocalizedString(java.util.Locale defaultLocale)` Build an empty localized string.
`LocalizedString(java.util.Map values, java.util.Locale defaultLocale)` Build a localized string using a Map object.
`LocalizedString(java.lang.String defaultValue)` Convenience constructor for simple localized strings with only one value using the `Locale.ENGLISH` locale.
`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
`boolean` | `equals(java.lang.Object o)`
`java.util.Locale` | `getDefaultLocale()` Return the default locale of this localized string.
`java.lang.String` | `getDefaultString()` Return the string for the default locale.
`LocalizedString.Value` | `getDefaultValue()` Returns 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)` Returns a string value.
`LocalizedString.Value` | `getValue(java.util.Locale locale, boolean resolve)` Returns a localized value.
`java.util.Map` | `getValues()`
`int` | `hashCode()`
`boolean` | `hasValues()` Determines if this LocalizedString contains any values.
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### LocalizedString

    public LocalizedString(java.lang.String defaultValue)
                    throws java.lang.IllegalArgumentException

  Convenience constructor for simple localized strings with only one value using the `Locale.ENGLISH` locale.

  Parameters:
    `defaultValue` - the localized value using the specified default locale
  Throws:
    `java.lang.IllegalArgumentException` - if no default value or locale is provided
  Since:
    2.6

### 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
  Throws:
    `java.lang.IllegalArgumentException` - if no default value or locale is provided
  Since:
    2.4

### LocalizedString

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

  Build an empty localized string.

  Parameters:
    `defaultLocale` - the default locale
  Throws:
    `java.lang.IllegalArgumentException` - if no default locale is provided

### LocalizedString

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

  Build a localized string using a Map object.

  Parameters:
    `values` - the Map
    `defaultLocale` -
  Throws:
    `java.lang.IllegalArgumentException` - if one argument if null or if the map entries are different from Map.Entry

Method Detail

### 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()

  Returns 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)

  Returns a string value.

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

### getValue

    public LocalizedString.Value getValue(java.util.Locale locale,
                                          boolean resolve)

  Returns a localized value. The lookup operation can be done without resolution which means that the locale is just used as a key during the lookup. If the lookup operation is done with resolution then the different parts of the locale will be used during the operation.

  Parameters:
    `locale` - the desired locale
    `resolve` - true if the locale must be resolved to the most appropriate
  Returns:
    the value or null if it is not found

### getValues

    public java.util.Map getValues()

### getDefaultLocale

    public java.util.Locale getDefaultLocale()

  Return the default locale of this localized string.

  Returns:
    the default locale

### 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 `LocaleFormat#RFC3066_LANGUAGE_TAG#getLocale(String)`
  Since:
    2.4

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### equals

    public boolean equals(java.lang.Object o)

  Overrides:
    `equals` in class `java.lang.Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD