Package com.semedy.reasoner.api.builtin
Class BuiltinProvider
java.lang.Object
com.semedy.reasoner.api.builtin.BuiltinProvider
Manages the available set of built-ins
- Author:
- angele
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
createsNewObjects
(String fullname, BitSet variablesinstantiation, Literal literal) indicates whether a built-in creates new objectsgetBuiltinType
(String fullname) returns the type of a built-in
given by its full qualified namelong
Every built-in provides a weight measure.boolean
returns whether a predicate given by the full qualified name
predicate name|arity is registered as a built-inboolean
isDynamicBuiltin
(String fullname) returns whether a predicate given by the full qualified name
predicate name|arity is registered as a dynamic built-inboolean
isEvaluable
(String fullname, BitSet variablesinstantiation, Literal literal) returns whether a built-in with a certain variable instantiation
is evaluable.boolean
isInternalBuiltin
(String fullname) indicates whether a predicate given by the full qualified name
predicate name| arity is an internal built-initerator()
Iterate over all built-insnewBuiltin
(String fullname) creates an instance of a built-in
given by its full qualified namevoid
registerBuiltin
(Builtin builtin) register a new built-invoid
removeBuiltin
(Builtin builtin) remove a registered built-inMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BuiltinProvider
- Throws:
BuiltinException
-
-
Method Details
-
registerBuiltin
register a new built-in- Parameters:
builtin
- , the built-in to be registered- Throws:
BuiltinException
-
removeBuiltin
remove a registered built-in- Parameters:
builtin
-- Throws:
BuiltinException
-
iterator
Iterate over all built-ins -
isBuiltin
returns whether a predicate given by the full qualified name
predicate name|arity is registered as a built-in- Parameters:
fullname
- , the full qualified name of the possible built-in- Returns:
- true if is a built-in
-
isDynamicBuiltin
returns whether a predicate given by the full qualified name
predicate name|arity is registered as a dynamic built-in- Parameters:
fullname
- , the full qualified name of the possible built-in- Returns:
- true if it is a dynamic built-in (use of the built-in cannot be cached)
-
isInternalBuiltin
indicates whether a predicate given by the full qualified name
predicate name| arity is an internal built-in- Parameters:
fullname
- , the full qualified name of the possible built-in- Returns:
- true if built-in is an intended to be used internally only
-
newBuiltin
creates an instance of a built-in
given by its full qualified name- Parameters:
fullname
- , the full qulified name of the built-in- Returns:
- newly generated built-in
- Throws:
BuiltinException
-
getBuiltinType
returns the type of a built-in
given by its full qualified name- Parameters:
fullname
- , full qualified name- Returns:
- the built-in type
-
createsNewObjects
public boolean createsNewObjects(String fullname, BitSet variablesinstantiation, Literal literal) throws BuiltinException indicates whether a built-in creates new objects- Parameters:
fullname
- , full qualified namevariablesinstantiation
- , which variables are instantiatedliteral
- , the built-in literal @return, true if new objects, e.g. new numbers are generated- Returns:
- true if built-in creates new objects
- Throws:
BuiltinException
-
isEvaluable
public boolean isEvaluable(String fullname, BitSet variablesinstantiation, Literal literal) throws BuiltinException returns whether a built-in with a certain variable instantiation
is evaluable. Every variable has a position in a rule. The bit set in
"variablesinstantiation" indicates that the variable with that position is instantiated- Parameters:
fullname
- , built-in predicatevariablesinstantiation
- , variables which are instantiatedliteral
- , the body literal- Returns:
- true if built-in is evaluable in that constellation
- Throws:
BuiltinException
-
getWeight
public long getWeight(String fullname, BitSet variablesinstantiation, Literal literal) throws BuiltinException Every built-in provides a weight measure. This determines the place
where it is positioned by the automatic ordering of the rule conditions.
Roughly the weight tells how many tuples are produced as the result of
applying the built-in to one input tuple.
E.g. sqrt has weight 2, because every input number has 2 square roots- Parameters:
fullname
- , full qualified name of the built-invariablesinstantiation
- , variables which are instantiatedliteral
- , the body literal- Returns:
- Throws:
BuiltinException
-