org.alfresco.service.cmr.repository
Class MLText

java.lang.Object
  extended by java.util.AbstractMap
      extended by java.util.HashMap
          extended by org.alfresco.service.cmr.repository.MLText
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map

public class MLText
extends java.util.HashMap

Class to represent a multilingual (ML) text value.

The language codes used should conform to the ISO639-2 language code standard, although there is no enforcement of the standard in this class.

This is a simple extension of a HashMap with a few convenience methods.

See Also:
ISO639-2, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry, java.util.AbstractMap.SimpleImmutableEntry
 
Constructor Summary
MLText()
           
MLText(java.util.Locale locale, java.lang.String value)
          Construct an instance with a value for the given locale.
MLText(java.lang.String value)
          Construct an instance with a value corresponding to the current context locale.
 
Method Summary
 void addValue(java.util.Locale locale, java.lang.String value)
          Add a multilingual text value
 java.lang.String getClosestValue(java.util.Locale locale)
          The given locale is used to search for a matching value according to: An exact locale match A match of locale ISO language codes The value for the locale provided in the constructor An arbitrary value null
 java.lang.String getDefaultValue()
          Retrieves a default value from the set of available locales.
 java.util.Set getLocales()
           
 java.lang.String getValue(java.util.Locale locale)
          Retrieve a multilingual text value
 java.util.Collection getValues()
           
 void removeValue(java.util.Locale locale)
          Remove a multilingual text value
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

MLText

public MLText()

MLText

public MLText(java.lang.String value)
Construct an instance with a value corresponding to the current context locale.

Parameters:
value - the value for the current default locale
See Also:
I18NUtil.getLocale(), MLText.MLText(Locale, String), MLText.getDefaultValue()

MLText

public MLText(java.util.Locale locale,
              java.lang.String value)
Construct an instance with a value for the given locale.

Parameters:
locale - the locale
value - the value
See Also:
MLText.getDefaultValue()
Method Detail

getLocales

public java.util.Set getLocales()
Returns:
Returns all the language locales defined in the text

getValues

public java.util.Collection getValues()
Returns:
Returns all the values stored

addValue

public void addValue(java.util.Locale locale,
                     java.lang.String value)
Add a multilingual text value

Parameters:
locale - the language locale
value - the multilingual text

getValue

public java.lang.String getValue(java.util.Locale locale)
Retrieve a multilingual text value

Parameters:
locale - the language locale

getDefaultValue

public java.lang.String getDefaultValue()
Retrieves a default value from the set of available locales.

See Also:
I18NUtil.getLocale(), MLText.getClosestValue(Locale)

getClosestValue

public java.lang.String getClosestValue(java.util.Locale locale)
The given locale is used to search for a matching value according to:

Parameters:
locale - the locale to use as the starting point of the value search
Returns:
Returns a default String value or null if one isn't available. null will only be returned if there are no values associated with this instance. With or without a match, the return value may be null, depending on the values associated with the locales.

removeValue

public void removeValue(java.util.Locale locale)
Remove a multilingual text value

Parameters:
locale - the language locale


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.