KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > query > model > PredicateExpr


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.query.model;
17
18 import org.outerj.daisy.repository.query.QueryException;
19 import org.outerj.daisy.repository.query.EvaluationContext;
20 import org.outerj.daisy.query.QueryContext;
21 import org.outerj.daisy.repository.Document;
22 import org.outerj.daisy.repository.Version;
23
24 import java.sql.PreparedStatement JavaDoc;
25 import java.sql.SQLException JavaDoc;
26
27 /**
28  * Interface for predicate expressions, these are expression which
29  * evaluate to either "true" or "false". They are used in the "where"
30  * part of the query, or can be evaluated stand-alone.
31  */

32 public interface PredicateExpr extends Expression {
33     /**
34      * Needs to be called before usage of other methods.
35      */

36     void prepare(QueryContext context) throws QueryException;
37
38     /**
39      * Evaluates the expression for the given document and version. The version
40      * parameter is allowed to be null, in which case version-dependent information
41      * will be retrieved from the document object.
42      */

43     boolean evaluate(Document document, Version version, EvaluationContext evaluationContext) throws QueryException;
44
45     void generateSql(StringBuffer JavaDoc sql, SqlGenerationContext context) throws QueryException;
46
47     /**
48      * @param bindPos the binding position on which to bind the next value
49      * @return the next binding position
50      */

51     int bindSql(PreparedStatement JavaDoc stmt, int bindPos, EvaluationContext evaluationContext) throws SQLException JavaDoc, QueryException;
52
53     /**
54      * Checks if this PredicateExpr only uses stuff allowed in ACL object conditions.
55      * Returns null if successfull.
56      */

57     AclConditionViolation isAclAllowed();
58
59     /**
60      * Checks if this conditionl expression could evaluate to true
61      * for a document, without really knowing everything about the document.
62      * The supplied Document object only needs to return the document type
63      * and collections, the other methods do not need to be implemented.
64      *
65      * <p>The result can be:
66      * <ul>
67      * <li>yes, if the expression is guaranteed to evaluate
68      * to true for such a document. For example, the simple
69      * expression 'true' will always be true regardless
70      * of the document.</li>
71      * <li>no,if the expression is guaranteed to evaluate to
72      * false for such a document. For example, the expression
73      * test "documentType = 'abc'" but the supplied document
74      * object is of another type.</li>
75      * <li>maybe, if the epxression could apply but the exact
76      * outcome depends on further information. For example,
77      * when the expression depends on the value of a field.
78      * </ul>
79      */

80     Tristate appliesTo(Document document) throws QueryException;
81 }
82
Popular Tags