org.apache.poi.hssf.model
Class FormulaParser

java.lang.Object
  extended byorg.apache.poi.hssf.model.FormulaParser

public class FormulaParser
extends java.lang.Object

This class parses a formula string into a List of tokens in RPN order. Inspired by Lets Build a Compiler, by Jack Crenshaw BNF for the formula expression is : ::= [ ]* ::= [ ]* ::= | () | | ::= ([expression [, expression]*])

Author:
Avik Sengupta , Andrew C. oliver (acoliver at apache dot org), Eric Ladner (eladner at goldinc dot com), Cameron Riley (criley at ekmail.com), Peter M. Murray (pete at quantrix dot com)

Field Summary
static int FORMULA_TYPE_ARRAY
           
static int FORMULA_TYPE_CELL
           
static int FORMULA_TYPE_CONDFOMRAT
           
static int FORMULA_TYPE_NAMEDRANGE
           
static int FORMULA_TYPE_SHARED
           
 
Constructor Summary
FormulaParser(java.lang.String formula, Workbook book)
          create the parser with the string that is to be parsed later call the parse() method to return ptg list in rpn order then call the getRPNPtg() to retrive the parse results This class is recommended only for single threaded use
 
Method Summary
 Ptg[] getRPNPtg()
          API call to retrive the array of Ptgs created as a result of the parsing
 Ptg[] getRPNPtg(int formulaType)
           
 void parse()
          API call to execute the parsing of the formula
static java.lang.String toFormulaString(Workbook book, java.util.List lptgs)
          Convience method which takes in a list then passes it to the other toFormulaString signature.
static java.lang.String toFormulaString(Workbook book, Ptg[] ptgs)
          Static method to convert an array of Ptgs in RPN order to a human readable string format in infix mode.
 java.lang.String toString()
          toString on the parser instance returns the RPN ordered list of tokens Useful for testing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FORMULA_TYPE_CELL

public static int FORMULA_TYPE_CELL

FORMULA_TYPE_SHARED

public static int FORMULA_TYPE_SHARED

FORMULA_TYPE_ARRAY

public static int FORMULA_TYPE_ARRAY

FORMULA_TYPE_CONDFOMRAT

public static int FORMULA_TYPE_CONDFOMRAT

FORMULA_TYPE_NAMEDRANGE

public static int FORMULA_TYPE_NAMEDRANGE
Constructor Detail

FormulaParser

public FormulaParser(java.lang.String formula,
                     Workbook book)
create the parser with the string that is to be parsed later call the parse() method to return ptg list in rpn order then call the getRPNPtg() to retrive the parse results This class is recommended only for single threaded use

Method Detail

parse

public void parse()
API call to execute the parsing of the formula


getRPNPtg

public Ptg[] getRPNPtg()
API call to retrive the array of Ptgs created as a result of the parsing


getRPNPtg

public Ptg[] getRPNPtg(int formulaType)

toFormulaString

public static java.lang.String toFormulaString(Workbook book,
                                               java.util.List lptgs)
Convience method which takes in a list then passes it to the other toFormulaString signature.

Parameters:
book - workbook for 3D and named references
lptgs - list of Ptg, can be null or empty
Returns:
a human readable String

toFormulaString

public static java.lang.String toFormulaString(Workbook book,
                                               Ptg[] ptgs)
Static method to convert an array of Ptgs in RPN order to a human readable string format in infix mode.

Parameters:
book - workbook for named and 3D references
ptgs - array of Ptg, can be null or empty
Returns:
a human readable String

toString

public java.lang.String toString()
toString on the parser instance returns the RPN ordered list of tokens Useful for testing



Copyright © 2003 Apache Software Foundation.