org.apache.poi.hssf.record.formula
Class FormulaParser
java.lang.Object
|
+--org.apache.poi.hssf.record.formula.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)
Constructor Summary |
FormulaParser(java.lang.String formula)
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
The parse and getPRNPtg are internally synchronized for safety, thus
while it is safe to use in a multithreaded environment, you will get long lock waits. |
Method Summary |
Ptg[] |
getRPNPtg()
API call to retrive the array of Ptgs created as
a result of the parsing |
void |
parse()
API call to execute the parsing of the formula |
static java.lang.String |
toFormulaString(java.util.List lptgs)
Convience method which takes in a list then passes it to the other toFormulaString
signature |
static java.lang.String |
toFormulaString(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 |
FormulaParser
public FormulaParser(java.lang.String formula)
- 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
The parse and getPRNPtg are internally synchronized for safety, thus
while it is safe to use in a multithreaded environment, you will get long lock waits.
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
toFormulaString
public static java.lang.String toFormulaString(java.util.List lptgs)
- Convience method which takes in a list then passes it to the other toFormulaString
signature
toFormulaString
public static java.lang.String toFormulaString(Ptg[] ptgs)
- Static method to convert an array of Ptgs in RPN order
to a human readable string format in infix mode
toString
public java.lang.String toString()
- toString on the parser instance returns the RPN ordered list of tokens
Useful for testing
- Overrides:
toString
in class java.lang.Object
Copyright © 2002 Apache jakarta-poi project. All Rights Reserved.