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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArithmeticOperator(PredicateKey key, String operatorClassName) Associates aArithmeticOperatorwith thisKnowledgeBase.voidaddArithmeticOperator(PredicateKey key, ArithmeticOperator operator) Associates aArithmeticOperatorwith thisKnowledgeBase.getNumeric(Term t) Returns the result of evaluating the specified arithmetic expression.getPreprocessedArithmeticOperator(Term argument)
-
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
-
getPreprocessedArithmeticOperator
- Returns:
- placeholder if argument is not numeric, atom or term
-
getArithmeticOperator
- Throws:
ProjogException- if not found
-
placeholder
-