hussam.math.operations.extra
Class CustomFunction
java.lang.Object
hussam.math.operations.Function
hussam.math.operations.extra.CustomFunction
- All Implemented Interfaces:
- Operation, Operator, java.lang.Comparable<Operator>
public class CustomFunction
- extends Function
A Custom Function, is a Function that takes an expression to evaluate the arguments.
This class can be extended to support different custom functions.
- Version:
- 2.0
- Author:
- Hussam Al-Mulhim حسام الملحم
| Field Summary |
|---|
protected java.lang.String | expression a String indicating the expression which will be evaulated. |
| Constructor Summary |
|---|
CustomFunction(OperatorSource s, java.lang.String name, java.lang.String expression) Constructing using An operatorSource, the name of the function, the expression used to evalute the arguments. |
CustomFunction(java.lang.String name, java.lang.String expression) This will use the default OperatorSource. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
expression
protected java.lang.String expression
a String indicating the expression which will be evaulated.
CustomFunction
public CustomFunction(OperatorSource s,
java.lang.String name,
java.lang.String expression)Constructing using An operatorSource, the name of the function, the expression used to evalute the arguments.
- Parameters:
s - The Datasource, from which the expression can be evaluated.name - The name of the function.
expression - The expression used.
CustomFunction
public CustomFunction(java.lang.String name,
java.lang.String expression)
throws MathExceptionThis will use the default OperatorSource.
- Throws:
MathException- See Also:
OperatorFactoryDB
execute
protected void execute()
throws MathExceptionEvaluates the argument.
This method is called when the result method is called.
- Throws:
MathException - If the expression has a problem.
getExpression
public java.lang.String getExpression()
Returns the Expression used to evaluate the Arguments
- Returns:
- The expression used.
result
public double result()
throws MathException- Description copied from interface:
Operation returns the result of the operation.
- Returns:
- The result value.
- Throws:
MathException - Throws MathException if there is a Math Exception!!
getVariable
public Variable getVariable(int i)
Returns the variable contained in the expression.
You can set the value of the Variable afterwords!
- Returns:
The Variable at the spicified position.
The Variables are sorted in alphabatical order.!
- Throws:
java.lang.ArrayIndexOutOfBoundsException - If i is not in the variable array!- See Also:
setOperation(int, Operation)
setOperation
public void setOperation(int i,
Operation op)
setReader
protected void setReader(OperationReader reader)
throws MathExceptionSets the Reader to use to read the Expression.
- Parameters:
reader - The reader to be set. - Throws:
MathException - when an exception occured.