Class InterpretedUserDefinedPredicate

java.lang.Object
org.projog.core.predicate.udp.InterpretedUserDefinedPredicate
All Implemented Interfaces:
Predicate

public final class InterpretedUserDefinedPredicate extends Object implements Predicate
Represents a user defined predicate.
See Also:
  • Constructor Details

  • Method Details

    • evaluate

      public boolean evaluate()
      Evaluates a user defined predicate.

      The process for evaluating a user defined predicate is as follows:

      • Iterates through every clause of the user defined predicate.
      • For each clause it attempts to unify the arguments in its head (consequent) with the arguments in the query ( queryArgs).
      • If the head of the clause can be unified with the query then an attempt is made to evaluate the body (antecedent) of the clause.
      • If the body of the clause is successfully evaluated then true is returned.
      • If the body of the clause is not successfully evaluated then the arguments in the query are backtracked.
      • When there are no more clauses left to check then false is returned.
      Once evaluate() has returned true subsequent invocations of evaluate() will attempt to re-evaluate the antecedent of the previously successfully evaluated clause. If the body of the clause is successfully re-evaluated then true is returned. If the body of the clause is not successfully re-evaluated then the arguments in the query are backtracked and the method continues to iterate through the clauses starting with the next clause in the sequence.
      Specified by:
      evaluate in interface Predicate
      Returns:
      true if it was possible to satisfy the clause, false otherwise
      See Also:
    • couldReevaluationSucceed

      public boolean couldReevaluationSucceed()
      Description copied from interface: Predicate
      Could the next re-evaluation of this instance succeed?

      Specifies whether a specific instance of a specific implementation of Predicate, that has already had Predicate.evaluate() called on it at least once, could possibly return true the next time Predicate.evaluate() is called on it. i.e. is it worth trying to continue to find solutions for the specific query this particular instance represents and has been evaluating?

      (Note: the difference between this method and PredicateFactory.isRetryable() is that PredicateFactory.isRetryable() deals with whether, in general, a specific implementation (rather than instance) of Predicate could ever produce multiple answers for an individual query.)

      Specified by:
      couldReevaluationSucceed in interface Predicate
      Returns:
      true if an attempt to re-evaluate this instance could possible succeed, false otherwise