org.problets.domain.model.expression.node.operator
Class Operator

java.lang.Object
  extended by org.problets.domain.model.DomainModel
      extended by org.problets.domain.model.expression.node.NodeModel
          extended by org.problets.domain.model.expression.node.operator.Operator
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Arithmetic, Assignment, Bitwise, Comma, Logical, Parenthesis, Pointer, Relational

public class Operator
extends NodeModel
implements java.lang.Cloneable

To hold one operator in the expression tree

Author:
Amruth Kumar

Field Summary
static java.lang.String INCORRECT_OPERAND_COUNT
           
 
Fields inherited from class org.problets.domain.model.DomainModel
BOOLEAN, BREAKPOINT, CHARACTER, DOUBLE_PRECISION_REAL, ERROR_TYPE, EVAL_STATUS, expACTION, expASSIGNMENT, expAUTO_DEALLOCATION, expCALL, expCONDITION, expDECLARATION, expDEREFERENCING, expDYNAMIC_ALLOCATION, expDYNAMIC_ALLOCATION_INITIALIZATION, expDYNAMIC_DEALLOCATION, expELSE_CLAUSE, expERROR, expEXECUTION, expIF_CLAUSE, expINITIALIZATION, expINPUT, expPARAMETER_PASSING, expPRINT, expQUESTIONABLE, expREFERENCING, expRETURN, expRUNTIME_ERROR, expSEMANTIC_ERROR, expSYNTAX_ERROR, expUPDATE, IDENTITY, MAX_OBJECT_IDENTITY, MIN_OBJECT_IDENTITY, QUADRUPLE_PRECISION_REAL, RUNTIME_ERROR, SEMANTIC_ERROR, SIGNED_INTEGER, SIGNED_LONG, SIGNED_SHORT, SINGLE_PRECISION_REAL, SYNTAX_ERROR, UNDEFINED_TYPE, UNSIGNED_INTEGER, UNSIGNED_LONG, UNSIGNED_SHORT, WARNING
 
Constructor Summary
Operator()
           
Operator(java.lang.String inOperatorType, java.lang.String inSymbol, int inPrecedence, java.lang.String inAssociativity, int inArity)
           
 
Method Summary
 java.lang.Object clone()
          Returns a bitwise/shallow copy of this node
 boolean coerceToReal(Value left, Value right)
          Returns true if there is a need to coerce, and false otherwise
 boolean contentEquals(NodeModel rightOp)
          Method overrides NodeModel's contentEquals - it considers the content of this node and its left and right child.
 boolean contentEquals(NodeModel rightOp, int depth)
          This will be called by contentEquals() and recursiveContentEquals() with appropriate values for depth
 Value evaluate()
          Method to detect any errors before subclasses evaluate expressions Not to be used by client.
 void explain(java.util.Vector explanation, java.util.Vector errors)
          Textually explains the evaluation of the tree - as opposed to graphical explanation by the view
 int getArity()
           
 java.lang.String getAssociativity()
           
 void getLocalLearningObjectives(java.util.Vector learnObjVector)
          Method adds all the local learning objectives (except precedence and associativity) to the vector passed as parameter The answer being correct is a learning objective applicable to ALL operators
 java.lang.String getOperatorType()
           
 int getPrecedence()
           
 java.lang.String getQualifiedLearningObject()
          Method serves as the base class for inherited classes
 NodeModel getStudentCopy()
          Method returns a copy of this node with only shareable values, resetting the others - Method used by StudentNodeModel to make a copy of the correct node for the student's answer
 java.lang.String getSymbol()
           
 boolean grade(java.lang.String actualTemplate, java.lang.String studentCode, java.util.Vector explanation)
          Grades the studentCode according to the actualTemplate, returns true if correct, and false otherwise
 int locateOperator(java.lang.String actualTemplate)
           
