Class FormulaFormatter

  • All Implemented Interfaces:
    Serializable

    public class FormulaFormatter
    extends Object
    implements Serializable
    Converts between a localized formula and a non-localized formula.

    This is needed because internally POI only handles formulas with '.' as the decimal separator, and ',' as the argument separator.

    See Also:
    Serialized Form
    • Constructor Detail

      • FormulaFormatter

        public FormulaFormatter()
    • Method Detail

      • unFormatFormulaValue

        public String unFormatFormulaValue​(String formulaValue,
                                           Locale locale)
        Convert from a localized format to a non-localized.
        Parameters:
        formulaValue - the value that should be converted
        locale - the locale of the given value
        Returns:
        the non-localized formula
      • reFormatFormulaValue

        public String reFormatFormulaValue​(String formulaValue,
                                           Locale locale)
        Convert from a non-localized format to a localized.
        Parameters:
        formulaValue - the value that should be converted
        locale - the target locale
        Returns:
        the localized formula
      • isFormulaFormat

        public boolean isFormulaFormat​(String value)
      • isValidFormulaFormat

        public boolean isValidFormulaFormat​(String value,
                                            Locale locale)
        Rudimentary checks if the given string could be a valid formula
        Parameters:
        value - whole formula as a string, must start with '=' or '+'
        locale - the current locale
        Returns:
        true if the formula could be valid
      • tokensToString

        protected String tokensToString​(List<com.vaadin.flow.component.spreadsheet.FormulaFormatter.FormulaToken> tokens)
      • unLocalizeTokens

        protected List<com.vaadin.flow.component.spreadsheet.FormulaFormatter.FormulaToken> unLocalizeTokens​(List<com.vaadin.flow.component.spreadsheet.FormulaFormatter.FormulaToken> tokens,
                                                                                                             Locale locale)
      • tokenizeFormula

        protected List<com.vaadin.flow.component.spreadsheet.FormulaFormatter.FormulaToken> tokenizeFormula​(String formulaValue,
                                                                                                            Locale from)
      • isNumberChar

        protected boolean isNumberChar​(Character current,
                                       Locale locale)
      • getCurrentDecimalSeparator

        protected char getCurrentDecimalSeparator​(Locale locale)