JTP API Documentation

jtp.fol
Class Symbol

java.lang.Object
  |
  +--jtp.fol.Symbol
All Implemented Interfaces:
Comparable, Serializable

public final class Symbol
extends Object
implements Comparable, Serializable

A constant atomic symbol. This could be a predicate, or an object in the knowledge base. The name of the symbol is in the variable value, inherited from Constant. There should be only one Symbol per name, which is ensured by the pseudo-Constructor function newSymbol.

See Also:
newSymbol(java.lang.String, java.lang.String), Serialized Form

Method Summary
 Object clone()
          returns this object, since the class is immutable.
 int compareTo(Object o)
          compares two Symbols.
 boolean equals(Object o)
          tests if two symbols are equal.
 String getName()
           
 String getPackage()
           
static Symbol getSymbol(String s, String pkg)
          finds a symbol with specified name.in the symbol table.
 int hashCode()
           
static Symbol newSymbol(String s)
           
static Symbol newSymbol(String s, String pkg)
          the right way to create a symbol.
 String toString()
          prints the symbol to string
static Symbol uniqueSymbol(String prefix, String pkg)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getName

public String getName()

getPackage

public String getPackage()

newSymbol

public static Symbol newSymbol(String s,
                               String pkg)
the right way to create a symbol.

Parameters:
s - the name of the new symbol. It should be in lower case.
Returns:
If a symbol with specified name already exists, returns the existing copy. If not, creates and returns a new symbol with specified name.

uniqueSymbol

public static Symbol uniqueSymbol(String prefix,
                                  String pkg)

newSymbol

public static Symbol newSymbol(String s)

getSymbol

public static Symbol getSymbol(String s,
                               String pkg)
finds a symbol with specified name.in the symbol table.

Parameters:
s - the name of the symbol
Returns:
the symbol with specified name if it exists in the symbol table; null otherwise.

toString

public String toString()
prints the symbol to string

Overrides:
toString in class Object
Returns:
the name of the symbol

equals

public boolean equals(Object o)
tests if two symbols are equal. Performs a == test on the name strings; this should work only if both symbols were created in the same symbol table!

Overrides:
equals in class Object
Parameters:
o - the object to match
Returns:
true if the target object is a symbol, and its name (aka value) is the same (physically) string as the value of this symbol.

compareTo

public int compareTo(Object o)
compares two Symbols.

Specified by:
compareTo in interface Comparable
Parameters:
o - the Symbol to compare with.
Returns:
an integer greater than zero if this object is greater than o, a negative if it's less, a zero if they are equal.
Throws:
ClassCastException - if o is not an Symbol

hashCode

public int hashCode()
Overrides:
hashCode in class Object

clone

public Object clone()
returns this object, since the class is immutable.

Overrides:
clone in class Object

JTP API Documentation