| ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hussam.math.operations.Operand
public abstract class Operand
An Operand is an Operator that takes at most two Operations as arguments. Operands are like, + - ^ % > <= etc...
For Example: 5 + 8 8, and 5 are ConstantNumbers, + is an operand. Operand o = new PlusOperand(Operator.PLUS, new ConstantNumber(5), new ConstantNumber(8)); System.out.println(o.result());
Operator
, OperatorFactoryDB
, Function
, Serialized FormField Summary |
---|
Fields inherited from interface hussam.math.operations.Operator |
---|
COMMA, FUNCTION, INDEFINITE, LOGICAL, MULTIPLY, NOTHING, PLUS, POWER |
Constructor Summary | |
---|---|
Operand(int type, java.lang.String name) Construcs an Operand by giving it a name, and a power. | |
Operand(int type, java.lang.String name, Operation previous, Operation next) Construcs an Operation Operand by a Power type, and two operations. |
Method Summary | |
---|---|
protected void | checkReady() Tests if this operand has two arguments, a previous argument and a next argument. |
Operand | clone(OperatorSourceImpl s) This method clones the operation. |
int | compareTo(Operator p) Compares this operand with another Operator. |
java.lang.String | getName() Returns the name of this Operator. |
Operation | getNext() returns the next operation. |
Operation | getPrevious() the previous operation. |
int | getType() |
Operation | optimize() Optimizes this operand. |
void | set(Operation previous, Operation next) Sets the previos and next operation. 5 + 8 5 is the previous operation. 8 is the next operation. |
void | setNext(Operation operation) Sets the next operation. 5 + 8 5 is the previous operation. 8 is the next operation. |
void | setPrevious(Operation operation) Sets the previos operation. 5 + 8 5 is the previous operation. 8 is the next operation. |
java.lang.String | toString() returns a description of this operand. |
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 Operand(int type, java.lang.String name, Operation previous, Operation next)
type
- The power of this Operand. for example: Operator.POWER
name
- the name of this operandprevious
- the previous operationnext
- the next operations.public Operand(int type, java.lang.String name)
type
- The power of the operand. for example: Operator.PLUS
name
- the name of the operand.Method Detail |
---|
public int getType()
getType
in interface Operator
public java.lang.String getName()
Operator
getName
in interface Operator
public void setPrevious(Operation operation)
Sets the previos operation. 5 + 8 5 is the previous operation. 8 is the next operation.
operation
- the operation to be set.public void setNext(Operation operation)
Sets the next operation. 5 + 8 5 is the previous operation. 8 is the next operation.
operation
- the operation to be set.public void set(Operation previous, Operation next)
Sets the previos and next operation. 5 + 8 5 is the previous operation. 8 is the next operation.
previous
- the previous operation.next
- the next operation.public Operation getPrevious()
public Operation getNext()
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 Operaotor. protected void checkReady() throws OperatorArgumentMissingException
OperatorArgumentMissingException
- Thrown if this Operand has one argument missing.public Operand 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 or Constant
s, then this will return a new ConstantNumber having the same result of this operand operation. optimize
in interface Operation
Function.optimize()
| ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |