Class QueryPlan
- java.lang.Object
-
- org.projog.api.QueryPlan
-
public class QueryPlan extends java.lang.ObjectRepresents a plan for executing a Prolog query.A single
QueryPlancan be used to create multipleQueryStatementobjects. If you are intending to execute the same query multiple times then, for performance reasons, it is recommended to use aQueryPlanrather than create multipleQueryStatementdirectly. When using aQueryPlanthe Prolog syntax will only be parsed once and the plan for executing the query will be optimised for performance.
-
-
Field Summary
Fields Modifier and Type Field Description private TermparsedInputprivate PredicateFactorypredicateFactory
-
Constructor Summary
Constructors Constructor Description QueryPlan(KnowledgeBase kb, java.lang.String prologQuery)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryStatementcreateStatement()Return a newly createdQueryStatementfor the query represented by this plan.voidexecuteOnce()Evaluate once the query represented by this statement.QueryResultexecuteQuery()Return a newly createdQueryResultfor the query represented by this plan.java.util.List<java.lang.String>findAllAsAtomName()java.util.List<java.lang.Double>findAllAsDouble()java.util.List<java.lang.Long>findAllAsLong()java.util.List<Term>findAllAsTerm()java.lang.StringfindFirstAsAtomName()doublefindFirstAsDouble()longfindFirstAsLong()java.util.Optional<java.lang.String>findFirstAsOptionalAtomName()java.util.Optional<java.lang.Double>findFirstAsOptionalDouble()java.util.Optional<java.lang.Long>findFirstAsOptionalLong()java.util.Optional<Term>findFirstAsOptionalTerm()TermfindFirstAsTerm()
-
-
-
Field Detail
-
predicateFactory
private final PredicateFactory predicateFactory
-
parsedInput
private final Term parsedInput
-
-
Constructor Detail
-
QueryPlan
QueryPlan(KnowledgeBase kb, java.lang.String prologQuery)
-
-
Method Detail
-
createStatement
public QueryStatement createStatement()
Return a newly createdQueryStatementfor the query represented by this plan.Before the query is executed, values can be assigned to variables in the query by using
QueryStatement.setTerm(String, Term). The query can be executed by callingQueryStatement.executeQuery().Note: If you do not intend to assign terms to variables then
executeQuery()can be called instead.- See Also:
executeQuery(),executeOnce()
-
executeQuery
public QueryResult executeQuery()
Return a newly createdQueryResultfor the query represented by this plan.The
QueryResult.next()andQueryResult.getTerm(String)methods can be used to evaluate the query and access values unified to the variables of the query.- See Also:
createStatement(),executeOnce()
-
executeOnce
public void executeOnce()
Evaluate once the query represented by this statement.The query will only be evaluated once, even if further solutions could of been found on backtracking.
- Throws:
ProjogException- if no solution can be found- See Also:
createStatement(),executeQuery()
-
findFirstAsAtomName
public java.lang.String findFirstAsAtomName()
-
findFirstAsDouble
public double findFirstAsDouble()
-
findFirstAsLong
public long findFirstAsLong()
-
findFirstAsTerm
public Term findFirstAsTerm()
-
findFirstAsOptionalAtomName
public java.util.Optional<java.lang.String> findFirstAsOptionalAtomName()
-
findFirstAsOptionalDouble
public java.util.Optional<java.lang.Double> findFirstAsOptionalDouble()
-
findFirstAsOptionalLong
public java.util.Optional<java.lang.Long> findFirstAsOptionalLong()
-
findFirstAsOptionalTerm
public java.util.Optional<Term> findFirstAsOptionalTerm()
-
findAllAsAtomName
public java.util.List<java.lang.String> findAllAsAtomName()
-
findAllAsDouble
public java.util.List<java.lang.Double> findAllAsDouble()
-
findAllAsLong
public java.util.List<java.lang.Long> findAllAsLong()
-
findAllAsTerm
public java.util.List<Term> findAllAsTerm()
-
-