Back to index

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

ROUND
usage: =ROUND(parameter, num_digits)
Rounds a number to a specified number of digits
example: =ROUND(1.534, 2) returns 1.53 More...

Inheritance diagram for SharpTools.FunctionRound:
Inheritance graph
[legend]
Collaboration diagram for SharpTools.FunctionRound:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Number evaluate (SharpTableModel table, Node node, int row, int col) throws ParserException
 This should be implemented in each function.
String getUsage ()
 Return the usage of the function.
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.

Detailed Description

ROUND
usage: =ROUND(parameter, num_digits)
Rounds a number to a specified number of digits
example: =ROUND(1.534, 2) returns 1.53

Definition at line 715 of file Function.java.


Member Function Documentation

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

Definition at line 42 of file Function.java.

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

Here is the caller graph for this function:

Number SharpTools.FunctionRound.evaluate ( SharpTableModel  table,
Node  node,
int  row,
int  col 
) throws ParserException [inline, virtual]

This should be implemented in each function.

Parameters:
tablethe SharpTabelModel
nodethe function node starting with the funciton name with a chain of parameters
colthe int column coordinate
rowthe int row coordinate
Exceptions:
ParserException

Implements SharpTools.Function.

Definition at line 717 of file Function.java.

                                                                {
       
       return new Float(Math.round
                      (getSingleParameter(table, node, row, col)));
    }

Here is the call graph for this function:

String SharpTools.FunctionRound.getDescription ( ) [inline, virtual]

Return the description of the function.

Implements SharpTools.Function.

Definition at line 728 of file Function.java.

                                   {
       return SharpTools.translation.getProperty("round_desc");
       //return "Returns the nearest integer of a number.";
    }
Node SharpTools.Function.getFirst ( Node  param) [inline, protected, inherited]

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, inherited]

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:

String SharpTools.FunctionRound.getUsage ( ) [inline, virtual]

Return the usage of the function.

Implements SharpTools.Function.

Definition at line 724 of file Function.java.

                             {
       return "ROUND(value)";
    }
boolean SharpTools.Function.isRange ( Node  param) [inline, protected, inherited]

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:

boolean SharpTools.Function.requireParams ( ) [inline, inherited]

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: