ai.krr
Class StringSymbol

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

public final class StringSymbol
extends SyntaxAdaptableSymbol

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

As for the order of StringSymbols, it is simply defined of the contained Strings.

Author:
Gerhard Wickler

Constructor Summary
StringSymbol(java.lang.String s)
           This constructor creates a StringSymbol for the given char value.
 
Method Summary
 int compareTo(StringSymbol strSy)
           This function compares this StringSymbol to the given StringSymbol.
 int compareTo(Symbol sy)
           This function compares this StringSymbol to the given Object, which must be a 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 stringValue()
           This function returns the value of this StringSymbol as a Java String.
 java.lang.String toString()
           This function returns a printable representation of this StringSymbol which is simply the contained String itself.
 
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

StringSymbol

public StringSymbol(java.lang.String s)

This constructor creates a StringSymbol for the given char value. The given String should not be null.

Parameters:
s - the String 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 zero.

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 StringSymbol to the given Object, which must be a Symbol. AnonymousSymbols and NamedSymbols are considered to come after StringSymbols in the order defined here. All other types of Symbols are considered to come before StringSymbols.

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

stringValue

public final java.lang.String stringValue()

This function returns the value of this StringSymbol as a Java String.

Returns:
the String value of this StringSymbol

compareTo

public int compareTo(StringSymbol strSy)

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

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

equals

public boolean equals(java.lang.Object obj)

This function tests whether this and the given object are equal. Two StringSymbols 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 StringSymbol which is simply the contained String itself.

Overrides:
toString in class java.lang.Object
Returns:
the String that is the value of this StringSymbol