cdx.scorebot.scoring.logic
Class Literal

java.lang.Object
  extended by cdx.scorebot.scoring.logic.Literal
All Implemented Interfaces:
LogicCode, LogicCodeEvaluatable, PrimaryExpressionType

public class Literal
extends java.lang.Object
implements LogicCodeEvaluatable, PrimaryExpressionType

holds a literal value

Author:
David Underhill

Constructor Summary
Literal(java.lang.Object value)
          instantiate a Literal value
 
Method Summary
 java.lang.Boolean boolValue()
          gets the value if it is a boolean and returns null otherwise
 java.lang.Double doubleValue()
          gets the value if it is a double (or integer) and returns null otherwise
 Literal evaluateLogic(Context context)
          a literal is an atomic value, so this just returns itself
 LiteralType evaluateTypeOnly(java.util.HashMap<java.lang.String,LiteralType> varTypes, java.util.HashMap<java.lang.String,TestData> testsInfo)
          returns the kind of literal this evaluates to
 LiteralType getType()
          gets the type of this literal
 java.lang.Object getValue()
          gets the value of this literal
 java.lang.Integer intValue()
          gets the value if it is a integer and returns null otherwise
 boolean isBoolean()
          whether or not the literal is a Boolean
 boolean isDouble()
          whether or not the literal is a Boolean
 boolean isInteger()
          whether or not the literal is a Boolean
 boolean isString()
          whether or not the literal is a Boolean
 java.lang.String stringValue()
          gets the value if it is a string and returns null otherwise
 java.lang.String toString()
          gets the string representation of the value stored by this literal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Literal

public Literal(java.lang.Object value)
        throws TypeMismatchException
instantiate a Literal value

Parameters:
value - the value of this literal
Throws:
TypeMismatchException
Method Detail

evaluateLogic

public Literal evaluateLogic(Context context)
                      throws LogicException
a literal is an atomic value, so this just returns itself

Specified by:
evaluateLogic in interface LogicCodeEvaluatable
Parameters:
context - contains the current context of the logic processor
Returns:
this literal value
Throws:
LogicException - thrown if an exception occurs while processing the logic

evaluateTypeOnly

public LiteralType evaluateTypeOnly(java.util.HashMap<java.lang.String,LiteralType> varTypes,
                                    java.util.HashMap<java.lang.String,TestData> testsInfo)
                             throws LogicException
Description copied from interface: LogicCodeEvaluatable
returns the kind of literal this evaluates to

Specified by:
evaluateTypeOnly in interface LogicCodeEvaluatable
Parameters:
varTypes - contains the type of value stored by each variable (variables names are keys)
testsInfo - information about each test item keyed on test item names this logic may hold
Returns:
the LiteralType this evaluates to
Throws:
LogicException - thrown if there is a problem with type which prevents this from being evaluated

getValue

public java.lang.Object getValue()
gets the value of this literal


getType

public LiteralType getType()
gets the type of this literal


isBoolean

public boolean isBoolean()
whether or not the literal is a Boolean


isDouble

public boolean isDouble()
whether or not the literal is a Boolean


isInteger

public boolean isInteger()
whether or not the literal is a Boolean


isString

public boolean isString()
whether or not the literal is a Boolean


boolValue

public java.lang.Boolean boolValue()
gets the value if it is a boolean and returns null otherwise


doubleValue

public java.lang.Double doubleValue()
gets the value if it is a double (or integer) and returns null otherwise


intValue

public java.lang.Integer intValue()
gets the value if it is a integer and returns null otherwise


stringValue

public java.lang.String stringValue()
gets the value if it is a string and returns null otherwise


toString

public java.lang.String toString()
gets the string representation of the value stored by this literal

Overrides:
toString in class java.lang.Object