jxl.biff.formula
Class StringFormulaParser

java.lang.Object
  |
  +--jxl.biff.formula.StringFormulaParser
All Implemented Interfaces:
Parser

class StringFormulaParser
extends java.lang.Object
implements Parser

Parses a string formula into a parse tree


Field Summary
private  java.util.Stack arguments
          The stack argument used when parsing a function in order to pass multiple arguments back to the calling method
private  ExternalSheet externalSheet
          A handle to the external sheet
private  java.lang.String formula
          The formula string passed to this object
private  NameTable nameTable
          A handle to the name table
private  java.lang.String parsedFormula
          The parsed formula string, as retrieved from the parse tree
private  ParseItem root
          The parse tree
private  WorkbookSettings settings
          The workbook settings
 
Constructor Summary
StringFormulaParser(java.lang.String f, ExternalSheet es, NameTable nt, WorkbookSettings ws)
          Constructor
 
Method Summary
 byte[] getBytes()
          Gets the bytes for the formula
 java.lang.String getFormula()
          Gets the formula as a string.
private  java.util.ArrayList getTokens()
          Gets the list of lexical tokens using the generated lexical analyzer
private  void handleFunction(StringFunction sf, java.util.Iterator i, java.util.Stack stack)
          Handles the case when parsing a string when a token is a function
 void parse()
          Parses the list of tokens
private  ParseItem parseCurrent(java.util.Iterator i)
          Recursively parses the token array.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

formula

private java.lang.String formula
The formula string passed to this object

parsedFormula

private java.lang.String parsedFormula
The parsed formula string, as retrieved from the parse tree

root

private ParseItem root
The parse tree

arguments

private java.util.Stack arguments
The stack argument used when parsing a function in order to pass multiple arguments back to the calling method

settings

private WorkbookSettings settings
The workbook settings

externalSheet

private ExternalSheet externalSheet
A handle to the external sheet

nameTable

private NameTable nameTable
A handle to the name table
Constructor Detail

StringFormulaParser

public StringFormulaParser(java.lang.String f,
                           ExternalSheet es,
                           NameTable nt,
                           WorkbookSettings ws)
Constructor
Parameters:
f -  
ws -  
Method Detail

parse

public void parse()
           throws FormulaException
Parses the list of tokens
Specified by:
parse in interface Parser
Throws:
FormulaException -  

parseCurrent

private ParseItem parseCurrent(java.util.Iterator i)
                        throws FormulaException
Recursively parses the token array. Recursion is used in order to evaluate parentheses and function arguments
Parameters:
i - an iterator of tokens
Returns:
the root node of the current parse stack
Throws:
FormulaException - if an error occurs

getTokens

private java.util.ArrayList getTokens()
                               throws FormulaException
Gets the list of lexical tokens using the generated lexical analyzer
Returns:
the list of tokens
Throws:
FormulaException - if an error occurs

getFormula

public java.lang.String getFormula()
Gets the formula as a string. Uses the parse tree to do this, and does not simply return whatever string was passed in
Specified by:
getFormula in interface Parser
Following copied from interface: jxl.biff.formula.Parser
Returns:
the formula as a string

getBytes

public byte[] getBytes()
Gets the bytes for the formula
Specified by:
getBytes in interface Parser
Returns:
the bytes in RPN

handleFunction

private void handleFunction(StringFunction sf,
                            java.util.Iterator i,
                            java.util.Stack stack)
                     throws FormulaException
Handles the case when parsing a string when a token is a function
Parameters:
sf - the string function
i - the token iterator
stack - the parse tree stack
Throws:
FormulaException - if an error occurs