org.pentaho.reporting.libraries.formula.util
Class FormulaUtil

java.lang.Object
  extended by org.pentaho.reporting.libraries.formula.util.FormulaUtil

public class FormulaUtil
extends Object

Todo: Document me!

Date: 15.04.2009 Time: 16:23:02

Author:
Thomas Morgner.

Method Summary
static String createCellUITextFromFormula(String formula)
           
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 extractStaticTextFromFormula(String formula)
           
static String extractStaticTextFromFormulaFragment(String formula)
           
static Object[] getReferences(Formula formula)
           
static Object[] getReferences(String formula)
           
static boolean isValidFormulaFragment(String formula)
           
static String quoteReference(String reference)
           
static String quoteString(String text)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

quoteReference

public static String quoteReference(String reference)

quoteString

public static String quoteString(String text)

getReferences

public static Object[] getReferences(String formula)
                              throws ParseException
Throws:
ParseException

getReferences

public static Object[] getReferences(Formula formula)

extractFormula

public static String extractFormula(String formula)

extractStaticTextFromFormula

public static String extractStaticTextFromFormula(String formula)

extractStaticTextFromFormulaFragment

public static String extractStaticTextFromFormulaFragment(String formula)

isValidFormulaFragment

public static boolean isValidFormulaFragment(String formula)

createCellUITextFromFormula

public static String createCellUITextFromFormula(String formula)

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.