Class Labels

java.lang.Object
eu.c6.gibraltar.api.common.CObject
eu.c6.gibraltar.api.common.Labels
All Implemented Interfaces:
ICObject, ILabels, Serializable, Cloneable

public class Labels extends CObject implements ILabels
The Class Labels to manage localized labels.

Example :

 ILabels labels = new Labels();
 labels.setLabel(Locale.FRANCE, "My label FR");
 labels.setLabel(Locale.ENGLISH, "My label EN");
 String labelFr = labels.getLocalizedValue(Locale.FRANCE);
 
See Also:
  • Constructor Details

    • Labels

      public Labels(ICObject obj)
      Instantiates a new Labels from ICObject instance.
      Parameters:
      obj - the ICObject instance
    • Labels

      public Labels()
      Instantiates a new Labels.
    • Labels

      public Labels(Map<Locale,String> values)
      Instantiates a new Labels from map of values and locales.
      Parameters:
      values - the values
  • Method Details

    • getLocales

      public List<Locale> getLocales()
      Description copied from interface: ILabels
      Gets the label locales.
      Specified by:
      getLocales in interface ILabels
      Returns:
      the locales
    • getLocalizedMapValues

      public Map<Locale,String> getLocalizedMapValues()
      Description copied from interface: ILabels
      Gets the localized map values to have all localized labels
      Specified by:
      getLocalizedMapValues in interface ILabels
      Returns:
      the localized map of label values
    • getLocalizedMapValues

      public Map<Locale,String> getLocalizedMapValues(String defaultValue, Locale fallbackLocale)
      Description copied from interface: ILabels
      Gets the localized map values to have all localized labels
      Specified by:
      getLocalizedMapValues in interface ILabels
      Parameters:
      defaultValue - the default value if label is NULL or empty
      fallbackLocale - the fallback locale to use if label is empty or NULL
      Returns:
      the localized map values
    • getLocalizedValue

      public String getLocalizedValue(Locale locale)
      Description copied from interface: ILabels
      Gets the localized value for a locale.
      Specified by:
      getLocalizedValue in interface ILabels
      Parameters:
      locale - the locale
      Returns:
      the localized value
    • getLocalizedValue

      public String getLocalizedValue(Locale locale, String defValue, Locale fallbackLocale)
      Description copied from interface: ILabels
      Gets the localized value for a locale.
      Specified by:
      getLocalizedValue in interface ILabels
      Parameters:
      locale - the locale
      defValue - the default value if locale is not managed and default locale has not value
      fallbackLocale - the fallback locale if locale is not managed
      Returns:
      the localized value
    • getLocalizedValue

      public String getLocalizedValue(Locale locale, String defValue)
      Description copied from interface: ILabels
      Gets the localized value for a locale.
      Specified by:
      getLocalizedValue in interface ILabels
      Parameters:
      locale - the locale
      defValue - the default value if locale is not managed
      Returns:
      the localized value
    • setLocalizedMapValue

      public void setLocalizedMapValue(Map<Locale,String> values)
      Description copied from interface: ILabels
      Sets the localized map values.
      Specified by:
      setLocalizedMapValue in interface ILabels
      Parameters:
      values - the values
    • setLabel

      public void setLabel(Locale locale, String label)
      Description copied from interface: ILabels
      Sets the label for a locale.
      Specified by:
      setLabel in interface ILabels
      Parameters:
      locale - the locale
      label - the label
    • removeLabel

      public void removeLabel(Locale locale)
      Description copied from interface: ILabels
      Removes the label for a locale.
      Specified by:
      removeLabel in interface ILabels
      Parameters:
      locale - the locale
    • getLabelAsString

      public String getLabelAsString(Locale locale)
      Description copied from interface: ILabels
      Gets the label as string representation.
      Specified by:
      getLabelAsString in interface ILabels
      Parameters:
      locale - the locale
      Returns:
      the label as string
    • hasNoLabelValue

      public boolean hasNoLabelValue()
      Description copied from interface: ILabels
      Checks for no label value.
      Specified by:
      hasNoLabelValue in interface ILabels
      Returns:
      true, if one of the label is NULL or empty
    • hasNoLabelValue

      public boolean hasNoLabelValue(Locale searchLocale)
      Description copied from interface: ILabels
      Checks for no label value for a locale.
      Specified by:
      hasNoLabelValue in interface ILabels
      Parameters:
      searchLocale - the locale
      Returns:
      true, if label of the locale is NULL or empty