Package org.prolog4j

Class Query

    • Constructor Detail

      • Query

        protected Query​(String goalPattern)
        Creates a query object.
        Parameters:
        goalPattern - the Prolog goal
    • Method Detail

      • getGoal

        protected final String getGoal()
        Returns the Prolog goal to be solved. The placeholders are removed from it, so it may differ from the original goal passed to the constructor.
        Returns:
        the Prolog goal to be solved
      • getPlaceholderNames

        protected final List<String> getPlaceholderNames()
        Returns a list with the name of the place holders in the query.
        Returns:
        the placeholderNames
      • solve

        public abstract <A> Solution<A> solve​(Object... actualArgs)
        Solves the Prolog goal and returns an object using which the individual solutions can be iterated over. The actual arguments will be bound to the placeholders before solving the goal.
        Type Parameters:
        A - the type of an element of the solutions
        Parameters:
        actualArgs - the actual arguments of the goal
        Returns:
        an object for traversing the solutions
      • bind

        public abstract Query bind​(int argument,
                                   Object value)
        Binds a value to the specified argument of the goal. The argument is specified by its position. Numbering starts from zero.

        The method returns the same query instance.

        Parameters:
        argument - the number of the argument of the goal
        value - the value to be bound to the argument
        Returns:
        the same query instance
      • bind

        public abstract Query bind​(String variable,
                                   Object value)
        Binds a value to the specified argument of the goal. The argument is specified by its name.
        Parameters:
        variable - the name of the variable of the goal
        value - the value to be bound to the variable
        Returns:
        the same query instance