org.problets.domain.model.expression.node
Class NodeModel

java.lang.Object
  extended by org.problets.domain.model.DomainModel
      extended by org.problets.domain.model.expression.node.NodeModel
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Operand, Operator

public class NodeModel
extends DomainModel
implements java.lang.Cloneable

To represent the nodes in the expression tree

Author:
Amruth Kumar

Field Summary
 
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
NodeModel()
           
 
Method Summary
 void classifyNodes(java.util.Vector operatorVector, java.util.Vector operandVector)
          Does an in-order traversal of the view tree (to preserve left to right order) and adds operators to operatorVector, and leaf operands to operandVector
 java.lang.Object clone()
          Returns a bitwise/shallow copy of this node
 boolean contentEquals(NodeModel right)
          Method returns true if this NodeModel's conntet is the same as the content of the right NodeModel, and false otherwise
 boolean contentEquals(NodeModel rightOp, int depth)
           
 Value evaluate()
           
 void explain(java.util.Vector explanation, java.util.Vector errors)
          Base Method to be overridden by those of Operand and Operator
 java.lang.String getContent()
           
 NodeModel getLeftChild()
           
 java.lang.String getNonRecursiveContent()
          Return just the sub-expression corresponding to this node
 int getOrder()
           
 int getPosition()
           
 java.lang.String getRecursiveContent()
           
 NodeModel getRightChild()
           
 java.util.Vector getSideEffects()
          Returns the side effects for this nodemodel - used only in Assignment right now
 NodeModel getStudentCopy()
          Method returns a copy of this node with only shareable values, i.e., content and position resetting the others, i.e., left, right, value and order - Method used by StudentNodeModel to make a copy of the correct node for the student's answer
 Value getValue()
           
 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
 void insertInOrder(NodeModel obj)
           
 void recursiveSetValue(java.lang.String inValue)
          Do not call this function directly, call NodeModel.skip() or NodeModel.shortCircuit() instead.
 void setLeftChild(NodeModel child)
          Method used by StudentNodeView to recreate student's answer's model
 void setOrder(int inOrder)
          Method used by StudentNodeView to set the order in student's answer's model
 void setPosition(int inPosition)
           
 void setRightChild(NodeModel child)
          Method used by StudentNodeView to recreate student's answer's model
 void setValue(java.lang.String result)
           
 void shortCircuit()
           
 void skip()
           
 java.lang.String subExpToString()
          Prints this subexpression - the operator and its two operands
 java.lang.String toString()
          Returns a string representation of this node
 boolean valueEquals(NodeModel right)
          Method returns true if this NodeModel's value is the same as the value of the right NodeModel, and false otherwise
 
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
 

Constructor Detail

NodeModel

public NodeModel()
Method Detail

clone

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

Overrides:
clone in class DomainModel

getRecursiveContent

public java.lang.String getRecursiveContent()

getNonRecursiveContent

public java.lang.String getNonRecursiveContent()
Return just the sub-expression corresponding to this node


getContent

public java.lang.String getContent()

getValue

public Value getValue()

getPosition

public int getPosition()

getLeftChild

public NodeModel getLeftChild()

getRightChild

public NodeModel getRightChild()

getOrder

public int getOrder()

valueEquals

public boolean valueEquals(NodeModel right)
Method returns true if this NodeModel's value is the same as the value of the right NodeModel, and false otherwise


contentEquals

public boolean contentEquals(NodeModel right)
Method returns true if this NodeModel's conntet is the same as the content of the right NodeModel, and false otherwise


contentEquals

public boolean contentEquals(NodeModel rightOp,
                             int depth)

classifyNodes

public void classifyNodes(java.util.Vector operatorVector,
                          java.util.Vector operandVector)
Does an in-order traversal of the view tree (to preserve left to right order) and adds operators to operatorVector, and leaf operands to operandVector


getSideEffects

public java.util.Vector getSideEffects()
Returns the side effects for this nodemodel - used only in Assignment right now


setPosition

public void setPosition(int inPosition)

insertInOrder

public void insertInOrder(NodeModel obj)

shortCircuit

public void shortCircuit()

skip

public void skip()

recursiveSetValue

public void recursiveSetValue(java.lang.String inValue)
Do not call this function directly, call NodeModel.skip() or NodeModel.shortCircuit() instead. Cannot make it protected since Operator.recursiveSetValue() calls it wrt left and right


setValue

public void setValue(java.lang.String result)

getStudentCopy

public NodeModel getStudentCopy()
Method returns a copy of this node with only shareable values, i.e., content and position resetting the others, i.e., left, right, value and order - Method used by StudentNodeModel to make a copy of the correct node for the student's answer


setLeftChild

public void setLeftChild(NodeModel child)
Method used by StudentNodeView to recreate student's answer's model


setRightChild

public void setRightChild(NodeModel child)
Method used by StudentNodeView to recreate student's answer's model


setOrder

public void setOrder(int inOrder)
Method used by StudentNodeView to set the order in student's answer's model


evaluate

public Value evaluate()

explain

public void explain(java.util.Vector explanation,
                    java.util.Vector errors)
Base Method to be overridden by those of Operand and Operator


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


toString

public java.lang.String toString()
Returns a string representation of this node

Overrides:
toString in class java.lang.Object

subExpToString

public java.lang.String subExpToString()
Prints this subexpression - the operator and its two operands