ai.krr
Class BooleanSymbol

java.lang.Object
  extended by ai.krr.SyntaxAdaptableSymbol
      extended by ai.krr.BooleanSymbol
All Implemented Interfaces:
Symbol, inf.compilers.SyntaxAdaptable, java.lang.Comparable<Symbol>

public final class BooleanSymbol
extends SyntaxAdaptableSymbol

This class implements part of the foundations for symbolic programming in Java. There are in fact only two BooleanSymbols, and these are defined in this class: TRUE and FALSE. Thus, there is no need to construct BooleanSymbols ever and no construction method is provided.

As for the order of BooleanSymbols, it is simply defined that FALSE precedes TRUE.

Author:
Gerhard Wickler

Field Summary
static BooleanSymbol FALSE
          the BooleanSymbol for FALSE
static BooleanSymbol TRUE
          the BooleanSymbol for TRUE
 
Method Summary
 boolean booleanValue()
           This function returns the value of this BooleanSymbol as a Java boolean.
protected  java.lang.Object clone()
           This class does not support cloning and an Exception will be thrown if this method is called.
 int compareTo(BooleanSymbol boolSy)
           This function compares this BooleanSymbol to the given BooleanSymbol.
 int compareTo(Symbol sy)
           This function compares this BooleanSymbol to the given Symbol.
 int getClassOrderIndex()
           This function returns the index used for ordering Symbols across different classes.
 int hashCode()
           This function returns the hash code of this Symbol.
 boolean isBooleanSymbol()
           This function tests whether this Symbol is a BooleanSymbol.
static BooleanSymbol not(BooleanSymbol b)
           This function returns the negation of the given BooleanSymbol.
 java.lang.String toString()
           This function returns a printable representation of this BooleanSymbol which is either "TRUE" or "FALSE".
 
Methods inherited from class ai.krr.SyntaxAdaptableSymbol
isNamedSymbol, isNumericSymbol, prettyPrint, read, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FALSE

public static final BooleanSymbol FALSE
the BooleanSymbol for FALSE


TRUE

public static final BooleanSymbol TRUE
the BooleanSymbol for TRUE

Method Detail

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException

This class does not support cloning and an Exception will be thrown if this method is called.

Overrides:
clone in class java.lang.Object
Returns:
nothing
Throws:
java.lang.CloneNotSupportedException - will be thrown

getClassOrderIndex

public final int getClassOrderIndex()

This function returns the index used for ordering Symbols across different classes. This index of this class is defined to be zero.

Returns:
an integer indicating how this type of Symbol is to be ordered with respect to different types of Symbol

isBooleanSymbol

public boolean isBooleanSymbol()

This function tests whether this Symbol is a BooleanSymbol.

Specified by:
isBooleanSymbol in interface Symbol
Overrides:
isBooleanSymbol in class SyntaxAdaptableSymbol
Returns:
always true

compareTo

public int compareTo(Symbol sy)

This function compares this BooleanSymbol to the given Symbol. The order between different kinds of Symbols is arbitrarily defined as (ascending): BooleanSymbol, NumericSymbol, CharacterSymbol, StringSymbol, AnonymousSymbol, NamedSymbol.

Parameters:
sy - the Symbol to which this Symbol is to be compared
Returns:
0 if the two Symbols are identical; -1 if the given Symbol should come after this Symbol; and +1 if the given Symbol should come before this Symbol

booleanValue

public final boolean booleanValue()

This function returns the value of this BooleanSymbol as a Java boolean.

Returns:
the boolean value of this BooleanSymbol

compareTo

public int compareTo(BooleanSymbol boolSy)

This function compares this BooleanSymbol to the given BooleanSymbol. In the order defined here FALSE comes before TRUE.

Parameters:
boolSy - the BooleanSymbol to which this BooleanSymbol is compared
Returns:
0 if the two BooleanSymbols are identical; -1 if the given Symbol should come after this BooleanSymbol; and +1 if the given Symbol should come before this BooleanSymbol

hashCode

public final int hashCode()

This function returns the hash code of this Symbol.

Overrides:
hashCode in class java.lang.Object
Returns:
a positive integer that may be used for hashing

toString

public java.lang.String toString()

This function returns a printable representation of this BooleanSymbol which is either "TRUE" or "FALSE".

Overrides:
toString in class java.lang.Object
Returns:
"TRUE" or "FALSE"

not

public static BooleanSymbol not(BooleanSymbol b)

This function returns the negation of the given BooleanSymbol.

Parameters:
b - the BooleanSymbol to be negated
Returns:
the complementary BooleanSymbol