Spreadsheet Toolkit

corpus.excel
Class Formula

java.lang.Object
  |
  +--corpus.excel.Component
        |
        +--corpus.excel.Formula
All Implemented Interfaces:
java.io.Serializable

public class Formula
extends Component

This class represents a Formula that is part of a cell.

See Also:
FormulaParser, Cell, Serialized Form

Field Summary
static boolean loud
          Dump extra debugging info.
 boolean processed
          Has this cell been processed.
 java.lang.String[] sheetnames
          An array of names for the sheets.
 java.lang.String SHEETNAMES
          A pattern for matching sheetnames.
 
Fields inherited from class corpus.excel.Component
haltOnErrors
 
Constructor Summary
Formula(Cell c, java.lang.String input, java.lang.String[] sheetnames)
           
Formula(int col, int row, java.lang.String input, java.lang.String[] sheetnames)
           
 
Method Summary
 Cell getCell()
          The cell that contains this formula.
 java.util.Vector getCells()
          Finds and returns all the cells referred to in this formula.
 int getComplexity()
          Some guage of the formula complexity.
 java.util.Vector getElements()
          Get all elements (cells, ranges, functions,etc...)
 java.lang.String getFormulaString()
          Gets the String Version of this Formula.
 java.util.Vector getFunctions()
          The functions used in this formula.
 java.util.Vector getRanges()
          The ranges that this formula refers to.
 boolean isCopyEquivalent(Cell c)
          Copy-Equivalence exists, if the formulas are absolutely identical (i.e. the cell contents has been copied from one cell into the other, either by copy and paste, or by retyping the same formula).
 boolean isLogicallyEquivalent(Formula f)
          Logical-Equivalence exists, if the formulas differ only in constant values (literals) and absolute references.
 boolean isSourceEquivalent(Formula f)
          Source-Equivalence exists, if the formulas use (potentially) all the same cells in calculation.
 boolean isStructurallyEquivalent(Formula f)
          Structural-Equivalence exists, if the formulas consist of the same operators in the same order, but the operators may be applied to different arguments.
static void main(java.lang.String[] args)
          Testing of Formula functionallity.
 java.util.Vector parseFormula()
          Turn the formula string into a sequence of excel elements using a recursive descent parser.
 javax.swing.JTree parseTree()
          Creates a JTree to represent the parsed strucutre of the formula.
static javax.swing.tree.DefaultMutableTreeNode parseTree(java.util.Vector elements)
          Returns the parseTree for the given elements.
 java.lang.String parseTreeString()
          First attempt at showing the parsetree strucutre of a formula as a multiline text String.
static void printParseTree(javax.swing.tree.DefaultMutableTreeNode root, java.lang.String indent)
          Dumps the current state of the parse tree to the console.
 void process()
          Use the information given for this formula to parse out the formula components.
 void setSheetNames(java.lang.String[] sheetnames)
          Sheetnames are used to determine cell depth during parsing.
 int sheetDepth(java.lang.String input)
          Given the name of a worksheet, return the depth that the sheet occurs at.
 java.lang.String toHTMLString()
          Converts information about this component into an HTML formatted String.
 java.lang.String toString()
          A string representation of this formula.
static java.util.Vector vectorIndexOfInstance(java.util.Vector elements, java.lang.String class_name)
          Finds the all instances of class_name in elements and returns a Vector to them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sheetnames

public java.lang.String[] sheetnames
An array of names for the sheets.


SHEETNAMES

public java.lang.String SHEETNAMES
A pattern for matching sheetnames.


loud

public static boolean loud
Dump extra debugging info.


processed

public boolean processed
Has this cell been processed.

Constructor Detail

Formula

public Formula(Cell c,
               java.lang.String input,
               java.lang.String[] sheetnames)

Formula

public Formula(int col,
               int row,
               java.lang.String input,
               java.lang.String[] sheetnames)
Method Detail

process

public void process()
             throws java.lang.Exception
Use the information given for this formula to parse out the formula components.

java.lang.Exception

setSheetNames

public void setSheetNames(java.lang.String[] sheetnames)
Sheetnames are used to determine cell depth during parsing.


getCell

public Cell getCell()
The cell that contains this formula.


isCopyEquivalent

public boolean isCopyEquivalent(Cell c)
Copy-Equivalence exists, if the formulas are absolutely identical (i.e. the cell contents has been copied from one cell into the other, either by copy and paste, or by retyping the same formula).

Returns:
True if copy equivalence exists.

isLogicallyEquivalent

public boolean isLogicallyEquivalent(Formula f)
Logical-Equivalence exists, if the formulas differ only in constant values (literals) and absolute references.


isStructurallyEquivalent

public boolean isStructurallyEquivalent(Formula f)
Structural-Equivalence exists, if the formulas consist of the same operators in the same order, but the operators may be applied to different arguments.


isSourceEquivalent

public boolean isSourceEquivalent(Formula f)
Source-Equivalence exists, if the formulas use (potentially) all the same cells in calculation.


getCells

public java.util.Vector getCells()
Finds and returns all the cells referred to in this formula.

Returns:
A Vector of ALL cells referred to in this formula.

getRanges

public java.util.Vector getRanges()
The ranges that this formula refers to.


getFunctions

public java.util.Vector getFunctions()
The functions used in this formula.


getElements

public java.util.Vector getElements()
Get all elements (cells, ranges, functions,etc...)


getComplexity

public int getComplexity()
Some guage of the formula complexity. Currently the length of the formula as a string.


getFormulaString

public java.lang.String getFormulaString()
Gets the String Version of this Formula.

Returns:
This formula as a string.

toString

public java.lang.String toString()
A string representation of this formula.

Specified by:
toString in class Component

toHTMLString

public java.lang.String toHTMLString()
Converts information about this component into an HTML formatted String.

Specified by:
toHTMLString in class Component

parseTree

public javax.swing.JTree parseTree()
Creates a JTree to represent the parsed strucutre of the formula.

Returns:
the parse tree.

printParseTree

public static void printParseTree(javax.swing.tree.DefaultMutableTreeNode root,
                                  java.lang.String indent)
Dumps the current state of the parse tree to the console.

Parameters:
root - Where to start printing from
indent - Text that is appended at each recursion through the tree.

parseTree

public static javax.swing.tree.DefaultMutableTreeNode parseTree(java.util.Vector elements)
Returns the parseTree for the given elements.

Parameters:
elements - The parsed tokens to convert into a parsed tree.
See Also:
parseTree()

vectorIndexOfInstance

public static java.util.Vector vectorIndexOfInstance(java.util.Vector elements,
                                                     java.lang.String class_name)
Finds the all instances of class_name in elements and returns a Vector to them.


parseTreeString

public java.lang.String parseTreeString()
First attempt at showing the parsetree strucutre of a formula as a multiline text String.


parseFormula

public java.util.Vector parseFormula()
                              throws java.lang.Exception
Turn the formula string into a sequence of excel elements using a recursive descent parser.

java.lang.Exception

sheetDepth

public int sheetDepth(java.lang.String input)
Given the name of a worksheet, return the depth that the sheet occurs at.


main

public static void main(java.lang.String[] args)
Testing of Formula functionallity.


Spreadsheet Toolkit

Project Home Page