Package org.projog.core.term
Class Atom
java.lang.Object
org.projog.core.term.Atom
- All Implemented Interfaces:
Term
Represents a specific object or relationship.
Atoms are constant; their values cannot be changed after they are created. Atoms have no arguments.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidReverts this term back to its original state prior to any unifications.Returns a copy of this term.booleangetArgument(int index) Returns the term at the specified position in this term's arguments.getName()Returns the value thisAtomrepresents.intReturns the number of arguments in this term.getTerm()Returns the current instantiated state of this term.getType()ReturnsTermType.ATOM.inthashCode()booleanReturnstrueis this term is immutable.toString()booleanAttempts to unify this term to the specified term.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.projog.core.term.Term
copy, firstArgument, fourthArgument, getBound, secondArgument, thirdArgument
-
Constructor Details
-
Atom
- Parameters:
value- the value thisAtomrepresents
-
-
Method Details
-
getName
Returns the value thisAtomrepresents. -
getNumberOfArguments
public int getNumberOfArguments()Description copied from interface:TermReturns the number of arguments in this term.- Specified by:
getNumberOfArgumentsin interfaceTerm- Returns:
- number of arguments in this term
-
getArgument
Description copied from interface:TermReturns the term at the specified position in this term's arguments.- Specified by:
getArgumentin interfaceTerm- Parameters:
index- index of the argument to return- Returns:
- the term at the specified position in this term's arguments
- Throws:
ArrayIndexOutOfBoundsException- as this implementation ofTermhas no arguments
-
getType
ReturnsTermType.ATOM.- Specified by:
getTypein interfaceTerm- Returns:
TermType.ATOM
-
isImmutable
public boolean isImmutable()Description copied from interface:TermReturnstrueis this term is immutable.A term is considered immutable if its value will never change as a result of executing its
Term.unify(Term)orTerm.backtrack()methods. A term will not be considered immutable if it is aVariableor any of its arguments are not immutable.- Specified by:
isImmutablein interfaceTerm- Returns:
trueis this term is immutable
-
copy
Description copied from interface:Term -
getTerm
Description copied from interface:TermReturns the current instantiated state of this term.Returns a representation of this term with all instantiated
Variables replaced with the terms they are instantiated with. -
unify
Description copied from interface:TermAttempts to unify this term to the specified term.The rules for deciding if two terms are unifiable are as follows:
- An uninstantiated
Variablewill unify with any term. As a result theVariablewill become instantiated to the other term. The instantiaton will be undone whenTerm.backtrack()is next called on theVariable - Non-variable terms will unify with other terms that are of the same
TermTypeand have the same value. The exact meaning of "having the same value" will vary between term types but will include that the two terms being unified have the same number of arguments and that all of their corresponding arguments unify.
- An uninstantiated
-
backtrack
public void backtrack()Description copied from interface:TermReverts this term back to its original state prior to any unifications.Makes all
Variables that this term consists of uninstantiated. -
equals
-
hashCode
public int hashCode() -
toString
-