|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.clients.web.formatter.FormatterFactory
public class FormatterFactory
Factory class for creating formatters for various data types. Some formatters are affected by user settings on the session control. For example, the number of decimals to display by a number formatter or the date format of a date formatter.
Constructor Summary | |
---|---|
FormatterFactory()
|
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FormatterFactory()
Method Detail |
---|
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 user
FormatterSettings.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 user
FormatterSettings.getNumDecimals(SessionControl)
,
FormatterSettings.setNumDecimals(SessionControl, int)
,
NumberFormatter
public static Formatter<Number> getIntFormatter(SessionControl sc)
sc
- The session control of the logged in user
IntegerFormatter
public static Formatter<Number> getLongFormatter(SessionControl sc)
sc
- The session control of the logged in user
IntegerFormatter
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 user
FormatterSettings.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 user
FormatterSettings.getDateTimeFormat(SessionControl)
,
FormatterSettings.setDateTimeFormat(SessionControl, String)
,
DateFormatter
public static Formatter<String> getStringFormatter(SessionControl sc)
sc
- The session control of the logged in user
StringFormatter
public static Formatter<Boolean> getBooleanFormatter(SessionControl sc)
sc
- The session control of the logged in user
BooleanFormatter
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 for
public 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 property
ExtendedPropertyFormatter
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 values
ColorFormatter
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
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |