org.problets.domain.model.expression.node.operator.bitwise
Class Bitwise

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
              extended by org.problets.domain.model.expression.node.operator.bitwise.Bitwise
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BitAnd, BitComplement, BitOr, JURightShift, LeftShift, RightShift, Xor

public class Bitwise
extends Operator

To hold all constants specific to bitwise operators

Author:
Amruth Kumar

Field Summary
static java.lang.String OPERATOR_INAPPLICABLE
          Error message presented when bitwise operator is applied to non-integer operand
static int TOTAL_OPERATORS
           
static int WORD_SIZE
          Number of bits assumed in the bit representation of operands, used for error generation of shift operators
 
Fields inherited from class org.problets.domain.model.expression.node.operator.Operator
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
 
Method Summary
 Value evaluate()
          Evaluates a binary bitwise operator
 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
 void getLocalLearningObjectives(java.util.Vector learnObjVector)
          Overrides Operator.getLocalLearningObjectives().
 java.lang.String getQualifiedLearningObject()
          Method returns the name of the operator, disambiguated enough so that it can be easily credited in the student model.
static boolean isBitwise(java.lang.String expression)
          Returns true if expression contains a bitwise operator, and false otherwise
 
Methods inherited from class org.problets.domain.model.expression.node.operator.Operator
clone, coerceToReal, contentEquals, contentEquals, getArity, getAssociativity, getOperatorType, getPrecedence, getStudentCopy, getSymbol, grade, locateOperator, main, recursiveContentEquals, recursiveSetValue
 
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

TOTAL_OPERATORS

public static final int TOTAL_OPERATORS
See Also:
Constant Field Values

OPERATOR_INAPPLICABLE

public static final java.lang.String OPERATOR_INAPPLICABLE
Error message presented when bitwise operator is applied to non-integer operand

See Also:
Constant Field Values

WORD_SIZE

public static final int WORD_SIZE
Number of bits assumed in the bit representation of operands, used for error generation of shift operators

See Also:
Constant Field Values
Method Detail

getLocalLearningObjectives

public void getLocalLearningObjectives(java.util.Vector learnObjVector)
Overrides Operator.getLocalLearningObjectives(). The answer being correct is a learning objective applicable to all bitwise operators. Not using integer operands is an error that applies to all bitwise operators. This is used by &, |, ^, <<, >>, ~. But, ~ uses its own function and does not call this version.

Overrides:
getLocalLearningObjectives in class Operator

getQualifiedLearningObject

public java.lang.String getQualifiedLearningObject()
Method returns the name of the operator, disambiguated enough so that it can be easily credited in the student model.

Overrides:
getQualifiedLearningObject in class Operator

isBitwise

public static boolean isBitwise(java.lang.String expression)
Returns true if expression contains a bitwise operator, and false otherwise


evaluate

public Value evaluate()
Evaluates a binary bitwise operator

Overrides:
evaluate in class Operator

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 Operator