Class LocalizableStringValue

  • All Implemented Interfaces:
    java.io.Serializable, StringValue

    public class LocalizableStringValue
    extends java.lang.Object
    implements StringValue
    A StringValue which looks up localized String representations for objects.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Locale locale  
      private java.util.Map<java.lang.Object,​java.lang.String> lookup  
      private java.lang.String prefix  
    • Constructor Summary

      Constructors 
      Constructor Description
      LocalizableStringValue​(java.util.Map<java.lang.Object,​java.lang.String> lookup)
      Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the JComponent defaultLocale.
      LocalizableStringValue​(java.util.Map<java.lang.Object,​java.lang.String> lookup, java.lang.String prefix)
      Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the JComponent defaultLocale.
      LocalizableStringValue​(java.util.Map<java.lang.Object,​java.lang.String> lookup, java.lang.String prefix, java.util.Locale locale)
      Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the given Locale.
      LocalizableStringValue​(java.util.Map<java.lang.Object,​java.lang.String> lookup, java.util.Locale locale)
      Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the given Locale.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Locale getLocale()
      Returns the Locale to use for lookup, guaranteed to be not null.
      java.lang.String getString​(java.lang.Object value)
      Returns a string representation of the given value.
      void setLocale​(java.util.Locale locale)
      Sets the Locale to use for lookup of localized string representation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • lookup

        private java.util.Map<java.lang.Object,​java.lang.String> lookup
      • locale

        private java.util.Locale locale
      • prefix

        private java.lang.String prefix
    • Constructor Detail

      • LocalizableStringValue

        public LocalizableStringValue​(java.util.Map<java.lang.Object,​java.lang.String> lookup)
        Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the JComponent defaultLocale.
        Parameters:
        lookup - a map containing Entries of objects and a string key to look up its string representation in the UIManager
      • LocalizableStringValue

        public LocalizableStringValue​(java.util.Map<java.lang.Object,​java.lang.String> lookup,
                                      java.util.Locale locale)
        Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the given Locale.
        Parameters:
        lookup - a map containing Entries of objects and a string key to look up its string representation in the UIManager
        locale - the locale to lookup the localized strings, may be null to denote using JComponent.defaultLocale
      • LocalizableStringValue

        public LocalizableStringValue​(java.util.Map<java.lang.Object,​java.lang.String> lookup,
                                      java.lang.String prefix)
        Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the JComponent defaultLocale.
        Parameters:
        lookup - a map containing Entries of objects and a string key to look up its string representation in the UIManager
        prefix - a common prefix for all string keys in the map, may be null to denote that the keys should be use as are
      • LocalizableStringValue

        public LocalizableStringValue​(java.util.Map<java.lang.Object,​java.lang.String> lookup,
                                      java.lang.String prefix,
                                      java.util.Locale locale)
        Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the given Locale.
        Parameters:
        lookup - a map containing Entries of objects and a string key to look up its string representation in the UIManager
        prefix - a common prefix for all string keys in the map, may be null to denote that the keys should be use as are
        locale - the locale to lookup the localized strings, may be null to denote using JComponent.defaultLocale
    • Method Detail

      • getString

        public java.lang.String getString​(java.lang.Object value)
        Description copied from interface: StringValue
        Returns a string representation of the given value.

        PENDING JW: forgot - why not null return guaranteed?

        Specified by:
        getString in interface StringValue
        Parameters:
        value - the object to present as a string
        Returns:
        a string representation of the given value, guaranteed to be not null
      • setLocale

        public final void setLocale​(java.util.Locale locale)
        Sets the Locale to use for lookup of localized string representation.
        Parameters:
        locale - the locale to lookup the localized strings, may be null to denote using Locale's default.
      • getLocale

        public java.util.Locale getLocale()
        Returns the Locale to use for lookup, guaranteed to be not null. If the initial setting had been null, returns current Locale's default.
        Returns:
        the Locale used for lookup.