Package org.jdesktop.swingx.renderer
Class FormatStringValue
- java.lang.Object
-
- org.jdesktop.swingx.renderer.FormatStringValue
-
- All Implemented Interfaces:
java.io.Serializable
,StringValue
public class FormatStringValue extends java.lang.Object implements StringValue
Base type forFormat
-backedStringValue
. Has static defaults for Date and Number which use the locale-dependent defaultFormat
s as returned from xxFormat.getInstance().This class is intended to ease the handling of formatted cell content. F.i. to show a list of
Date
s in the defaultLocale
's FULL version and right align the text:
PENDING: need to update on Locale change? How to detect? When?StringValue stringValue = new FormatStringValue( DateFormat.getInstance(DateFormat.FULL)); list.setCellRenderer( new DefaultListRenderer(stringValue, JLabel.RIGHT);
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static FormatStringValue
DATE_TO_STRING
Default converter forDate
types.protected java.text.Format
format
the format used in creating the String representation.static FormatStringValue
NUMBER_TO_STRING
Default converter forNumber
types.-
Fields inherited from interface org.jdesktop.swingx.renderer.StringValue
EMPTY, TO_STRING
-
-
Constructor Summary
Constructors Constructor Description FormatStringValue()
Instantiates a formatted converter with null format.FormatStringValue(java.text.Format format)
Instantiates a formatted converter with the given Format.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.text.Format
getFormat()
java.lang.String
getString(java.lang.Object value)
Returns a string representation of the given value.
-
-
-
Field Detail
-
DATE_TO_STRING
public static final FormatStringValue DATE_TO_STRING
Default converter forDate
types. Uses the default format as returned fromDateFormat
.
-
NUMBER_TO_STRING
public static final FormatStringValue NUMBER_TO_STRING
Default converter forNumber
types. Uses the default format as returned fromNumberFormat
.
-
format
protected java.text.Format format
the format used in creating the String representation.
-
-
Constructor Detail
-
FormatStringValue
public FormatStringValue()
Instantiates a formatted converter with null format.
-
FormatStringValue
public FormatStringValue(java.text.Format format)
Instantiates a formatted converter with the given Format.- Parameters:
format
- the format to use in creating the String representation.
-
-
Method Detail
-
getFormat
public java.text.Format getFormat()
- Returns:
- the format used in creating the String representation.
-
getString
public java.lang.String getString(java.lang.Object value)
Returns a string representation of the given value.PENDING JW: forgot - why not null return guaranteed?
- 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
-
-