com.f1j.addin
Class Func

java.lang.Object
  |
  +--com.actuate.util.Debug
        |
        +--com.f1j.util.Debug
              |
              +--com.f1j.util.ObjConst
                    |
                    +--com.f1j.util.Obj
                          |
                          +--com.f1j.util.AbstractIndexObj
                                |
                                +--com.f1j.util.IndexObj
                                      |
                                      +--com.f1j.calc.HitIndexObj
                                            |
                                            +--com.f1j.calc.Base
                                                  |
                                                  +--com.f1j.calc.Func
                                                        |
                                                        +--com.f1j.addin.Func

public abstract class Func
extends com.f1j.calc.Func

This is the base class for com.f1j.addin functions.

To add a function, simply instantiate an instance of a class derived from the Func class.


Constructor Summary
protected Func(java.lang.String name, int iMinArgs, int iMaxArgs)
          Allocates a new Func object and adds the function into the e.Spreadsheet calc engine.
 
Method Summary
protected abstract  void evaluate(FuncContext funcContext)
          Override this method to implement an e.Spreadsheet addin function.
 void setDeterminant()
          Indicates that a function is determinant (always returns the same result given the same arguments).
 void setReferenceArgument(int iArgument)
          Indicates that ranges or cells should be passed by reference.
 

Constructor Detail

Func

protected Func(java.lang.String name,
               int iMinArgs,
               int iMaxArgs)
Allocates a new Func object and adds the function into the e.Spreadsheet calc engine. By default, all com.f1j.addin functions are assumed to be non-determinant. This means that formulas referring to these functions are always recalculated, even if the arguments to the function do not change. To change this default behavior, use the setDeterminant method.
Parameters:
name - The name of the addin function.
iMinArgs - The minimum number of arguments for this function.
iMaxArgs - The maximum number of arguments for this function.
See Also:
setDeterminant()
Method Detail

evaluate

protected abstract void evaluate(FuncContext funcContext)
                          throws java.lang.Throwable
Override this method to implement an e.Spreadsheet addin function.

Notes:

This method may be called by multiple threads, and must synchronize access to member variables and other resources. Doing so will have a negative impact on performance. Therefore, it is recommended that addin functions do not access member variables or shared resources.

No changes should be made to any workbook from this method. Workbooks should be treated as read-only.

Parameters:
funcContext - provides information and arguments to the addin function.
Throws:
java.lang.Throwable - #N/A! will be the result of the addin function if any exception is thrown.

setDeterminant

public void setDeterminant()
Indicates that a function is determinant (always returns the same result given the same arguments). By default, all addin functions are assumed to be non-determinant. This means that formulas referring to these functions are always recalculated, even if the arguments to the function do not change. Call this method to override the default behavior. An example of a built in function which is non-determinant is RAND(). This function returns a different result every time it is called. Two examples of functions which are determinant are PI() and ABS(n). PI() always returns the value of PI. ABS(n) always returns the same result for a given value of n.

setReferenceArgument

public void setReferenceArgument(int iArgument)
Indicates that ranges or cells should be passed by reference.

Normally, a range or cell reference will be converted to the value of the cell before the addin function is evaluated. Calling this method will cause the specified argument to be passed as a range or cell reference.

Parameters:
iArgument - the zero-based index number of the argument to pass by reference.
See Also:
Value.isCell(), Value.isRange()