All Packages Class Hierarchy This Package Previous Next Index
Class designer.LogicalOperation
java.lang.Object
|
+----designer.LogicalOperation
- public class LogicalOperation
- extends Object
Class: Logical Operation
Purpose:
This class provides our design problem solver the capability of evaulating
logical expressions. Architecturally, logical expression are super-sets of
arithmetic expressions, as logical expression can contain arithmetic
expressions. This class will be RPN stack-based, with the ability to
accept "Calculation"s as operands. Supported logical operators are >, >=
<, <=, !=, =, && (and), || (or), ^ (xor). The parameters are pushed first,
followed by the logical operation.
For example, the following calls would result in the expression: x <= y
--pushOperand(y);
--pushOperand(x);
--pushOperator("<=");
-
vSaveExecutionStack
- This instance variable will hold the reference to a vector, which
in this case is the execution stack.
-
LogicalOperation(int)
- This is the constructor for the logical operation.
-
append(LogicalOperation)
- Method Name: append
Purpose: This method is used to append two logical operations together.
-
execute()
- Method Name: execute
Purpose: This method will execute this logical operation.
-
executeStack()
- MethodName: executeStack()
Purpose: This method is called after the execution stack has been loaded.
-
getExecutionResult()
- MethodName: getExecutionResult()
Purpose: This method is called after the execution stack has been executed.
-
pushOperand(boolean)
- Method Name: pushOperand
Purpose: This method will push an integer operand onto the
execution stack.
-
pushOperand(Calculation)
- Method Name: pushOperand
Purpose: This method will push a Calculation operand onto the
execution stack.
-
pushOperand(double)
- Method Name: pushOperand
Purpose: This method will push a double operand onto the
execution stack.
-
pushOperand(float)
- Method Name: pushOperand
Purpose: This method will push a float operand onto the
execution stack.
-
pushOperand(int)
- Method Name: pushOperand
Purpose: This method will push an integer operand onto the
execution stack.
-
pushOperand(long)
- Method Name: pushOperand
Purpose: This method will push long integer operand onto the
execution stack.
-
pushOperand(String)
- Method Name: pushOperand
Purpose: This method will push an integer operand onto the
execution stack.
-
pushOperator(String[])
- Method Name: pushOperator
Purpose: This method will receive a String dictating the operator
to push on the stack.
-
removeOperand()
- Method Name: removeOperand
Purpose: This method will remove the top-most operand from the
execution stack.
-
removeOperator()
- Method Name: removeOperator
Purpose: This method will remove the top-most operator from the
execution stack.
-
removeTopMostElement()
- Method Name: removeTopMostElement
Purpose: This method will remove the top-most element, regardless if it is
an operand or operator.
vSaveExecutionStack
protected Vector vSaveExecutionStack
- This instance variable will hold the reference to a vector, which
in this case is the execution stack.
LogicalOperation
public LogicalOperation(int iExecutionStackSize)
- This is the constructor for the logical operation. It simply allocates
all instance data (i.e. the stack) and awaits for something to input.
pushOperand
public void pushOperand(boolean booOperand)
- Method Name: pushOperand
Purpose: This method will push an integer operand onto the
execution stack.
PRE: Nothing.
POST: Stack must not be empty, the last object placed is the one
passed a a parameter. The size of the execution stack must be one more than
it was before the insertion.
pushOperand
public void pushOperand(int intOperand)
- Method Name: pushOperand
Purpose: This method will push an integer operand onto the
execution stack.
PRE: Nothing.
POST: Stack must not be empty, the last object placed is the one
passed a a parameter. The size of the execution stack must be one more than
it was before the insertion.
pushOperand
public void pushOperand(long longOperand)
- Method Name: pushOperand
Purpose: This method will push long integer operand onto the
execution stack.
PRE: Nothing.
POST: Stack must not be empty, the last object placed is the one
passed a a parameter. The size of the stack must be one more than
it was before the insertion.
pushOperand
public void pushOperand(float floatOperand)
- Method Name: pushOperand
Purpose: This method will push a float operand onto the
execution stack.
PRE: Nothing.
POST: Stack must not be empty, the last object placed is the one
passed a a parameter. The size of the stack must be one more than
it was before the insertion.
pushOperand
public void pushOperand(double doubleOperand)
- Method Name: pushOperand
Purpose: This method will push a double operand onto the
execution stack.
PRE: Nothing.
POST: Stack must not be empty, the last object placed is the one
passed a a parameter. The size of the stack must be one more than
it was before the insertion.
pushOperand
public void pushOperand(String stringOperand)
- Method Name: pushOperand
Purpose: This method will push an integer operand onto the
execution stack.
PRE: Valid database variable.
POST: Stack must not be empty, the last object placed is the one
passed a a parameter. The size of the stack must be one more than
it was before the insertion.
pushOperand
public void pushOperand(Calculation calcOperand)
- Method Name: pushOperand
Purpose: This method will push a Calculation operand onto the
execution stack.
PRE: Nothing.
POST: Stack must not be empty, the last object placed is the one
passed a a parameter. The size of the stack must be one more than
it was before the insertion.
pushOperator
public boolean pushOperator(String operatorNameAndParameterTypes[])
- Method Name: pushOperator
Purpose: This method will receive a String dictating the operator
to push on the stack. Operators will be selected from an UI, which
is sort of a trusted source. Operators will be checked for validity and
compliance with supported boolean operators. Supported logical operators
are "<=", "<", ">=", ">", "!=".
PRE: operator must be one of the defined operators.
POST: Stack must not be empty, the last object placed is the one
passed a a parameter. The size of the stack must be one more than
it was before the insertion.
removeOperand
public void removeOperand()
- Method Name: removeOperand
Purpose: This method will remove the top-most operand from the
execution stack.
PRE: The top object in the execution stack must be an operand (of type
PushableOperand.
POST: The size of the execution stack must be one less than it was.
removeOperator
public void removeOperator()
- Method Name: removeOperator
Purpose: This method will remove the top-most operator from the
execution stack.
PRE: The top object in the execution stack must be an operator (of
type String) and a valid operator.
POST: The size of the execution stack must be one less than it was.
removeTopMostElement
public void removeTopMostElement()
- Method Name: removeTopMostElement
Purpose: This method will remove the top-most element, regardless if it is
an operand or operator.
PRE: The execution stack must not be empty.
POST: Nothing
execute
public boolean execute()
- Method Name: execute
Purpose: This method will execute this logical operation. The result
will be on the execution stack, accessible by getExecutionResult().
PRE: Stack is not empty.
POST: Result is the top-most element of the stack. The result is the
only element on the execution stack.
executeStack
public boolean executeStack()
- MethodName: executeStack()
Purpose: This method is called after the execution stack has been loaded.
This execution stack assumes operators/operands have been loaded onto the
execution stack in a RPN format.
PRE: Stack not empty.
POST: Result is the top-most element of the stack. The result is the
only element on the execution stack.
getExecutionResult
public Boolean getExecutionResult()
- MethodName: getExecutionResult()
Purpose: This method is called after the execution stack has been executed.
PRE: Only one element on the execution stack. If the element is not a Number
null is returned.
POST: Execution stack empty
append
public void append(LogicalOperation logicalOperationToAppend)
- Method Name: append
Purpose: This method is used to append two logical operations together. The passed
parameter is appended to the object owning the append call.
PRE: logicalOperationToAppend must not be null.
POST: The two logical operations are appended.
All Packages Class Hierarchy This Package Previous Next Index