Class Predicates
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<PredicateKey, String> The class names of "built-in" Java predicates (i.e.private final Map<PredicateKey, PredicateFactory> The instances of "built-in" Java predicates (i.e.private final KnowledgeBaseprivate final ObjectUsed to coordinate access tojavaPredicateClassNames,javaPredicateInstancesanduserDefinedPredicatesprivate final Map<PredicateKey, UserDefinedPredicateFactory> The user-defined predicates (i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPredicateFactory(PredicateKey key, String predicateFactoryClassName) Associates aPredicateFactorywith thisKnowledgeBase.voidaddPredicateFactory(PredicateKey key, PredicateFactory predicateFactory) Associates aPredicateFactorywith thisKnowledgeBase.voidaddUserDefinedPredicate(UserDefinedPredicateFactory userDefinedPredicate) Adds a user defined predicate to this object.Returns theUserDefinedPredicateFactoryfor the specifiedPredicateKey.Returns details of all predicates, both user-defined and built-in predicates.private PredicateFactorygetPredicate(Term t) Returns thePredicateFactoryassociated with the specifiedPredicateKey.getPredicateFactory(Term term) Returns thePredicateFactoryassociated with the specifiedTerm.Returns details of all the user define predicates of this object.private PredicateFactoryinstantiatePredicateFactory(String className) private PredicateFactoryprivate booleanprivate booleanprivate booleanprivate PredicateFactoryprivate voidupdateExistingPredicate(PredicateKey key, UserDefinedPredicateFactory userDefinedPredicate)
-
Field Details
-
predicatesLock
Used to coordinate access tojavaPredicateClassNames,javaPredicateInstancesanduserDefinedPredicates -
javaPredicateClassNames
The class names of "built-in" Java predicates (i.e. not defined using Prolog syntax) associated with thisKnowledgeBase. -
javaPredicateInstances
The instances of "built-in" Java predicates (i.e. not defined using Prolog syntax) associated with thisKnowledgeBase. -
userDefinedPredicates
The user-defined predicates (i.e. defined using Prolog syntax) associated with thisKnowledgeBase.Uses TreeMap to enforce predictable ordering for when iterated (e.g. by
listing(X)). -
kb
-
-
Constructor Details
-
Predicates
-
-
Method Details
-
getPredicate
-
getAllDefinedPredicateKeys
Returns details of all predicates, both user-defined and built-in predicates. -
getUserDefinedPredicates
Returns details of all the user define predicates of this object. -
createOrReturnUserDefinedPredicate
Returns theUserDefinedPredicateFactoryfor the specifiedPredicateKey.If this object does not already have a
UserDefinedPredicateFactoryfor the specifiedPredicateKeythen it will create it.- Throws:
ProjogException- if the specifiedPredicateKeyrepresents an existing "plugin" predicate
-
addUserDefinedPredicate
Adds a user defined predicate to this object.Any existing
UserDefinedPredicateFactorywith the samePredicateKeywill be replaced.- Throws:
ProjogException- if thePredicateKeyof the specifiedUserDefinedPredicateFactoryrepresents an existing "plugin" predicate
-
updateExistingPredicate
private void updateExistingPredicate(PredicateKey key, UserDefinedPredicateFactory userDefinedPredicate) -
getPreprocessedPredicateFactory
-
getPredicateFactory
Returns thePredicateFactoryassociated with the specifiedTerm.If this object has no
PredicateFactoryassociated with thePredicateKeyof the specifiedTermthen a new instance ofUnknownPredicateis returned. -
getPredicateFactory
Returns thePredicateFactoryassociated with the specifiedPredicateKey.If this object has no
PredicateFactoryassociated with the specifiedPredicateKeythen a new instance ofUnknownPredicateis returned. -
getExistingPredicateFactory
-
instantiatePredicateFactory
-
instantiatePredicateFactory
-
unknownPredicate
-
addPredicateFactory
Associates aPredicateFactorywith thisKnowledgeBase.This method provides a mechanism for "plugging in" or "injecting" implementations of
PredicateFactoryat 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 thePredicateFactorywith.predicateFactoryClassName- The name of a class that implementsPredicateFactory.- Throws:
ProjogException- if there is already aPredicateFactoryassociated with thePredicateKey
-
addPredicateFactory
Associates aPredicateFactorywith thisKnowledgeBase.This method provides a mechanism for "plugging in" or "injecting" implementations of
PredicateFactoryat 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 thePredicateFactorywith.predicateFactory- ThePredicateFactoryto be added.- Throws:
ProjogException- if there is already aPredicateFactoryassociated with thePredicateKey
-
isExistingPredicate
-
isExistingJavaPredicate
-
isExistingUserDefinedPredicate
-