Class BuiltinProvider

java.lang.Object
com.semedy.reasoner.api.builtin.BuiltinProvider
All Implemented Interfaces:
Iterable<Builtin>

public class BuiltinProvider extends Object implements Iterable<Builtin>
Manages the available set of built-ins
Author:
angele
  • Constructor Details

  • Method Details

    • registerBuiltin

      public void registerBuiltin(Builtin builtin) throws BuiltinException
      register a new built-in
      Parameters:
      builtin - , the built-in to be registered
      Throws:
      BuiltinException
    • removeBuiltin

      public void removeBuiltin(Builtin builtin) throws BuiltinException
      remove a registered built-in
      Parameters:
      builtin -
      Throws:
      BuiltinException
    • iterator

      public Iterator<Builtin> iterator()
      Iterate over all built-ins
      Specified by:
      iterator in interface Iterable<Builtin>
    • isBuiltin

      public boolean isBuiltin(String fullname)
      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

      public boolean isDynamicBuiltin(String fullname)
      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

      public boolean isInternalBuiltin(String fullname)
      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

      public Builtin newBuiltin(String fullname) throws BuiltinException
      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

      public BuiltinType getBuiltinType(String fullname)
      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 name
      variablesinstantiation - , which variables are instantiated
      literal - , 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 predicate
      variablesinstantiation - , variables which are instantiated
      literal - , 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-in
      variablesinstantiation - , variables which are instantiated
      literal - , the body literal
      Returns:
      Throws:
      BuiltinException