hussam.math.operations
Class MyGroup

java.lang.Object
extended by hussam.math.operations.MyGroup
All Implemented Interfaces:
Operation, OperationGroup, java.io.Serializable, java.lang.Cloneable

public class MyGroup
extends java.lang.Object
implements OperationGroup

This is an implementation for the OperationGroup interface.

Author:
ΝΣΗγ
See Also:
Serialized Form

Constructor Summary
MyGroup()
          Construcs a new OperationGroup with 0 operations.
MyGroup(java.util.List<? extends Operation> ops)
          Construcs an OperationGroup giving a List of Operations.
 
Method Summary
 voidaddOperations(java.util.List<? extends Operation> ops)
           
 MyGroupclone(OperatorSourceImpl s)
          This method clones the operation.
 OperationgetOperation(int i)
          Returns the operation at the specified index.
 java.util.List<? extends Operation>getOperations()
          Returns the list of operations.
 OperationGroupoptimize()
          This optimizes all the arguments in this group.
 doubleresult()
          This implementation returns the Last argument result!
 voidsetOperations(java.util.List<? extends Operation> ops)
           
 java.lang.StringtoString()
          Returns a String describing this OperationGroup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MyGroup

public MyGroup(java.util.List<? extends Operation> ops)
Construcs an OperationGroup giving a List of Operations.

Parameters:
ops - the list of Operations.

MyGroup

public MyGroup()
Construcs a new OperationGroup with 0 operations.

Method Detail

setOperations

public void setOperations(java.util.List<? extends Operation> ops)

addOperations

public void addOperations(java.util.List<? extends Operation> ops)

result

public double result()
              throws MathException
This implementation returns the Last argument result! The Default implementation has Changed since Version 3. Version 2 of thic method used to return the first argument result. There are also other changes: Before returning the result of the last method, it computes the results of all arguments. This feature is added to support the use of Assingment feature in Version 3.
This is group:
 (x=10 , y= 20, z=y+x)
 the result of this operationGroup is 30! 
Notice that the equal sign is an Assignement sign. The Default Equals Sign is '==' MyParser
It is the responsibility of other Operations to read all arguments. For example: Function 

Specified by:
result in interface Operation
Returns:
The result value.
Throws:
MathException - if there is a Math Exception!!

getOperations

public java.util.List<? extends Operation> getOperations()
Description copied from interface: OperationGroup
Returns the list of operations.

Specified by:
getOperations in interface OperationGroup
Returns:
The list of operations.

getOperation

public Operation getOperation(int i)
Description copied from interface: OperationGroup
Returns the operation at the specified index.

Specified by:
getOperation in interface OperationGroup
Parameters:
i - The index of the operation
Returns:
the operation.

toString

public java.lang.String toString()
Returns a String describing this OperationGroup

Overrides:
toString in class java.lang.Object
Returns:
a description

clone

public MyGroup clone(OperatorSourceImpl s)
              throws java.lang.CloneNotSupportedException
Description copied from interface: Operation
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
.

Specified by:
clone in interface Operation
Parameters:
s - 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)

optimize

public OperationGroup optimize()
This optimizes all the arguments in this group.

Specified by:
optimize in interface Operation
Specified by:
optimize in interface OperationGroup
Returns:
an optimized Operation of this operation.