static void main(java.lang.String[] args)
           
 boolean recursiveContentEquals(NodeModel rightOp)
          Recursively checks the contents of two trees - used by And/Or to compare bailed out right expressions.
 void recursiveSetValue(java.lang.String inValue)
          Overrides NodeModel's function - do not call this function directly, call NodeModel.skip() or NodeModel.shortCircuit() instead
 
Methods inherited from class org.problets.domain.model.expression.node.NodeModel
classifyNodes, getContent, getLeftChild, getNonRecursiveContent, getOrder, getPosition, getRecursiveContent, getRightChild, getSideEffects, getValue, insertInOrder, setLeftChild, setOrder, setPosition, setRightChild, setValue, shortCircuit, skip, subExpToString, toString, valueEquals
 
Methods inherited from class org.problets.domain.model.DomainModel
getId, getIdName, grade
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INCORRECT_OPERAND_COUNT

public static final java.lang.String INCORRECT_OPERAND_COUNT
See Also:
Constant Field Values
Constructor Detail

Operator

public Operator(java.lang.String inOperatorType,
                java.lang.String inSymbol,
                int inPrecedence,
                java.lang.String inAssociativity,
                int inArity)

Operator

public Operator()
Method Detail

clone

public java.lang.Object clone()
Returns a bitwise/shallow copy of this node

Overrides:
clone in class NodeModel

getSymbol

public java.lang.String getSymbol()

getPrecedence

public int getPrecedence()

getAssociativity

public java.lang.String getAssociativity()

getArity

public int getArity()

getOperatorType

public java.lang.String getOperatorType()

getLocalLearningObjectives

public void getLocalLearningObjectives(java.util.Vector learnObjVector)
Method adds all the local learning objectives (except precedence and associativity) to the vector passed as parameter The answer being correct is a learning objective applicable to ALL operators


getQualifiedLearningObject

public java.lang.String getQualifiedLearningObject()
Method serves as the base class for inherited classes


contentEquals

public boolean contentEquals(NodeModel rightOp,
                             int depth)
This will be called by contentEquals() and recursiveContentEquals() with appropriate values for depth

Overrides:
contentEquals in class NodeModel

contentEquals

public boolean contentEquals(NodeModel rightOp)
Method overrides NodeModel's contentEquals - it considers the content of this node and its left and right child. It does NOT recursively check the left and right child, but only their contents.

Overrides:
contentEquals in class NodeModel

recursiveContentEquals

public boolean recursiveContentEquals(NodeModel rightOp)
Recursively checks the contents of two trees - used by And/Or to compare bailed out right expressions. This is not the most efficient since it checks each node twice, but it reuses an existing function.


getStudentCopy

public NodeModel getStudentCopy()
Method returns a copy of this node with only shareable values, resetting the others - Method used by StudentNodeModel to make a copy of the correct node for the student's answer

Overrides:
getStudentCopy in class NodeModel

recursiveSetValue

public void recursiveSetValue(java.lang.String inValue)
Overrides NodeModel's function - do not call this function directly, call NodeModel.skip() or NodeModel.shortCircuit() instead

Overrides:
recursiveSetValue in class NodeModel

grade

public boolean grade(java.lang.String actualTemplate,
                     java.lang.String studentCode,
                     java.util.Vector explanation)
Grades the studentCode according to the actualTemplate, returns true if correct, and false otherwise

Overrides:
grade in class NodeModel

coerceToReal

public boolean coerceToReal(Value left,
                            Value right)
Returns true if there is a need to coerce, and false otherwise


evaluate

public Value evaluate()
Method to detect any errors before subclasses evaluate expressions Not to be used by client. Checks if both operands are valid Inherited by all except assignment and boolean operators

Overrides:
evaluate in class NodeModel

explain

public void explain(java.util.Vector explanation,
                    java.util.Vector errors)
Textually explains the evaluation of the tree - as opposed to graphical explanation by the view

Overrides:
explain in class NodeModel

locateOperator

public int locateOperator(java.lang.String actualTemplate)

main

public static void main(java.lang.String[] args)