hussam.math.operations
Interface Operation

All Superinterfaces:
java.lang.Cloneable, java.io.Serializable
All Known Subinterfaces:
OperationGroup, Operator
All Known Implementing Classes:
Constant, ConstantNumber, CustomFunctionFactory.CustomFunction, DynamicFunctionFactory.DynamicFunction, Function, MyGroup, Operand, OperationProxy, OperatorFactoryDB.CommaOperand, Variable

public interface Operation
extends java.lang.Cloneable, java.io.Serializable

This interface is the main interface used for all Values, Numbers, Variables Operands, Functions, and all other operatos. An Operation, which can be viewed as a Value, has a result. You can always extend this interface to add more operations.

Version:
3.0
Author:
Hussam Almulhim حسام الملحم
See Also:
Variable

Method Summary
 Operationclone(OperatorSourceImpl ops)
          This method clones the operation.
 Operationoptimize()
          This method optimizes the operation.
 doubleresult()
          returns the result of the operation.
 

Method Detail

result

double result()
              throws MathException
returns the result of the operation.

Returns:
The result value.
Throws:
MathException - if there is a Math Exception!!

optimize

Operation optimize()
This method optimizes the operation. Optimization can increase compile time and decrease run time execution. This method should generate an operation that generate the same result(). This method is one of the main methods intruduced in Version 3 of the HussamMathParser package. It is also worth to note that this methods' implementation is optional! you can just return
this
.

Returns:
an optimized Operation of this operation.
Since:
Version 3

clone

Operation clone(OperatorSourceImpl ops)
                throws java.lang.CloneNotSupportedException
This method clones the operation. Cloning can be achieved by useing the default clone method since Operations are Clonable since Version 3! However, cloning sometimes needs more than what the clone method offers! Notice that this clone method takes an OperatorSource as a parameter, this method should update this source with any arguments needed such as Variables! It can be seen as an implemetation of the Visitor approach. It is also worth to note that this method's implemetation is optional. You can egnore the implemetation of this method and just return
this
.

Parameters:
ops - The OperatorSourceImpl.
Returns:
Returns the cloned operation.
Throws:
java.lang.CloneNotSupportedException - If the operation is not clonable.
See Also:
ConstantNumber.clone(hussam.math.operations.dataBase.OperatorSourceImpl), Variable.clone(hussam.math.operations.dataBase.OperatorSourceImpl)