ai.krr
Class NumericSymbol

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

public abstract class NumericSymbol
extends SyntaxAdaptableSymbol

This class implements part of the foundations for symbolic programming in Java. A NumericSymbol consists solely of its numeric value.

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

Author:
Gerhard Wickler

Constructor Summary
NumericSymbol()
           
 
Method Summary
abstract  int compareTo(NumericSymbol numSy)
           This function compares this NumericSymbol to the given NumericSymbol.
 int compareTo(Symbol sy)
           This function compares this NumericSymbol to the given Symbol.
abstract  double doubleValue()
           This function returns the value of this NumericSymbol as a Java double.
 boolean equals(java.lang.Object obj)
           This function tests whether this and the given Object are equal.
 int getClassOrderIndex()
           This function returns the index used for ordering Symbols across different classes.
abstract  long intValue()
           This function returns the value of this NumericSymbol as a Java long.
 boolean isNumericSymbol()
           This function tests whether this Symbol is a NumericSymbol.
 
Methods inherited from class ai.krr.SyntaxAdaptableSymbol
isBooleanSymbol, isNamedSymbol, prettyPrint, read, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumericSymbol

public NumericSymbol()
Method Detail

intValue

public abstract long intValue()

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

Returns:
the numeric value of this NumericSymbol

doubleValue

public abstract double doubleValue()

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

Returns:
the numeric value of this NumericSymbol

compareTo

public abstract int compareTo(NumericSymbol numSy)

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

Parameters:
numSy - the NumericSymbol to which this NumericSymbol 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

getClassOrderIndex

public 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

isNumericSymbol

public boolean isNumericSymbol()

This function tests whether this Symbol is a NumericSymbol.

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

compareTo

public int compareTo(Symbol sy)

This function compares this NumericSymbol to the given Symbol. Only BooleanSymbols are considered to come before NumericSymbols in the order defined here. All other types of Symbols are considered to come after NumericSymbols.

Parameters:
sy - the Symbol to which this NumericSymbol is to be 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

equals

public boolean equals(java.lang.Object obj)

This function tests whether this and the given Object are equal. Two NumericSymbols are equal if they contain the same value, as int or double.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the Object this should be compared to
Returns:
true iff they have the same value