public abstract class AbstractSingleResultPredicate extends Object implements PredicateFactory, KnowledgeBaseConsumer
Provides a skeletal implementation of PredicateFactory
and Predicate
. No attempt to find multiple
solutions will be made as part of backtracking as isRetryable()
always returns false
.
Constructor and Description |
---|
AbstractSingleResultPredicate() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
evaluate() |
protected boolean |
evaluate(Term arg) |
boolean |
evaluate(Term[] args) |
protected boolean |
evaluate(Term arg1,
Term arg2) |
protected boolean |
evaluate(Term arg1,
Term arg2,
Term arg3) |
protected boolean |
evaluate(Term arg1,
Term arg2,
Term arg3,
Term arg4) |
protected ArithmeticOperators |
getArithmeticOperators() |
protected FileHandles |
getFileHandles() |
protected KnowledgeBase |
getKnowledgeBase() |
protected Operands |
getOperands() |
Predicate |
getPredicate(Term[] args)
Returns a
Predicate to be used in the evaluation of a goal. |
protected Predicates |
getPredicates() |
protected ProjogListeners |
getProjogListeners() |
protected SpyPoints |
getSpyPoints() |
protected TermFormatter |
getTermFormatter() |
protected void |
init()
This method is called by
setKnowledgeBase(KnowledgeBase) . |
boolean |
isRetryable()
Should instances of this implementation be re-evaluated when backtracking?
|
void |
setKnowledgeBase(KnowledgeBase knowledgeBase)
Provides a reference to a
KnowledgeBase . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isAlwaysCutOnBacktrack
public final Predicate getPredicate(Term[] args)
PredicateFactory
Predicate
to be used in the evaluation of a goal.getPredicate
in interface PredicateFactory
args
- the arguments to use in the evaluation of the goalPredicate.evaluate()
public final boolean evaluate(Term[] args)
protected boolean evaluate()
protected boolean evaluate(Term arg)
public final boolean isRetryable()
PredicateFactory
Some goals (e.g. X is 1
) are only meant to be evaluated once (the statement is either true or false) while
others (e.g. repeat(3)
) are meant to be evaluated multiple times. For instances of Predicate
that
are designed to possibly have Predicate.evaluate()
called on them multiple times for the same individual
query this method should return true
. For instances of Predicate
that are designed to only be
evaluated once per individual query this method should return false
.
isRetryable
in interface PredicateFactory
true
if an attempt should be made to re-evaluate instances of implementing classes when
backtracking, false
otherwisepublic final void setKnowledgeBase(KnowledgeBase knowledgeBase)
KnowledgeBaseConsumer
KnowledgeBase
.setKnowledgeBase
in interface KnowledgeBaseConsumer
protected void init()
setKnowledgeBase(KnowledgeBase)
.
Can be overridden by subclasses to perform initialisation before any calls to evaluate(Term...)
are made.
As setKnowledgeBase(KnowledgeBase)
will have already been called before this method is invoked,
overridden versions will be able to access the KnowledgeBase
using getKnowledgeBase()
.
protected final KnowledgeBase getKnowledgeBase()
protected final Predicates getPredicates()
protected final ArithmeticOperators getArithmeticOperators()
protected final ProjogListeners getProjogListeners()
protected final Operands getOperands()
protected final TermFormatter getTermFormatter()
protected final SpyPoints getSpyPoints()
protected final FileHandles getFileHandles()
Copyright © 2024. All rights reserved.