Back to index

wims  3.65+svn20090927
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Private Member Functions
SharpTools.Function Class Reference

Function classes used only by Formula to evaluate functions. More...

Inheritance diagram for SharpTools.Function:
Inheritance graph
[legend]

List of all members.

Public Member Functions

abstract Number evaluate (SharpTableModel table, Node node, int row, int col) throws ParserException
 This should be implemented in each function.
abstract String getUsage ()
 Return the usage of the function.
abstract String getDescription ()
 Return the description of the function.
boolean requireParams ()
 Whether this function requires parameters.

Protected Member Functions

boolean isRange (Node param)
Node getFirst (Node param)
void checkParamsExist (Node func) throws ParserException

Static Protected Member Functions

static float getSingleParameter (SharpTableModel table, Node node, int row, int col) throws ParserException
 This gets the first float number of a parameter li st, for functions only accepting a single parameter such as ABS, COS , etc.

Static Private Member Functions

static ParserException
exception new 
ParserException ("#PARAM?")

Detailed Description

Function classes used only by Formula to evaluate functions.

Any function needs to have a function handler that implements the "evaluate" interface of the base class Function.

A function can accept zero, one, or more parameters. Each parameter is a number, a relative/absolute address or an address range (e.g., A1:B3).

Author:
Hua Zhong
Version:
Revision:
1.24

Definition at line 24 of file Function.java.


Member Function Documentation

void SharpTools.Function.checkParamsExist ( Node  func) throws ParserException [inline, protected]

Definition at line 42 of file Function.java.

                                                                      {
       
       if (func.getParams().size()==0){
           throw exception;
       }
    }

Here is the caller graph for this function:

abstract Number SharpTools.Function.evaluate ( SharpTableModel  table,
Node  node,
int  row,
int  col 
) throws ParserException [pure virtual]
abstract String SharpTools.Function.getDescription ( ) [pure virtual]
Node SharpTools.Function.getFirst ( Node  param) [inline, protected]

Definition at line 37 of file Function.java.

                                        {
       return (Node)param.getExp().getFirst();
    }    

Here is the call graph for this function:

Here is the caller graph for this function:

static float SharpTools.Function.getSingleParameter ( SharpTableModel  table,
Node  node,
int  row,
int  col 
) throws ParserException [inline, static, protected]

This gets the first float number of a parameter li st, for functions only accepting a single parameter such as ABS, COS , etc.

Parameters:
tablethe SharpTabelModel
nodethe formula unit
colthe int column coordinate
rowthe int row coordinate
Returns:
the float number

Definition at line 61 of file Function.java.

                              {
       //     Node param = node.getNextParam();
       LinkedList params = node.getParams();

       if (params.size() != 1)
           throw new ParserException("#PARAM?");

       LinkedList exp = ((Node)params.getFirst()).getExp();
       
       return Formula.evaluate(table, exp, row, col).floatValue();

    }

Here is the call graph for this function:

Here is the caller graph for this function:

abstract String SharpTools.Function.getUsage ( ) [pure virtual]
boolean SharpTools.Function.isRange ( Node  param) [inline, protected]

Definition at line 29 of file Function.java.

                                          {
       LinkedList exp = param.getExp();
       return exp.size() == 1 &&
           ((Node)exp.getFirst()).isType(Node.COLON);
           //((Node)param.getExp().getFirst()).isType(Node.COLON);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static ParserException exception new SharpTools.Function.ParserException ( "#PARAM?"  ) [static, final, private]

Here is the caller graph for this function:

Whether this function requires parameters.

By default yes.

See also:
FunctionPI
FunctionE

Reimplemented in SharpTools.FunctionE, and SharpTools.FunctionPI.

Definition at line 136 of file Function.java.

{ return true; }

Here is the caller graph for this function:


The documentation for this class was generated from the following file: