public class FormatterFactory extends Object
Constructor and Description |
---|
FormatterFactory() |
Modifier and Type | Method and Description |
---|---|
static Formatter<?> |
getAnnotationFormatter(SessionControl sc,
Annotation a,
Unit unit)
Get a formatter for nice formatting of annotation values, including units.
|
static Formatter<Boolean> |
getBooleanFormatter(SessionControl sc)
Get the logged in user's formatter for boolean values.
|
static Formatter<Number> |
getColorFormatter(SessionControl sc,
Coloring coloring,
Formatter<Number> valueFormatter)
Get a formatter that adds a color box to the display which is a visual representation
of the value.
|
static Formatter<Date> |
getDateFormatter(SessionControl sc)
Get the logged in user's date formatter.
|
static Formatter<Date> |
getDateTimeFormatter(SessionControl sc)
Get the logged in user's datetime formatter.
|
static Formatter<Number> |
getDoubleFormatter(SessionControl sc)
Get the logged in user's number formatter for double values.
|
static Formatter<?> |
getExtendedPropertyFormatter(SessionControl sc,
ExtendedProperty ep)
Get a formatter for an extended property.
|
static Formatter<?> |
getFormulaFormatter(SessionControl sc,
Formula formula)
Get a formatter that knows how to format results from formulas.
|
static Formatter<Number> |
getIntFormatter(SessionControl sc)
Get the logged in user's formatter for integral numbers.
|
static Formatter<Number> |
getLongFormatter(SessionControl sc)
Get the logged in user's formatter for long numbers.
|
static Formatter<Number> |
getNumberFormatter(SessionControl sc)
Get the logged in user's number formatter for float values.
|
static Formatter<String> |
getStringFormatter(SessionControl sc)
Get the logged in user's formatter for strings.
|
static Formatter<?> |
getTypeFormatter(SessionControl sc,
Type type)
Get a formatter suitable for displaying values of the given type.
|
public static Formatter<Number> getNumberFormatter(SessionControl sc)
formatter.number.decimals
. The default number of decimals is two.sc
- The session control of the logged in userFormatterSettings.getNumDecimals(SessionControl)
,
FormatterSettings.setNumDecimals(SessionControl, int)
,
NumberFormatter
public static Formatter<Number> getDoubleFormatter(SessionControl sc)
formatter.number.decimals
. The default number of decimals is two.sc
- The session control of the logged in userFormatterSettings.getNumDecimals(SessionControl)
,
FormatterSettings.setNumDecimals(SessionControl, int)
,
NumberFormatter
public static Formatter<Number> getIntFormatter(SessionControl sc)
sc
- The session control of the logged in userIntegerFormatter
public static Formatter<Number> getLongFormatter(SessionControl sc)
sc
- The session control of the logged in userIntegerFormatter
public static Formatter<Date> getDateFormatter(SessionControl sc)
formatter.date.formatstring
. The default date format
is yyyy-MM-dd
.sc
- The session control of the logged in userFormatterSettings.getDateFormat(SessionControl)
,
FormatterSettings.setDateFormat(SessionControl, String)
,
DateFormatter
public static Formatter<Date> getDateTimeFormatter(SessionControl sc)
formatter.datetime.formatstring
. The
default format is yyyy-MM-dd HH:nn:ss
.sc
- The session control of the logged in userFormatterSettings.getDateTimeFormat(SessionControl)
,
FormatterSettings.setDateTimeFormat(SessionControl, String)
,
DateFormatter
public static Formatter<String> getStringFormatter(SessionControl sc)
sc
- The session control of the logged in userStringFormatter
public static Formatter<Boolean> getBooleanFormatter(SessionControl sc)
sc
- The session control of the logged in userBooleanFormatter
public static Formatter<?> getTypeFormatter(SessionControl sc, Type type)
FLOAT
or DOUBLE
a getNumberFormatter(SessionControl)
is returned. If type is LONG
or INT
a getIntFormatter(SessionControl)
is returned. If type is STRING
or TEXT
a getStringFormatter(SessionControl)
is returned.
If type is DATE
a getDateFormatter(SessionControl)
is returned.
If type is BOOLEAN
a getBooleanFormatter(SessionControl)
is returned. Otherwise null is returned.sc
- The logged in user's session controltype
- The type to get a formatter forpublic static Formatter<?> getExtendedPropertyFormatter(SessionControl sc, ExtendedProperty ep)
ExtendedProperty.getUrl(Object)
if the property value should be
linked and create a link if needed. The actual value is formatted by
creating a formatter based on the type of the extended property using
the getTypeFormatter(SessionControl, Type)
method.sc
- The logged in user's session controlep
- The extended propertyExtendedPropertyFormatter
public static Formatter<Number> getColorFormatter(SessionControl sc, Coloring coloring, Formatter<Number> valueFormatter)
ColorGenerator
is created based on the Coloring
information. The color generator is used to create the color for a specific value.
The value is formatted by the supplied formatter and is not affected by the color
formatter. If the Coloring.isUsingColors()
returns false no color formatter
is created and the orginal formatter is returned.sc
- The logged in user's session controlcoloring
- The coloring object that keeps information about how
to generate colorsvalueFormatter
- A formatter for the actual valuesColorFormatter
public static Formatter<?> getAnnotationFormatter(SessionControl sc, Annotation a, Unit unit)
getTypeFormatter(SessionControl, Type)
using the value type of the annotation. This formatter is wrapped by
a PrefixSuffixFormatter
if a unit is supplied or the annotation has
a unit.sc
- The logged in user's session controla
- The annotation to get a formatter forunit
- The unit, or null to use the unit from the annotation
(Annotation.getUnit()
.public static Formatter<?> getFormulaFormatter(SessionControl sc, Formula formula)
Formula.getValueType()
) and
getTypeFormatter(SessionControl, Type)
to create the basic formatter.
If the formula is numerical and uses coloring information the formatter is
wrapped in a color formatter getColorFormatter(SessionControl, Coloring, Formatter)
.
If the value type of the formula can't be determined a ToStringFormatter
is used.sc
- The logged in user's session controlformula
- The formula