jxl.biff.formula
Class FormulaParser

java.lang.Object
  extended byjxl.biff.formula.FormulaParser

public class FormulaParser
extends java.lang.Object

Parses the formula passed in (either as parsed strings or as a string) into a tree of operators and operands


Constructor Summary
FormulaParser(byte[] tokens, Cell rt, ExternalSheet es, WorkbookMethods nt, WorkbookSettings ws)
          Constructor which creates the parse tree out of tokens
FormulaParser(java.lang.String form, ExternalSheet es, WorkbookMethods nt, WorkbookSettings ws)
          Constructor which creates the parse tree out of the string
 
Method Summary
 void adjustRelativeCellReferences(int colAdjust, int rowAdjust)
          Adjusts all the relative cell references in this formula by the amount specified.
 void columnInserted(int sheetIndex, int col, boolean currentSheet)
          Called when a column is inserted on the specified sheet.
 void columnRemoved(int sheetIndex, int col, boolean currentSheet)
          Called when a column is inserted on the specified sheet.
 byte[] getBytes()
          Gets the bytes for the formula.
 java.lang.String getFormula()
          Gets the formula as a string
 void parse()
          Parses the formula into a parse tree
 void rowInserted(int sheetIndex, int row, boolean currentSheet)
          Called when a column is inserted on the specified sheet.
 void rowRemoved(int sheetIndex, int row, boolean currentSheet)
          Called when a column is inserted on the specified sheet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormulaParser

public FormulaParser(byte[] tokens,
                     Cell rt,
                     ExternalSheet es,
                     WorkbookMethods nt,
                     WorkbookSettings ws)
              throws FormulaException
Constructor which creates the parse tree out of tokens

Parameters:
tokens - the list of parsed tokens
rt - the cell containing the formula
es - a handle to the external sheet
nt - a handle to the name table
ws - the workbook settings
Throws:
FormulaException

FormulaParser

public FormulaParser(java.lang.String form,
                     ExternalSheet es,
                     WorkbookMethods nt,
                     WorkbookSettings ws)
Constructor which creates the parse tree out of the string

Parameters:
form - the formula string
es - the external sheet handle
nt - the name table
ws - the workbook settings
Method Detail

adjustRelativeCellReferences

public void adjustRelativeCellReferences(int colAdjust,
                                         int rowAdjust)
Adjusts all the relative cell references in this formula by the amount specified. Used when copying formulas

Parameters:
colAdjust - the amount to add on to each relative cell reference
rowAdjust - the amount to add on to each relative row reference

parse

public void parse()
           throws FormulaException
Parses the formula into a parse tree

Throws:
FormulaException

getFormula

public java.lang.String getFormula()
                            throws FormulaException
Gets the formula as a string

Throws:
FormulaException

getBytes

public byte[] getBytes()
Gets the bytes for the formula. This takes into account any token mapping necessary because of shared formulas

Returns:
the bytes in RPN

columnInserted

public void columnInserted(int sheetIndex,
                           int col,
                           boolean currentSheet)
Called when a column is inserted on the specified sheet. Tells the formula parser to update all of its cell references beyond this column

Parameters:
sheetIndex - the sheet on which the column was inserted
col - the column number which was inserted
currentSheet - TRUE if this formula is on the sheet in which the column was inserted, FALSE otherwise

columnRemoved

public void columnRemoved(int sheetIndex,
                          int col,
                          boolean currentSheet)
Called when a column is inserted on the specified sheet. Tells the formula parser to update all of its cell references beyond this column

Parameters:
sheetIndex - the sheet on which the column was inserted
col - the column number which was inserted
currentSheet - TRUE if this formula is on the sheet in which the column was inserted, FALSE otherwise

rowInserted

public void rowInserted(int sheetIndex,
                        int row,
                        boolean currentSheet)
Called when a column is inserted on the specified sheet. Tells the formula parser to update all of its cell references beyond this column

Parameters:
sheetIndex - the sheet on which the column was inserted
row - the column number which was inserted
currentSheet - TRUE if this formula is on the sheet in which the column was inserted, FALSE otherwise

rowRemoved

public void rowRemoved(int sheetIndex,
                       int row,
                       boolean currentSheet)
Called when a column is inserted on the specified sheet. Tells the formula parser to update all of its cell references beyond this column

Parameters:
sheetIndex - the sheet on which the column was inserted
currentSheet - TRUE if this formula is on the sheet in which the column was inserted, FALSE otherwise