Class ArithmeticOperators
java.lang.Object
org.projog.core.math.ArithmeticOperators
Maintains a collection of
ArithmeticOperator instances.
This class provides a mechanism for "plugging in" or "injecting" implementations of ArithmeticOperator at
runtime. This mechanism provides an easy way to configure and extend the arithmetic operations supported by Projog.
Each KnowledgeBase has a single unique ArithmeticOperators instance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final KnowledgeBaseprivate final Objectprivate final Map<PredicateKey, String> private final Map<PredicateKey, ArithmeticOperator> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArithmeticOperator(PredicateKey key, String operatorClassName) Associates aArithmeticOperatorwith thisKnowledgeBase.voidaddArithmeticOperator(PredicateKey key, ArithmeticOperator operator) Associates aArithmeticOperatorwith thisKnowledgeBase.private NumericgetNumeric(Term t) Returns the result of evaluating the specified arithmetic expression.private ArithmeticOperatorgetPreprocessedArithmeticOperator(PredicateKey key, Term argument) getPreprocessedArithmeticOperator(Term argument) private ArithmeticOperatorinstantiateArithmeticOperator(String className) private ArithmeticOperator
-
Field Details
-
kb
-
lock
-
operatorClassNames
-
operatorInstances
-
-
Constructor Details
-
ArithmeticOperators
-
-
Method Details
-
addArithmeticOperator
Associates aArithmeticOperatorwith thisKnowledgeBase.- Parameters:
key- The name and arity to associate theArithmeticOperatorwith.operator- The instance ofArithmeticOperatorto be associated withkey.- Throws:
ProjogException- if there is already aArithmeticOperatorassociated with thePredicateKey
-
addArithmeticOperator
Associates aArithmeticOperatorwith thisKnowledgeBase.- Parameters:
key- The name and arity to associate theArithmeticOperatorwith.operatorClassName- The class name of theArithmeticOperatorto be associated withkey.- Throws:
ProjogException- if there is already aArithmeticOperatorassociated with thePredicateKey
-
getNumeric
Returns the result of evaluating the specified arithmetic expression.- Parameters:
t- aTermthat can be evaluated as an arithmetic expression (e.g. aStructureof the form+(1,2)or aNumeric)- Returns:
- the result of evaluating the specified arithmetic expression
- Throws:
ProjogException- if the specified term does not represent an arithmetic expression
-
calculate
-
getPreprocessedArithmeticOperator
- Returns:
- null if not found
-
getPreprocessedArithmeticOperator
-
getArithmeticOperator
- Throws:
ProjogException- if not found
-
instantiateArithmeticOperator
-
instantiateArithmeticOperator
-