Package org.jdesktop.swingx.renderer
Class LocalizableStringValue
java.lang.Object
org.jdesktop.swingx.renderer.LocalizableStringValue
- All Implemented Interfaces:
Serializable
,StringValue
A StringValue which looks up localized String representations for objects.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLocalizableStringValue
(Map<Object, String> lookup) Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the JComponent defaultLocale.LocalizableStringValue
(Map<Object, String> lookup, String prefix) Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the JComponent defaultLocale.Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the given Locale.LocalizableStringValue
(Map<Object, String> lookup, Locale locale) Instantiates a LocaleStringValue which looks up localized String representations for items in the map using the given Locale. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
getFallbackString
(Object value) Returns the fallback string representation.protected String
Returns the key for the given value.Returns the Locale to use for lookup, guaranteed to be not null.protected String
getLocalizedString
(String key) Returns the localized value for the given key or null if not found.Returns a string representation of the given value.final void
Sets the Locale to use for lookup of localized string representation.
-
Constructor Details
-
LocalizableStringValue
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
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 UIManagerlocale
- the locale to lookup the localized strings, may be null to denote using JComponent.defaultLocale
-
LocalizableStringValue
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 UIManagerprefix
- a common prefix for all string keys in the map, may be null to denote that the keys should be use as are
-
LocalizableStringValue
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 UIManagerprefix
- a common prefix for all string keys in the map, may be null to denote that the keys should be use as arelocale
- the locale to lookup the localized strings, may be null to denote using JComponent.defaultLocale
-
-
Method Details
-
getString
Returns a string representation of the given value.PENDING JW: forgot - why not null return guaranteed?
Implemented to lookup the value's localized string representation, if contained in the lookup map. Returns the fallback if not contained.
- Specified by:
getString
in interfaceStringValue
- Parameters:
value
- the object to present as a string- Returns:
- a string representation of the given value, guaranteed to be not null
-
getKey
Returns the key for the given value. The prefix is prepended to the key if both are available. May be null if not available.- Parameters:
value
- the value to find the key for- Returns:
- the key or null if not available.
-
getFallbackString
Returns the fallback string representation. This method is called when a localized value isn't available be found.This implementation returns toString.
- Parameters:
value
- the object to return a string representation for.- Returns:
- a string representation for the value
-
getLocalizedString
Returns the localized value for the given key or null if not found.This implementation queries the UIManagerExt.
- Parameters:
key
- the key to search a value for- Returns:
- the localized value for the given key or null if not available.
-
setLocale
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
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.
-