Package org.jdesktop.swingx.sort
Class StringValueRegistry
- java.lang.Object
-
- org.jdesktop.swingx.sort.StringValueRegistry
-
- All Implemented Interfaces:
StringValueProvider
public final class StringValueRegistry extends java.lang.Object implements StringValueProvider
A writable implemenation of StringValueProvider. Typically, this is created and maintained by a collection view and then passed over to interested parties. It is modeled/implemented after the default renderer maintenance in a JTable.PENDING JW: for safety - better not implement but return a provider. We probably don't want readers to frickle around here?.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap<java.lang.Integer,java.lang.Class<?>>
classPerColumn
private static java.util.logging.Logger
LOG
private java.util.Map<java.lang.Class<?>,StringValue>
perClass
private java.util.HashMap<java.lang.Integer,StringValue>
perColumn
-
Constructor Summary
Constructors Constructor Description StringValueRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearColumnStringValues()
Removes all per-column mappings of StringValues.private java.lang.Class<?>
getClass(int row, int column)
Returns the Class of the column.private java.util.Map<java.lang.Integer,java.lang.Class<?>>
getColumnClassMap()
Returns the Map which stores the per-column Class, lazily creates one if null.private java.util.Map<java.lang.Class<?>,StringValue>
getPerClassMap()
Returns the Map which stores the per-class StringValues, lazily creates one if null.private java.util.Map<java.lang.Integer,StringValue>
getPerColumnMap()
Returns the Map which stores the per-column StringValues, lazily creates one if null.StringValue
getStringValue(int row, int column)
Returns a StringValue to use for conversion of the cell content at row and column.StringValue
getStringValue(java.lang.Class<?> clazz)
Returns the StringValue registered for the given class.private StringValue
getStringValueByClass(java.lang.Class<?> clazz)
void
setColumnClass(java.lang.Class<?> clazz, int column)
Sets the column class.void
setColumnClasses(java.util.Map<java.lang.Integer,java.lang.Class<?>> classPerColumn)
void
setStringValue(StringValue sv, int column)
Sets a StringValue to use for the given column.void
setStringValue(StringValue sv, java.lang.Class<?> clazz)
Sets the StringValue to use for the given class.
-
-
-
Field Detail
-
LOG
private static final java.util.logging.Logger LOG
-
perClass
private java.util.Map<java.lang.Class<?>,StringValue> perClass
-
perColumn
private java.util.HashMap<java.lang.Integer,StringValue> perColumn
-
classPerColumn
private java.util.HashMap<java.lang.Integer,java.lang.Class<?>> classPerColumn
-
-
Method Detail
-
getStringValue
public StringValue getStringValue(int row, int column)
Returns a StringValue to use for conversion of the cell content at row and column. The converter is guaranteed to be not null, so implemenations are responsible for a reasonable fall-back value always, f.i. if they have no converters registered of if any or both of the row/column coordinate is "invalid" (f.i. -1)- Specified by:
getStringValue
in interfaceStringValueProvider
- Parameters:
row
- the row of the cell in model coordinatescolumn
- the column of the cell in model coordinates- Returns:
- a StringValue to use for conversion, guaranteed to not null.
-
setStringValue
public void setStringValue(StringValue sv, int column)
Sets a StringValue to use for the given column. If the converter is null, the mapping is removed.- Parameters:
sv
- the StringValue to use for the given column.column
- the column index in model coordinates.
-
clearColumnStringValues
public void clearColumnStringValues()
Removes all per-column mappings of StringValues.
-
setStringValue
public void setStringValue(StringValue sv, java.lang.Class<?> clazz)
Sets the StringValue to use for the given class. If the converter is null, the mapping is removed.- Parameters:
sv
- the StringValue to use for the given column.clazz
- the class
-
getStringValue
public StringValue getStringValue(java.lang.Class<?> clazz)
Returns the StringValue registered for the given class.This is temporarily exposed for testing only - do not use, it will be removed very soon!
- Parameters:
clazz
- the class to find the registered StringValue for- Returns:
- the StringValue registered for the class, or null if not directly registered.
-
setColumnClass
public void setColumnClass(java.lang.Class<?> clazz, int column)
Sets the column class.- Parameters:
clazz
-column
- index in model coordinates
-
setColumnClasses
public void setColumnClasses(java.util.Map<java.lang.Integer,java.lang.Class<?>> classPerColumn)
- Parameters:
classPerColumn
-
-
getStringValueByClass
private StringValue getStringValueByClass(java.lang.Class<?> clazz)
- Parameters:
clazz
-- Returns:
-
getClass
private java.lang.Class<?> getClass(int row, int column)
Returns the Class of the column.- Parameters:
row
-column
-- Returns:
-
getColumnClassMap
private java.util.Map<java.lang.Integer,java.lang.Class<?>> getColumnClassMap()
Returns the Map which stores the per-column Class, lazily creates one if null.- Returns:
- the per-column storage map of Class
-
getPerClassMap
private java.util.Map<java.lang.Class<?>,StringValue> getPerClassMap()
Returns the Map which stores the per-class StringValues, lazily creates one if null.- Returns:
- the per-class storage map of StringValues
-
getPerColumnMap
private java.util.Map<java.lang.Integer,StringValue> getPerColumnMap()
Returns the Map which stores the per-column StringValues, lazily creates one if null.- Returns:
- the per-column storage map of StringValues
-
-