Class FormulaUtil
- java.lang.Object
-
- org.pentaho.reporting.libraries.formula.util.FormulaUtil
-
public class FormulaUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
createCellUITextFromFormula(String formula)
static String
createCellUITextFromFormula(String formula, FormulaContext context)
static String
createEditorTextFromFormula(String formula, FormulaContext formulaContext)
static String
createFormulaFromUIText(String formula)
Creates a formula fragment from the given UI text.static String
extractFormula(String formula)
static String[]
extractFormulaContext(String formula)
static String
extractStaticTextFromFormula(String formula)
static String
extractStaticTextFromFormulaFragment(String formula)
static String[]
getReferences(String formula)
static String[]
getReferences(Formula formula)
static boolean
isValidFormulaFragment(String formula)
static String
quoteReference(String reference)
static String
quoteString(String text)
-
-
-
Method Detail
-
getReferences
public static String[] getReferences(String formula) throws ParseException
- Throws:
ParseException
-
extractStaticTextFromFormulaFragment
public static String extractStaticTextFromFormulaFragment(String formula)
-
isValidFormulaFragment
public static boolean isValidFormulaFragment(String formula)
-
createCellUITextFromFormula
public static String createCellUITextFromFormula(String formula, FormulaContext context)
-
createEditorTextFromFormula
public static String createEditorTextFromFormula(String formula, FormulaContext formulaContext)
-
createFormulaFromUIText
public static String createFormulaFromUIText(String formula)
Creates a formula fragment from the given UI text. Within the reporting engine, the fragment must be prefixed with a formula-context selector. The input follows the Excel/OpenOffice Calc rules: A leading equals indicates a formula, a leading apostrophe indicates a text. Otherwise, if the input is parsable as number it will be formed into a formula that returns that static number, and everything else will be treated as text. Note that there is no syntax check for formula input - if the user writes garbage after the formula selector, this garbage will still be treated as formula.- Parameters:
formula
- the input from the user.- Returns:
- the normalized formula.
-
-