jmathlib.core.functions
Class Function

java.lang.Object
  extended by jmathlib.core.interpreter.RootObject
      extended by jmathlib.core.functions.Function
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ErrorCodes, TokenConstants
Direct Known Subclasses:
ExternalFunction, InternalFunction, UserFunction

public abstract class Function
extends RootObject

This is the base class for all functions

See Also:
Serialized Form

Field Summary
protected  long lastModified
          data and time of last modification of this file on disc
protected  java.lang.String name
          The functions name
private  int nargout
          Number of left-hand arguments (e.g.
protected  java.lang.String pathAndFileName
          path and filename where this function is located on the disc
 
Fields inherited from interface jmathlib.core.constants.ErrorCodes
ERR_BRACKET_OPEN, ERR_BRACKET_ORDER, ERR_FUNCTION_NOT_FOUND, ERR_FUNCTION_NOT_IMPLEMENTED, ERR_INSUFFICIENT_PARAMETERS, ERR_INVALID_PARAMETER, ERR_LVALUE_REQUIRED, ERR_MATRIX_SINGULAR, ERR_NOT_SQUARE_MATRIX, ERR_OPNOTSUPPORTED, ERR_TOO_MANY_PARAMETERS, ERR_USER_ERROR, ERR_VARIABLE_NOTDEFINED, OK, OK_FUNCTION_PROCESS
 
Fields inherited from interface jmathlib.core.constants.TokenConstants
ADDSUB_PRIORITY, AND_PRIORITY, ANDAND_PRIORITY, ASSIGN_PRIORITY, BRACKET_PRIORITY, COMPARE_PRIORITY, CONCAT, MATRIX, MULDIV_PRIORITY, OR_PRIORITY, OROR_PRIORITY, PARAMETER, POWER_PRIORITY, RELATION_PRIORITY, SINGLE, ttDelimiter, ttNotSet, ttOperand, ttOperator
 
Constructor Summary
Function()
          Default constructor - Creates a function with a null name
Function(java.lang.String _name)
          Creates a function called _name
 
Method Summary
 void debugLine(java.lang.String s)
          write debug line to std-out and file
 boolean equals(java.lang.Object obj)
          Tests if an object is equal to this function if obj is an instance of Function or Function token then it compares the name of obj to the functions name otherwise it calls the superclasses version
abstract  OperandToken evaluate(Token[] operands, GlobalValues globals)
          Executes the function
 long getLastModified()
          Returns the date of last modification of this function
 java.lang.String getName()
           
protected  int getNArgIn(Token[] operands)
          Returns the number of right-hand arguments of the function (e.g.: a=some_function(a,b,c,d) will return "4"
protected  int getNArgOut()
          Returns the number of left-hand arguments of the function (e.g.)
 int getNoOfLeftHandArguments()
          Returns the number of left-hand arguments of the function (e.g.)
 java.lang.String getPathAndFileName()
          returns the path and filename that belongs to this functions
 void setLastModified(long _lastModified)
          Set the date of last modification of this function
 void setName(java.lang.String _name)
          Sets the name of this function
 void setNoOfLeftHandArguments(int _number)
          Sets the number of left-hand arguments of the function (e.g.)
 void setPathAndFileName(java.lang.String _pathAndFileName)
          sets the path and filename that belongs to this functions
 void throwMathLibException(java.lang.String errorMessage)
          Throws arithmetic exception for external functions
 
Methods inherited from class jmathlib.core.interpreter.RootObject
clone, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The functions name


pathAndFileName

protected java.lang.String pathAndFileName
path and filename where this function is located on the disc


lastModified

protected long lastModified
data and time of last modification of this file on disc


nargout

private int nargout
Number of left-hand arguments (e.g. [a,b,c]=some_functions() )

Constructor Detail

Function

public Function()
Default constructor - Creates a function with a null name


Function

public Function(java.lang.String _name)
Creates a function called _name

Parameters:
_name - = the name of the function
Method Detail

getName

public java.lang.String getName()
Returns:
the name of the function

setPathAndFileName

public void setPathAndFileName(java.lang.String _pathAndFileName)
sets the path and filename that belongs to this functions

Parameters:
_pathAndFileName -

getPathAndFileName

public java.lang.String getPathAndFileName()
returns the path and filename that belongs to this functions

Returns:
path and filename

setLastModified

public void setLastModified(long _lastModified)
Set the date of last modification of this function

Parameters:
_lastModified -

getLastModified

public long getLastModified()
Returns the date of last modification of this function

Returns:
date of last modification

setName

public void setName(java.lang.String _name)
Sets the name of this function

Parameters:
name - = name of this function

getNoOfLeftHandArguments

public int getNoOfLeftHandArguments()
Returns the number of left-hand arguments of the function (e.g.) [a,b,c]=some_function will return "3"

Returns:
the number of left hand arguments

getNArgOut

protected int getNArgOut()
Returns the number of left-hand arguments of the function (e.g.) [a,b,c]=some_function will return "3"

Returns:
the number of left hand arguments

getNArgIn

protected int getNArgIn(Token[] operands)
Returns the number of right-hand arguments of the function (e.g.: a=some_function(a,b,c,d) will return "4"

Returns:
number of right hand arguments. Returns -1 if there are no right hand arguments. Returns also -1 if there if one argument==null

setNoOfLeftHandArguments

public void setNoOfLeftHandArguments(int _number)
Sets the number of left-hand arguments of the function (e.g.) [a,b,c]=some_function will return set a "3"

Parameters:
_number - = the number of left hand arguments

equals

public boolean equals(java.lang.Object obj)
Tests if an object is equal to this function if obj is an instance of Function or Function token then it compares the name of obj to the functions name otherwise it calls the superclasses version

Overrides:
equals in class java.lang.Object
Parameters:
obj - = object to test
Returns:
true if the objects are equal

evaluate

public abstract OperandToken evaluate(Token[] operands,
                                      GlobalValues globals)
Executes the function

Parameters:
operands - - an array of the functions paramaters
globals - TODO
Returns:
the result as an OperandToken

throwMathLibException

public void throwMathLibException(java.lang.String errorMessage)
Throws arithmetic exception for external functions

Parameters:
error - text to display

debugLine

public void debugLine(java.lang.String s)
write debug line to std-out and file

Parameters:
s -

FOOTER

BOTTOM