ai.krr
Class CharacterSymbol

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

public class CharacterSymbol
extends SyntaxAdaptableSymbol

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

As for the order of CharacterSymbols, it is simply defined of the contained char values.

Author:
Gerhard Wickler

Constructor Summary
CharacterSymbol(char c)
           This constructor creates a CharacterSymbol for the given char value.
 
Method Summary
 char charValue()
           This function returns the value of this CharacterSymbol as a Java char.
 int compareTo(CharacterSymbol charSy)
           This function compares this CharacterSymbol to the given CharacterSymbol.
 int compareTo(Symbol sy)
           This function compares this CharacterSymbol to the given Symbol.
 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.
 int hashCode()
           This function returns the hash code of this Symbol.
 java.lang.String toString()
           This function returns a printable representation of this CharacterSymbol which is simply the character as a String.
 
Methods inherited from class ai.krr.SyntaxAdaptableSymbol
isBooleanSymbol, isNamedSymbol, isNumericSymbol, prettyPrint, read, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CharacterSymbol

public CharacterSymbol(char c)

This constructor creates a CharacterSymbol for the given char value.

Parameters:
c - the char value of this symbol
Method Detail

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 80.

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

compareTo

public int compareTo(Symbol sy)

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

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

charValue

public final char charValue()

This function returns the value of this CharacterSymbol as a Java char.

Returns:
the char value of this CharacterSymbol

compareTo

public int compareTo(CharacterSymbol charSy)

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

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

equals

public boolean equals(java.lang.Object obj)

This function tests whether this and the given Object are equal. Two CharacterSymbols are equal if the contain the same value.

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

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 CharacterSymbol which is simply the character as a String.

Overrides:
toString in class java.lang.Object
Returns:
a String of length 1 containing the char value