Class BMoneyStringTranslator

All Implemented Interfaces:
ValueTranslator<BMoney,String>

@ValueTranslatorService(modelClass=BMoney.class, viewClass=String.class) public class BMoneyStringTranslator extends FractionNumberStringTranslator<BMoney>
BMoney translator.
Applies to DMoney as well.
Author:
harald
  • Constructor Details

    • BMoneyStringTranslator

      public BMoneyStringTranslator(FxTextComponent component)
      Creates a translator.
      Parameters:
      component - the text component
  • Method Details

    • toViewFunction

      public Function<BMoney,String> toViewFunction()
      Description copied from interface: ValueTranslator
      Function to translate a model value to a view value.
      Returns:
      the function
    • toModelFunction

      public Function<String,BMoney> toModelFunction()
      Description copied from interface: ValueTranslator
      Function to translate a view value to a model value.
      Returns:
      the function
    • getDefaultPattern

      public String getDefaultPattern()
      Description copied from class: NumberStringTranslator
      Gets the default pattern according to the type.
      Specified by:
      getDefaultPattern in class NumberStringTranslator<BMoney>
      Returns:
      the pattern
    • parse

      protected BMoney parse(String str)
      Parses a string to a number.
      On failure, the error and error offset are set in the component.

      If the decimal separator is missing and FxUtilities.isLenientMoneyInput(FxTextComponent) is enabled, it is inserted according to the component's scale. Unlike the other number translators, parsing errors are only set in the component and null is returned.

      Overrides:
      parse in class NumberStringTranslator<BMoney>
      Parameters:
      str - the string
      Returns:
      the money value, null if the string is null or parsing failed