org.norecess.citkit.tir.expressions
Class BooleanETIR

java.lang.Object
  extended by org.norecess.citkit.tir.expressions.BooleanETIR
All Implemented Interfaces:
DatumTIR, IBooleanETIR, ExpressionTIR, HobbesTIR

public class BooleanETIR
extends java.lang.Object
implements IBooleanETIR

A way to represent boolean values in Hobbes. There are three ways to get a BooleanETIR: use the constant TRUE, use the constant FALSE, or use create(boolean) to return the appropriate constant.

However, since BooleanETIR can have a position, do not use == for an equality test unless you are certain that you're using only the constants.

Author:
Jeremy D. Frens

Field Summary
static BooleanETIR FALSE
          Handy constant for a false value.
static BooleanETIR TRUE
          Handy constant for a true value.
 
Constructor Summary
BooleanETIR(boolean value)
           
BooleanETIR(IPosition position, boolean value)
           
BooleanETIR(IPosition position, java.lang.String value)
           
BooleanETIR(java.lang.String value)
           
 
Method Summary
<A> A
accept(ExpressionTIRVisitor<A> visitor)
          Implements the visitor pattern with ExpressionTIRVisitor.
static BooleanETIR create(boolean bool)
          Factory method to return TRUE or FALSE.
 boolean equals(java.lang.Object obj)
           
 IPosition getPosition()
          The position of the TIR in the source code.
 HobbesType getType()
          Retrieves the type of the expression.
 boolean getValue()
          Returns the actual value for this BooleanETIR.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TRUE

public static final BooleanETIR TRUE
Handy constant for a true value.


FALSE

public static final BooleanETIR FALSE
Handy constant for a false value.

Constructor Detail

BooleanETIR

public BooleanETIR(IPosition position,
                   boolean value)

BooleanETIR

public BooleanETIR(boolean value)

BooleanETIR

public BooleanETIR(IPosition position,
                   java.lang.String value)

BooleanETIR

public BooleanETIR(java.lang.String value)
Method Detail

create

public static BooleanETIR create(boolean bool)
Factory method to return TRUE or FALSE.

Parameters:
bool - the boolean value to convert.
Returns:
the appropriate boolean value for a Hobbes expression.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getValue

public boolean getValue()
Returns the actual value for this BooleanETIR.

Specified by:
getValue in interface IBooleanETIR
Returns:
the actual Boolean value.

accept

public <A> A accept(ExpressionTIRVisitor<A> visitor)
Description copied from interface: ExpressionTIR
Implements the visitor pattern with ExpressionTIRVisitor.

Specified by:
accept in interface ExpressionTIR
Parameters:
visitor - the visitor object.
Returns:
the result of visiting the AST with the visitor.

getType

public HobbesType getType()
Description copied from interface: ExpressionTIR
Retrieves the type of the expression.

Specified by:
getType in interface DatumTIR
Specified by:
getType in interface ExpressionTIR
Returns:
the type of the code.

getPosition

public IPosition getPosition()
Description copied from interface: HobbesTIR
The position of the TIR in the source code.

Specified by:
getPosition in interface HobbesTIR

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object