ai.krr
Class IntegerSymbol

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

public class IntegerSymbol
extends NumericSymbol

This class implements part of the foundations for symbolic programming in Java. An IntegerSymbol consists solely of its integer value, which is actually a Java long.

The order between all NumericSymbols, i.e. IntegerSymbol s and RealNumberSymbols, in defined as the order of their values. Thus, an IntegerSymbol can come before or after a RealNumberSymbol.

Author:
Gerhard Wickler

Constructor Summary
IntegerSymbol(long val)
           This constructor creates a new IntegerSymbol with the given value.
 
Method Summary
 int compareTo(IntegerSymbol numSy)
           This function compares this IntegerSymbol to the given IntegerSymbol.
 int compareTo(NumericSymbol numSy)
           This function compares this IntegerSymbol to the given NumericSymbol.
 double doubleValue()
           This function returns the value of this IntegerSymbol as a Java double.
 int hashCode()
           This function returns the hash code of this Symbol.
 long intValue()
           This function returns the value of this IntegerSymbol as a Java long.
 java.lang.String toString()
           This function returns a printable representation of this IntegerSymbol which is the value (a long) of this NumericSymbol.
 
Methods inherited from class ai.krr.NumericSymbol
compareTo, equals, getClassOrderIndex, isNumericSymbol
 
Methods inherited from class ai.krr.SyntaxAdaptableSymbol
isBooleanSymbol, isNamedSymbol, prettyPrint, read, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntegerSymbol

public IntegerSymbol(long val)

This constructor creates a new IntegerSymbol with the given value.

Parameters:
val - the numeric value of this symbol
Method Detail

intValue

public final long intValue()

This function returns the value of this IntegerSymbol as a Java long.

Specified by:
intValue in class NumericSymbol
Returns:
the numeric value of this IntegerSymbol

doubleValue

public final double doubleValue()

This function returns the value of this IntegerSymbol as a Java double.

Specified by:
doubleValue in class NumericSymbol
Returns:
the numeric value of this IntegerSymbol

compareTo

public int compareTo(NumericSymbol numSy)

This function compares this IntegerSymbol to the given NumericSymbol. Two NumericSymbols are compared by value.

Specified by:
compareTo in class NumericSymbol
Parameters:
numSy - the NumericSymbol to which this IntegerSymbol is compared
Returns:
0 if the two NumericSymbols are identical; -1 if the given Symbol should come after this NumericSymbol; and +1 if the given Symbol should come before this NumericSymbol

compareTo

public int compareTo(IntegerSymbol numSy)

This function compares this IntegerSymbol to the given IntegerSymbol. Two IntegerSymbol are compared by value.

Parameters:
numSy - the IntegerSymbol to which this IntegerSymbol is compared
Returns:
0 if the two NumericSymbols are identical; -1 if the given Symbol should come after this NumericSymbol; and +1 if the given Symbol should come before this NumericSymbol

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 IntegerSymbol which is the value (a long) of this NumericSymbol.

Overrides:
toString in class java.lang.Object
Returns:
a String representation for a long