Class FormulaLocaleNormalizer

java.lang.Object
io.keikai.model.impl.sys.formula.FormulaLocaleNormalizer

public final class FormulaLocaleNormalizer extends Object
Locale-aware translator between Excel's locale-specific formula surface form and the US-canonical form the Rust engine understands.

The translation is intentionally textual: cell refs, sheet names, function names, and string literals are passed through unchanged. Only the function-argument separator and the decimal mark are rewritten, and only when they actually differ from the US defaults.

Since:
7.0.0
  • Method Details

    • needsTranslation

      public static boolean needsTranslation(Locale locale)
      Returns true when locale uses non-US separators for either the decimal mark or the function argument list. When this returns false both translation methods are no-ops.
    • toCanonical

      public static String toCanonical(String formula, Locale locale)
      Translates formula from the locale's surface form (e.g. German MAX(0;D$8-($A11+0,5))) to US-canonical (MAX(0,D$8-($A11+0.5))). Returns the input unchanged when needsTranslation(Locale) is false.

      Characters inside double-quoted string literals and inside structured-reference brackets [...] are preserved verbatim. A , is treated as a decimal point only when it sits between two digits; otherwise it has no canonical role in the locale form (the arg-separator is ;).

    • toLocale

      public static String toLocale(String formula, Locale locale)
      Translates formula from US-canonical to the locale's surface form. Inverse of toCanonical(String, Locale). Returns the input unchanged when no translation is needed.

      Strings and structured-reference brackets are preserved. A . is rewritten to the locale decimal only when it sits between two digits; , is always the arg separator in the US form and is rewritten to the locale's arg separator.