|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.deri.iris.builtins.AbstractBuiltin
public abstract class AbstractBuiltin
Serves as skeleton implementation for builtins. If you use this class as superclass, you only have only to implement the evaluate method.
$Id: AbstractBuiltin.java,v 1.11 2007-10-19 07:37:16 poettler_ric Exp $
| Field Summary | |
|---|---|
protected static ITerm |
EMPTY_TERM
Something to save creating an an empty tuple every time we just need 'any' tuple. |
| Constructor Summary | |
|---|---|
protected |
AbstractBuiltin(IPredicate p,
ITerm... t)
Constructs the builtin. |
| Method Summary | |
|---|---|
int |
compareTo(IAtom o)
|
boolean |
equals(Object o)
|
ITuple |
evaluate(ITuple t)
Runs the evaluation. |
protected ITerm |
evaluateTerms(ITerm[] terms,
int[] variableIndexes)
Evaluate the predicate once the terms and variable indexes have been found. |
IPredicate |
getPredicate()
Returns the predicate symbol of the atom. |
ITuple |
getTuple()
Returns the tuple of the atom. |
int |
hashCode()
|
boolean |
isBuiltin()
Returns whether this atom is a builtin one, or not. |
boolean |
isGround()
Checks whether the atom is grounded (tuple contains no variables). |
int |
maxUnknownVariables()
The maximum number of unknown variables allowed such that the predicate can still be evaluated. |
String |
toString()
Returns a short description of the inner atom. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final ITerm EMPTY_TERM
| Constructor Detail |
|---|
protected AbstractBuiltin(IPredicate p,
ITerm... t)
p - the special predicate for this builtint - the terms defining the values and variables for this builtin
NullPointerException - if the perdicate or the terms is null
NullPointerException - if the terms contain null
IllegalArgumentException - if the length of the terms and the arity of the perdicate
doesn't match| Method Detail |
|---|
public IPredicate getPredicate()
IAtomReturns the predicate symbol of the atom.
getPredicate in interface IAtompublic ITuple getTuple()
IAtomReturns the tuple of the atom.
getTuple in interface IAtompublic boolean isGround()
IAtomChecks whether the atom is grounded (tuple contains no variables).
isGround in interface IAtompublic int compareTo(IAtom o)
compareTo in interface Comparable<IAtom>public String toString()
Returns a short description of the inner atom. The format of the returned String is undocumented and subject to change.
An example String could be: EQUALS(A, B)
toString in class Objectpublic int hashCode()
hashCode in class Objectpublic boolean equals(Object o)
equals in class Objectpublic boolean isBuiltin()
IAtom
isBuiltin in interface IAtomtrue if it is builtin, otherwise
false
public ITuple evaluate(ITuple t)
throws EvaluationException
IBuiltinAtomRuns the evaluation.
This method takes as input a tuple for which it should run the evaluation. The tuple must contain the substitutes for the variables of this built-in at the corresponding position. Substitutes where this built-in already has a constant might be ignored.
The returned tuple contains the calculated substitutions for the
remaining variables (after replacing the variables with the passed in
constants) in the built-in in the order their variables
appear in the built-in. If there are no variables left to calculate
the built-in will check the correctness of the terms and return a
tuple containing all constants if it is correct, otherwise
null.
For example if you evaluate
4 + X = 9 you would get back <5>.
The only difference are the binary built-ins: For a binary built-in
if you try to evaluate 3 < 4 you will get back
<3, 4>, but if you try to evaluate 3 < 2
you will get back null.
evaluate in interface IBuiltinAtomt - the substitutes for the variables of the builtin
null if the built-in
isn't evaluable
EvaluationException
protected ITerm evaluateTerms(ITerm[] terms,
int[] variableIndexes)
throws EvaluationException
terms - The array of all terms for this evaluation.variableIndexes - the indexes of the terms which should be
computed (starting at 0)
EvaluationExceptionpublic int maxUnknownVariables()
IBuiltinAtom
maxUnknownVariables in interface IBuiltinAtom
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||