Package org.jdesktop.swingx.renderer
Interface StringValue
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
AbstractRenderer
,DefaultListRenderer
,DefaultTableRenderer
,DefaultTreeRenderer
,FormatStringValue
,MappedValue
public interface StringValue extends java.io.Serializable
A simple converter to return a String representation of an object. This class is intended to be the "small coin" to configure/format textual cell content of concrete subclasses ofComponentProvider
.F.i. to show a Contributor cell object as "Busywoman, Herta" implement a custom StringValue and use it in a text rendering provider.
StringValue stringValue = new StringValue() { public String getString(Object value) { if (!(value instanceof Contributor)) return TO_STRING.getString(value); Contributor contributor = (Contributor) value; return contributor.lastName + ", " + contributor.firstName; } }; ComponentProvider provider = new LabelProvider(stringValue); table.setDefaultRenderer(Contributor.class, new DefaultTableRenderer(provider));
PENDING: use a full-fledged Format instead? Would impose a higher burden onto implementors but could be re-used in editors.
-
-
Field Summary
Fields Modifier and Type Field Description static StringValue
EMPTY
Converter returning an empty String always.static StringValue
TO_STRING
Default converter using the toString.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
getString(java.lang.Object value)
Returns a string representation of the given value.
-
-
-
Field Detail
-
TO_STRING
static final StringValue TO_STRING
Default converter using the toString.
-
EMPTY
static final StringValue EMPTY
Converter returning an empty String always.
-
-
Method Detail
-
getString
java.lang.String getString(java.lang.Object value)
Returns a string representation of the given value.PENDING JW: forgot - why not null return guaranteed?
- Parameters:
value
- the object to present as a string- Returns:
- a string representation of the given value, guaranteed to be not null
-
-