edu.cs.ai.kreator.logic
Class Constant

java.lang.Object
  extended by edu.cs.ai.kreator.logic.Term
      extended by edu.cs.ai.kreator.logic.Constant
All Implemented Interfaces:
Latexable, java.lang.Comparable<Term>

public class Constant
extends Term

This class models a constant, i.e., a member of the universe under discourse.

Author:
Matthias Thimm, Sebastian Loh, Marc Finthammer

Field Summary
static org.apache.log4j.Logger LOG
           
 
Method Summary
 int compareTo(Term other)
           
static Constant create(LanguageFactory languageFactory, java.lang.String name)
          Constructs a constant with the given name and default sort.
static Constant create(LanguageFactory lang, java.lang.String name, Sort sort)
          Constructs a new constant with the given name and sort.
static Constant createOrGet(LanguageFactory lang, java.lang.String name)
          If not already existing, constructs a constant with the given name and the default sort.
static Constant createOrGet(LanguageFactory lang, java.lang.String name, Sort sort)
          Returns an already existing constant or, if necessary, constructs a new constant with the given name and sort.
 boolean equals(java.lang.Object obj)
          If the other object is a Term, then equals returns true if both objects have the same class, same name and sort.
 LanguageFactory getLanguageFactory()
          Returns the LanguageFactory this constant object belongs to.
 java.lang.String getName()
          returns the name (identifier) of this Term
 Sort getSort()
          Returns the sort of this term.
 int hashCode()
           
 boolean isGround()
          Specifies if this term is ground, i.e., if there occurs any variable in this term
 java.lang.String toLatex()
          Returns a Latex grammar conform string to generate variables, rules (conditionals) etc.
 java.lang.String toString()
           
 
Methods inherited from class edu.cs.ai.kreator.logic.Term
getAllSequences
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Method Detail

create

public static Constant create(LanguageFactory lang,
                              java.lang.String name,
                              Sort sort)
                       throws WriteProtectionException
Constructs a new constant with the given name and sort.

Parameters:
name - a string.
sort - a sort
languageFactory - the LanguageFactory the constant will be registered to
Throws:
java.lang.IllegalArgumentException - if a constant with the same name already exists
WriteProtectionException

create

public static Constant create(LanguageFactory languageFactory,
                              java.lang.String name)
                       throws WriteProtectionException
Constructs a constant with the given name and default sort.

Parameters:
name - a string.
languageFactory - the LanguageFactory the constant will be registered to
Throws:
java.lang.IllegalArgumentException - if a constant with the same name already exists
WriteProtectionException

createOrGet

public static Constant createOrGet(LanguageFactory lang,
                                   java.lang.String name,
                                   Sort sort)
                            throws WriteProtectionException
Returns an already existing constant or, if necessary, constructs a new constant with the given name and sort.

Parameters:
name - a string.
sort - a sort
languageFactory - the LanguageFactory the constant will be or is already registered to
Throws:
WriteProtectionException

createOrGet

public static Constant createOrGet(LanguageFactory lang,
                                   java.lang.String name)
                            throws WriteProtectionException
If not already existing, constructs a constant with the given name and the default sort. Otherwise the existing constant is returned.

Parameters:
name - a string.
sort - a sort
languageFactory - the LanguageFactory the constant will be or is already registered to
Throws:
WriteProtectionException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toLatex

public java.lang.String toLatex()
Description copied from interface: Latexable
Returns a Latex grammar conform string to generate variables, rules (conditionals) etc.

Specified by:
toLatex in interface Latexable
Returns:
a Latex grammar conform string.

isGround

public boolean isGround()
Description copied from class: Term
Specifies if this term is ground, i.e., if there occurs any variable in this term

Specified by:
isGround in class Term
Returns:
a boolean; "true" if there is no variable in this term

getName

public java.lang.String getName()
Description copied from class: Term
returns the name (identifier) of this Term

Specified by:
getName in class Term

getSort

public Sort getSort()
Description copied from class: Term
Returns the sort of this term.

Specified by:
getSort in class Term
Returns:
the sort

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Description copied from class: Term
If the other object is a Term, then equals returns true if both objects have the same class, same name and sort.

Specified by:
equals in class Term
Returns:
true, if both objects have the same class, name and sort.

compareTo

public int compareTo(Term other)
Specified by:
compareTo in interface java.lang.Comparable<Term>

getLanguageFactory

public LanguageFactory getLanguageFactory()
Returns the LanguageFactory this constant object belongs to.

Returns:
the lang