APIdia Launch Partner
Top Description Inners Fields Constructors Methods
io.github.spannm.jackcess.util

public Class ColumnFormatter

extends Object
Class Inheritance
Imports
io.github.spannm.jackcess.Column, .PropertyMap, io.github.spannm.jackcess.expr.EvalConfig, .EvalException, io.github.spannm.jackcess.impl.ColEvalContext, .ColumnImpl, io.github.spannm.jackcess.impl.expr.FormatUtil, java.io.IOException, java.util.Map

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's EvalConfig can 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).

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ColumnFormatter.FormatEvalContext

Utility class to provide an EvalContext for the expression evaluation engine format support.

Field Summary

Modifier and TypeField and Description
private final ColumnImpl
private final ColumnFormatter.FormatEvalContext
private FormatUtil.StandaloneFormatter
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the formatted result, always non-null
format
(Object
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 be null
val
)

Formats the given value according to the format currently defined for the underlying Column.

public String
getFormatString()

Returns the currently loaded "Format" property for this formatter, may be null.

public String

Returns:

the formatted result, always non-null
getRowValue
(Object[] rowArray)

Convenience method for retrieving the appropriate Column value from the given row array and formatting it.

public String

Returns:

the formatted result, always non-null
getRowValue
(Map<String, ?> rowMap)

Convenience method for retrieving the appropriate Column value from the given row map and formatting it.

public final void
reload()

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.

public void
setFormatString(String
the new format string. may be null, in which case the "Format" property is removed from the underlying Column
newFmtStr
)

Sets the given format string as the "Format" property for the underlying Column and reloads this formatter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

colback to summary
private final ColumnImpl col
ctxback to summary
private final ColumnFormatter.FormatEvalContext ctx
fmtback to summary
private FormatUtil.StandaloneFormatter fmt
fmtStrback to summary
private String fmtStr

Constructor Detail

ColumnFormatterback to summary
public ColumnFormatter(Column col) throws IOException

Method Detail

formatback to summary
public String format(Object val)

Formats the given value according to the format currently defined for the underlying Column.

Parameters
val:Object

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 be null

Returns:String

the formatted result, always non-null

getFormatStringback to summary
public String getFormatString()

Returns the currently loaded "Format" property for this formatter, may be null.

getRowValueback to summary
public String getRowValue(Object[] rowArray)

Convenience method for retrieving the appropriate Column value from the given row array and formatting it.

Returns:String

the formatted result, always non-null

getRowValueback to summary
public String getRowValue(Map<String, ?> rowMap)

Convenience method for retrieving the appropriate Column value from the given row map and formatting it.

Returns:String

the formatted result, always non-null

reloadback to summary
public final void reload() throws IOException

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.

setFormatStringback to summary
public void setFormatString(String newFmtStr) throws IOException

Sets the given format string as the "Format" property for the underlying Column and reloads this formatter.

Parameters
newFmtStr:String

the new format string. may be null, in which case the "Format" property is removed from the underlying Column

io.github.spannm.jackcess.util back to summary

private final Class ColumnFormatter.FormatEvalContext

extends ColEvalContext
Class Inheritance

Utility class to provide an EvalContext for the expression evaluation engine format support.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
Inherited from io.github.spannm.jackcess.impl.ColEvalContext:
getColtoValuewithErrorContext

Constructor Detail

FormatEvalContextback to summary
private FormatEvalContext(ColumnImpl col)

Method Detail

formatback to summary
public String format(Object val)