Class TabledUserDefinedPredicateFactory
java.lang.Object
org.projog.core.predicate.udp.TabledUserDefinedPredicateFactory
- All Implemented Interfaces:
PredicateFactory, UserDefinedPredicateFactory
public final class TabledUserDefinedPredicateFactory
extends Object
implements UserDefinedPredicateFactory
-
Constructor Summary
ConstructorsConstructorDescriptionTabledUserDefinedPredicateFactory(KnowledgeBase kb, PredicateKey predicateKey) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFirst(ClauseModel clauseModel) Adds a clause to the beginning of the predicate's list of clauses.voidaddLast(ClauseModel clauseModel) Adds a clause to the end of the predicate's list of clauses.voidcompile()getClauseModel(int index) Returns the clause at the specified position in this predicate's list of clauses.org.projog.core.predicate.udp.ImplicationsIteratorReturns an iterator over the clauses in the predicate in proper sequence.getPredicate(Term term) Returns aPredicateto be used in the evaluation of a goal.Returns the key for the predicate this object representsbooleanReturnstrueis this predicate is dynamic.booleanShould instances of this implementation be re-evaluated when backtracking?Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PredicateFactory
isAlwaysCutOnBacktrack, preprocess
-
Constructor Details
-
TabledUserDefinedPredicateFactory
-
-
Method Details
-
addFirst
Description copied from interface:UserDefinedPredicateFactoryAdds a clause to the beginning of the predicate's list of clauses.- Specified by:
addFirstin interfaceUserDefinedPredicateFactory- Parameters:
clauseModel- the clause to add to the beginning of the predicate
-
addLast
Description copied from interface:UserDefinedPredicateFactoryAdds a clause to the end of the predicate's list of clauses.- Specified by:
addLastin interfaceUserDefinedPredicateFactory- Parameters:
clauseModel- the clause to add to the end of the predicate
-
isRetryable
public boolean isRetryable()Description copied from interface:PredicateFactoryShould instances of this implementation be re-evaluated when backtracking?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 ofPredicatethat are designed to possibly havePredicate.evaluate()called on them multiple times for the same individual query this method should returntrue. For instances ofPredicatethat are designed to only be evaluated once per individual query this method should returnfalse.- Specified by:
isRetryablein interfacePredicateFactory- Returns:
trueif an attempt should be made to re-evaluate instances of implementing classes when backtracking,falseotherwise
-
getPredicateKey
Description copied from interface:UserDefinedPredicateFactoryReturns the key for the predicate this object represents- Specified by:
getPredicateKeyin interfaceUserDefinedPredicateFactory- Returns:
- the key for the predicate this object represents
-
getImplications
public org.projog.core.predicate.udp.ImplicationsIterator getImplications()Description copied from interface:UserDefinedPredicateFactoryReturns an iterator over the clauses in the predicate in proper sequence.- Specified by:
getImplicationsin interfaceUserDefinedPredicateFactory- Returns:
- an iterator over the clauses in the predicate in proper sequence.
-
isDynamic
public boolean isDynamic()Description copied from interface:UserDefinedPredicateFactoryReturnstrueis this predicate is dynamic.A "dynamic" predicate is a user defined predicate that can have clauses added or removed after is first defined.
- Specified by:
isDynamicin interfaceUserDefinedPredicateFactory- Returns:
trueis this predicate is dynamic
-
getClauseModel
Description copied from interface:UserDefinedPredicateFactoryReturns the clause at the specified position in this predicate's list of clauses.- Specified by:
getClauseModelin interfaceUserDefinedPredicateFactory- Parameters:
index- index of the clause to return- Returns:
- the clause at the specified position in this predicate's list of clauses or
nullif out of bounds
-
getPredicate
Description copied from interface:PredicateFactoryReturns aPredicateto be used in the evaluation of a goal.- Specified by:
getPredicatein interfacePredicateFactory- Parameters:
term- the term containing the arguments to use in the evaluation of the goal- Returns:
- Predicate to be used in the evaluation of the goal
- See Also:
-
compile
public void compile()- Specified by:
compilein interfaceUserDefinedPredicateFactory
-