Class ColumnFormatter
- java.lang.Object
-
- com.healthmarketscience.jackcess.util.ColumnFormatter
-
public class ColumnFormatter extends Object
Utility for applying Column formatting to column values for display. This utility loads the "Format" property from the given column and builds an appropriate formatter (essentially leveraging the internals of the expression execution engine's support for the "Format()" function). Since formats leverage the expression evaluation engine, the underlying Database'sEvalConfigcan be used to alter how this utility formats values. Note, formatted values may be suitable for display only (i.e. a formatted value may not be accepted as an input value to a Table add/update method).- Author:
- James Ahlborn
- Usage:
- General: This class is general use.
-
-
Constructor Summary
Constructors Constructor Description ColumnFormatter(Column col)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringformat(Object val)Formats the given value according to the format currently defined for the underlying Column.StringgetFormatString()Returns the currently loaded "Format" property for this formatter, may benull.StringgetRowValue(Object[] rowArray)Convenience method for retrieving the appropriate Column value from the given row array and formatting it.StringgetRowValue(Map<String,?> rowMap)Convenience method for retrieving the appropriate Column value from the given row map and formatting it.voidreload()If the properties for the underlying Column have been modified directly (or the EvalConfig for the underlying Database has been modified), this method may be called to reload the format for the underlying Column.voidsetFormatString(String fmtStr)Sets the given format string as the "Format" property for the underlying Column and reloads this formatter.
-
-
-
Constructor Detail
-
ColumnFormatter
public ColumnFormatter(Column col) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getFormatString
public String getFormatString()
Returns the currently loaded "Format" property for this formatter, may benull.
-
setFormatString
public void setFormatString(String fmtStr) throws IOException
Sets the given format string as the "Format" property for the underlying Column and reloads this formatter.- Parameters:
fmtStr- the new format string. may benull, in which case the "Format" property is removed from the underlying Column- Throws:
IOException
-
format
public String format(Object val)
Formats the given value according to the format currently defined for the underlying Column.- Parameters:
val- a valid input value for the DataType of the underlying Column (i.e. a value which could be passed to a Table add/update method for this Column). may benull- Returns:
- the formatted result, always non-
null
-
getRowValue
public String getRowValue(Object[] rowArray)
Convenience method for retrieving the appropriate Column value from the given row array and formatting it.- Returns:
- the formatted result, always non-
null
-
getRowValue
public String getRowValue(Map<String,?> rowMap)
Convenience method for retrieving the appropriate Column value from the given row map and formatting it.- Returns:
- the formatted result, always non-
null
-
reload
public final void reload() throws IOExceptionIf the properties for the underlying Column have been modified directly (or the EvalConfig for the underlying Database has been modified), this method may be called to reload the format for the underlying Column.- Throws:
IOException
-
-