hussam.math.operations
Class OperationProxy

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

public class OperationProxy
extends java.lang.Object
implements Operation

This is a proxy to hide an Operation. The proxy operation takes an operation as argument. You can hide any operation inside this proxy. The implementation is only redirting to the hidden operation.

See Also:
Serialized Form

Constructor Summary
OperationProxy(Operation o)
          Constructs a new Proxy given an operation to hide.
 
Method Summary
 OperationProxyclone(OperatorSourceImpl s)
          This method clones the operation.
 OperationgetOperation()
          Returns the hidden operation.
 Operationoptimize()
          Redircts the optimization to the hidden optimization.
 doubleresult()
          Returns the hidden operation.result().
 java.lang.StringtoString()
          Returns the hidden operation.toString()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OperationProxy

public OperationProxy(Operation o)
Constructs a new Proxy given an operation to hide.

Parameters:
o - The operation to be hidden.
Method Detail

result

public double result()
              throws MathException
Returns the hidden operation.result().

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

toString

public java.lang.String toString()
Returns the hidden operation.toString()

Overrides:
toString in class java.lang.Object
Returns:
the hidden operation.toString();

getOperation

public Operation getOperation()
Returns the hidden operation.

Returns:
The operation hidden.

clone

public OperationProxy 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 Operation optimize()
Redircts the optimization to the hidden optimization. It may return a new ConstantNumber if the hidden operation is a constantnumber.

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