Package org.prolog4j
Class Query
- java.lang.Object
-
- org.prolog4j.Query
-
- Direct Known Subclasses:
SWIPrologQuery
,TuPrologQuery
public abstract class Query extends Object
Represents a Prolog query. It is supposed to be created byProver.query(String)
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Query
bind(int argument, Object value)
Binds a value to the specified argument of the goal.abstract Query
bind(String variable, Object value)
Binds a value to the specified argument of the goal.protected String
getGoal()
Returns the Prolog goal to be solved.protected List<String>
getPlaceholderNames()
Returns a list with the name of the place holders in the query.abstract <A> Solution<A>
solve(Object... actualArgs)
Solves the Prolog goal and returns an object using which the individual solutions can be iterated over.
-
-
-
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 goalvalue
- the value to be bound to the argument- Returns:
- the same query instance
-
-