Class ValueFormatter
- java.lang.Object
-
- com.aquima.interactions.project.impl.ValueFormatter
-
- All Implemented Interfaces:
IValueFormatter
,Serializable
public class ValueFormatter extends Object implements IValueFormatter
Internal class, should not use.This class is responsible for formatting and parsing values of specified DataType objects to their corresponding text and back.
- Since:
- 6.0
- Author:
- F. van der Meer
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ValueFormatter(IValueFormat integerFormat, IValueFormat numberFormat, IValueFormat currencyFormat, IValueFormat percentageFormat, IValueFormat dateFormat, IValueFormat dateTimeFormat, IValueFormat booleanFormat)
Constructs a Value formatter based on the specific formatter classes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
format(IPrimitiveValue valueObject)
This method formats the to a string representation.static IValueFormatter
getSensibleDefault(Locale locale)
A sensible default for when there are no formatting options.IPrimitiveValue
parse(String text, DataType type)
This method parses the text to a IPrimitiveValue of the type specified by the data type argument.
-
-
-
Constructor Detail
-
ValueFormatter
public ValueFormatter(IValueFormat integerFormat, IValueFormat numberFormat, IValueFormat currencyFormat, IValueFormat percentageFormat, IValueFormat dateFormat, IValueFormat dateTimeFormat, IValueFormat booleanFormat)
Constructs a Value formatter based on the specific formatter classes.- Parameters:
integerFormat
- The integer number format to use for DataType.IntegernumberFormat
- The number number format to use for DataType.NumbercurrencyFormat
- The number format to use for DataType.CurrencypercentageFormat
- The number format to use for DataType.PercentagedateFormat
- The date format to use for DataType.DatedateTimeFormat
- The date format to use for DataType.DateTimebooleanFormat
- The boolean format to use for DataType.Boolean
-
-
Method Detail
-
getSensibleDefault
public static final IValueFormatter getSensibleDefault(Locale locale)
A sensible default for when there are no formatting options.- Parameters:
locale
- the localization to use when creating the sensible default.- Returns:
- A sensible default which should always succeed.
-
format
public String format(IPrimitiveValue valueObject)
Description copied from interface:IValueFormatter
This method formats the to a string representation.- Specified by:
format
in interfaceIValueFormatter
- Parameters:
valueObject
- The primitive value whose string representation is requested.- Returns:
- String representation of the primitive value.
-
parse
public IPrimitiveValue parse(String text, DataType type)
Description copied from interface:IValueFormatter
This method parses the text to a IPrimitiveValue of the type specified by the data type argument.- Specified by:
parse
in interfaceIValueFormatter
- Parameters:
text
- The input text which should be parsed. Preferably String. However some primitive object handling is included.type
- The data type to which the string should be converted.- Returns:
- The primitive value for the specified data type and text.
-
-