org.fraid.function
Class ComplexFunction

java.lang.Object
  extended by org.fraid.function.ComplexFunction
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
abs, acos, acosh, add, and, asin, asinh, assign, atan, atanh, clear, closeControllers, closeWindow, conj, controlVar, cos, cosec, cosh, cot, debug, debugParser, DefinedFunction, diff, divide, E, elemS, equal, exit, exp, False, GeneratorFunction, GraphicsFunction, greater, greaterorequal, imag, info, integer, isComplex, isFunction, isInf, isNaN, isNextIntEven, isString, lengthS, loadScript, loadSymbols, log, max, maxS, MaxVal, min, minS, MinVal, mul, mulS, multiply, NaN, negate, NegInf, nextInt, nextpow2, not, notequal, or, Pi, playSound, plotOption, pmChart, PosInf, power, predictionMarket, printClassPath, printDef, printDep, printGen, printPlugins, printS, printTree, printWindowFunction, quad, rand, real, rename, rk, rk1, round, saveAsSound, saveS, sec, setGridMark, sign, sin, sinh, sleep, smaller, smallerorequal, sqrt, startS, stepS, string, subtract, sum, sumS, tan, tanh, True, typeOf, xor

public abstract class ComplexFunction
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

The Java interface to the FrAid functions. Every FrAid function is a ComplexFunction.

See Also:
Serialized Form

Field Summary
protected  java.lang.String mName
           
protected  int mNumberOfArguments
          How many arguments the particular function needs.
 
Constructor Summary
ComplexFunction()
          Creates a new ComplexFunction instance.
ComplexFunction(int aNumberOfArguments)
          Creates a new ComplexFunction instance.
 
Method Summary
 java.lang.Object clone()
          Used when a panel is cloned to be saved in a file.
 Complex exec(java.lang.Object... args)
          The scripting interface of the Complex Functions.
 java.lang.String getDependancies()
          On what other definitions this function depends.
 java.lang.String getName()
           
 int getNumberOfArguments()
          How many arguments this function takes.
 java.lang.String getSignature()
          The signature of the function...
abstract  Complex invoke(Complex[] args)
          The actual call to the function.
 void setName(java.lang.String aFunctionName)
           
 void setNumberOfArguments(int aNumberOfArguments)
           
 java.lang.String toString()
          The String representataion (DefinedFunction gives you back the complete definition).
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mNumberOfArguments

protected int mNumberOfArguments
How many arguments the particular function needs. -1 means variable number. Used to form the symbol table key. Functions with 0 arguments you can call without brackets.


mName

protected java.lang.String mName
Constructor Detail

ComplexFunction

public ComplexFunction()
Creates a new ComplexFunction instance.


ComplexFunction

public ComplexFunction(int aNumberOfArguments)
Creates a new ComplexFunction instance. Use when defining a FrAid function (subclassing ComplexFunction) from a scripting environment. In some of them although they let you subclass won't let you override protected members (like getNumberOfArguments). So from their constructor call super( my_functions_number_of_arguments )

Parameters:
aNumberOfArguments - an int value
Method Detail

getNumberOfArguments

public int getNumberOfArguments()
How many arguments this function takes. Used for identification only, the function can actually process diff. number.

Returns:
an int value

setNumberOfArguments

public void setNumberOfArguments(int aNumberOfArguments)

getName

public java.lang.String getName()

setName

public void setName(java.lang.String aFunctionName)

exec

public Complex exec(java.lang.Object... args)
             throws java.lang.Exception
The scripting interface of the Complex Functions. Use from Java or any other language with a Java interface. The argumets can be: Complex( and SimpleNode as a subclass ), Number (and subclasses), String, ComplexFunction and Class ( a class instance of a Java defined FrAid function ).

Returns:
a Complex value
Throws:
java.lang.Exception - if an error occurs

invoke

public abstract Complex invoke(Complex[] args)
                        throws java.lang.Exception
The actual call to the function.

Parameters:
args - the arguments, can be (and usualy are) SimpleNode's
Returns:
a Complex value
Throws:
java.lang.Exception - if an error occurs
See Also:
SimpleNode

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Used when a panel is cloned to be saved in a file. The clone is transient (not included in the symbtable). This ensures the function won't change while we are generating large files.

Overrides:
clone in class java.lang.Object
Returns:
an Object value
Throws:
java.lang.CloneNotSupportedException - if an error occurs

getSignature

public java.lang.String getSignature()
The signature of the function...

Returns:
a String value

toString

public java.lang.String toString()
The String representataion (DefinedFunction gives you back the complete definition).

Overrides:
toString in class java.lang.Object
Returns:
a String value
See Also:
DefinedFunction

getDependancies

public java.lang.String getDependancies()
On what other definitions this function depends. Example: a=5; b='a; //now b depends on a, if I want to use it tomorrow need to save the whole thing.

Returns:
a String value
See Also:
DefinedFunction


Fraid (system and language). (C) 2003-2007 Ivaylo Iliev
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.