com.vaadin.flow.component.spreadsheet.
Class FormulaFormatter
- java.lang.Object
-
- com.vaadin.flow.component.spreadsheet.FormulaFormatter
-
All Implemented Interfaces:
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:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
FormulaFormatter.NumberToken
protected class
FormulaFormatter.SeparatorToken
-
Constructor Summary
Constructors Constructor Description FormulaFormatter()
-
Method Summary
All Methods Modifier and Type Method Description protected char
getCurrentDecimalSeparator(Locale locale)
protected DecimalFormat
getDecimalFormat(Locale locale)
boolean
isFormulaFormat(String value)
protected boolean
isNumberChar(Character current, Locale locale)
boolean
isValidFormulaFormat(String value, Locale locale)
Rudimentary checks if the given string could be a valid formula
String
reFormatFormulaValue(String formulaValue, Locale locale)
Convert from a non-localized format to a localized.
protected List<com.vaadin.flow.component.spreadsheet.FormulaFormatter.FormulaToken>
tokenizeFormula(String formulaValue, Locale from)
protected String
tokensToString(List<com.vaadin.flow.component.spreadsheet.FormulaFormatter.FormulaToken> tokens)
String
unFormatFormulaValue(String formulaValue, Locale locale)
Convert from a localized format to a non-localized.
protected List<com.vaadin.flow.component.spreadsheet.FormulaFormatter.FormulaToken>
unLocalizeTokens(List<com.vaadin.flow.component.spreadsheet.FormulaFormatter.FormulaToken> tokens, Locale locale)
-
-
-
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 convertedlocale
- the locale of the given valueReturns:
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 convertedlocale
- the target localeReturns:
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 localeReturns:
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)
-
getDecimalFormat
protected DecimalFormat getDecimalFormat(Locale locale)
-
getCurrentDecimalSeparator
protected char getCurrentDecimalSeparator(Locale locale)
-
-