| ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hussam.math.operations.Function
public abstract class Function
This class is an abstract Operator. You should extend this class to have a special reault method. The result method should use the class's functionality.
A Function uses a list of arguments packaged in anOperationGroup
The Result method should read the arguments stored in thegetOperationGroup()
method.
For Example: You can extend this to have a (factorial) implementation. The result implementation reads the first argument, from the Function#getOperationGroup() method. Then do the job to return the factorial result!
OperatorFactoryDB
, DynamicFunctionFactory
, OperatorFactory
, Serialized FormField Summary |
---|
Fields inherited from interface hussam.math.operations.Operator |
---|
COMMA, FUNCTION, INDEFINITE, LOGICAL, MULTIPLY, NOTHING, PLUS, POWER |
Constructor Summary | |
---|---|
Function(java.lang.String name) Simple constructor. | |
Function(java.lang.String name, OperationGroup g) Simpler constructor. | |
Function(java.lang.String name, OperationGroup g, java.lang.String discription) Construcs a new Function given a name, and an Optional OperationGroup, and a discription |
Method Summary | |
---|---|
protected void | checkReady(int argumentCount) This can be used as a check for arguments. |
Function | clone(OperatorSourceImpl s) This method clones the operation. |
int | compareTo(Operator p) Compares the Function with another operator. |
int | getCurrentArgumentCount() Returns the current number of arguments inside this Function. |
java.lang.String | getDiscription() The Function Description. |
java.lang.String | getName() Returns the name of this Operator. |
Operation | getOperation(int i) Returns the Operation at the specified index. |
OperationGroup | getOperationGroup() Returns the OperationGroup |
int | getType() Returns Operator.FUNCTION |
Operation | optimize() Returns an optimized view of this Function. |
void | setOperationGroup(OperationGroup group) Sets the Operations Group. |
java.lang.String | toString() Returns a String describing the name of the function and the list of arguments. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface hussam.math.operations.Operation |
---|
result |
Constructor Detail |
---|
public Function(java.lang.String name, OperationGroup g, java.lang.String discription)
name
- Name of the Funcitong
- Optional OperationGroup, can be null;discription
- The function description.public Function(java.lang.String name, OperationGroup g)
name
- function name.g
- Optional OperationGroup.Function(String, OperationGroup, String)
public Function(java.lang.String name)
name
- Function name.Method Detail |
---|
public java.lang.String getDiscription()
public int getType()
getType
in interface Operator
Operator.FUNCTION
public void setOperationGroup(OperationGroup group)
group
- The OperationGroup to be inserted into this Function. From which the result method will calculate the result, based on the argument list inside the OperationGroup.public OperationGroup getOperationGroup()
public Operation getOperation(int i)
i
- the Index of this operation. public int getCurrentArgumentCount()
public java.lang.String getName()
Operator
getName
in interface Operator
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(Operator p)
compareTo
in interface java.lang.Comparable<Operator>
p
- The other operator which the method will compare with. protected void checkReady(int argumentCount) throws OperatorArgumentMissingException
OperatorArgumentMissingException
argumentCount
- The number of arguments to test. OperatorArgumentMissingException
- Thrown if the number of arguments contained in this Function is lower than argumentCount.Operand.checkReady()
public Function clone(OperatorSourceImpl s) throws java.lang.CloneNotSupportedException
Operation
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.
clone
in interface Operation
s
- The OperatorSourceImpl. java.lang.CloneNotSupportedException
- If the operation is not clonable.ConstantNumber.clone(hussam.math.operations.dataBase.OperatorSourceImpl)
, Variable.clone(hussam.math.operations.dataBase.OperatorSourceImpl)
public Operation optimize()
ConstantNumber
s Then this method will return a New ConstantNumber reflecting the same result(). For example, Function : Max(Abs(-20), 23) will be optimized to be a new ConstantNumber(23).This works for the assumtion that if the argument list has only
ConstantNumber
s then result of the Function is always constant! Special care should be taken if a Function does not comply to this assumption. That is, override this implemetation when neccesary! optimize
in interface Operation
| ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |