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:
  • Constructor Details

    • 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.Integer
      numberFormat - The number number format to use for DataType.Number
      currencyFormat - The number format to use for DataType.Currency
      percentageFormat - The number format to use for DataType.Percentage
      dateFormat - The date format to use for DataType.Date
      dateTimeFormat - The date format to use for DataType.DateTime
      booleanFormat - The boolean format to use for DataType.Boolean
  • Method Details

    • 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 interface IValueFormatter
      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 interface IValueFormatter
      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.