Class Predicates

java.lang.Object
org.projog.core.predicate.Predicates

public class Predicates extends Object
Acts as a repository of rules and facts.
  • Constructor Details

  • Method Details

    • getPredicate

      public Predicate getPredicate(Term t)
    • getAllDefinedPredicateKeys

      public Set<PredicateKey> getAllDefinedPredicateKeys()
      Returns details of all predicates, both user-defined and built-in predicates.
    • getUserDefinedPredicates

      public Map<PredicateKey, UserDefinedPredicateFactory> getUserDefinedPredicates()
      Returns details of all the user define predicates of this object.
    • createOrReturnUserDefinedPredicate

      public UserDefinedPredicateFactory createOrReturnUserDefinedPredicate(PredicateKey key)
      Returns the UserDefinedPredicateFactory for the specified PredicateKey.

      If this object does not already have a UserDefinedPredicateFactory for the specified PredicateKey then it will create it.

      Throws:
      ProjogException - if the specified PredicateKey represents an existing "plugin" predicate
    • addUserDefinedPredicate

      public void addUserDefinedPredicate(UserDefinedPredicateFactory userDefinedPredicate)
      Adds a user defined predicate to this object.

      Any existing UserDefinedPredicateFactory with the same PredicateKey will be replaced.

      Throws:
      ProjogException - if the PredicateKey of the specified UserDefinedPredicateFactory represents an existing "plugin" predicate
    • getPreprocessedPredicateFactory

      public PredicateFactory getPreprocessedPredicateFactory(Term term)
    • getPredicateFactory

      public PredicateFactory getPredicateFactory(Term term)
      Returns the PredicateFactory associated with the specified Term.

      If this object has no PredicateFactory associated with the PredicateKey of the specified Term then a new instance of UnknownPredicate is returned.

    • getPredicateFactory

      public PredicateFactory getPredicateFactory(PredicateKey key)
      Returns the PredicateFactory associated with the specified PredicateKey.

      If this object has no PredicateFactory associated with the specified PredicateKey then a new instance of UnknownPredicate is returned.

    • addPredicateFactory

      public void addPredicateFactory(PredicateKey key, String predicateFactoryClassName)
      Associates a PredicateFactory with this KnowledgeBase.

      This method provides a mechanism for "plugging in" or "injecting" implementations of PredicateFactory at runtime. This mechanism provides an easy way to configure and extend the functionality of Projog - including adding functionality not possible to define in pure Prolog syntax.

      Parameters:
      key - The name and arity to associate the PredicateFactory with.
      predicateFactoryClassName - The name of a class that implements PredicateFactory.
      Throws:
      ProjogException - if there is already a PredicateFactory associated with the PredicateKey
    • addPredicateFactory

      public void addPredicateFactory(PredicateKey key, PredicateFactory predicateFactory)
      Associates a PredicateFactory with this KnowledgeBase.

      This method provides a mechanism for "plugging in" or "injecting" implementations of PredicateFactory at runtime. This mechanism provides an easy way to configure and extend the functionality of Projog - including adding functionality not possible to define in pure Prolog syntax.

      Parameters:
      key - The name and arity to associate the PredicateFactory with.
      predicateFactory - The PredicateFactory to be added.
      Throws:
      ProjogException - if there is already a PredicateFactory associated with the PredicateKey
    • placeholder

      public PredicateFactory placeholder()