01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.algebra.evaluation;
07:
08: import info.aduna.iteration.CloseableIteration;
09:
10: import org.openrdf.model.Value;
11: import org.openrdf.query.BindingSet;
12: import org.openrdf.query.QueryEvaluationException;
13: import org.openrdf.query.algebra.TupleExpr;
14: import org.openrdf.query.algebra.ValueExpr;
15:
16: /**
17: * Evaluates {@link TupleExpr}s and {@link ValueExpr}s.
18: *
19: * @author Arjohn Kampman
20: * @author James Leigh
21: */
22: public interface EvaluationStrategy {
23:
24: /**
25: * Evaluates the tuple expression against the supplied triple source with the
26: * specified set of variable bindings as input.
27: *
28: * @param expr
29: * The Tuple Expression to evaluate
30: * @param bindings
31: * The variables bindings to use for evaluating the expression, if
32: * applicable.
33: * @return A closeable iterator over the variable binding sets that match the
34: * tuple expression.
35: */
36: public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(
37: TupleExpr expr, BindingSet bindings)
38: throws QueryEvaluationException;
39:
40: /**
41: * Gets the value of this expression.
42: *
43: * @param bindings
44: * The variables bindings to use for evaluating the expression, if
45: * applicable.
46: * @return The Value that this expression evaluates to, or <tt>null</tt> if
47: * the expression could not be evaluated.
48: */
49: public Value evaluate(ValueExpr expr, BindingSet bindings)
50: throws ValueExprEvaluationException,
51: QueryEvaluationException;
52:
53: /**
54: * Evaluates the boolean expression on the supplied TripleSource object.
55: *
56: * @param bindings
57: * The variables bindings to use for evaluating the expression, if
58: * applicable.
59: * @return The result of the evaluation.
60: * @throws ValueExprEvaluationException
61: * If the value expression could not be evaluated, for example when
62: * comparing two incompatible operands. When thrown, the result of
63: * the boolean expression is neither <tt>true</tt> nor
64: * <tt>false</tt>, but unknown.
65: */
66: public boolean isTrue(ValueExpr expr, BindingSet bindings)
67: throws ValueExprEvaluationException,
68: QueryEvaluationException;
69: }
|