01: /*
02: * Copyright 2004 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.repository.query;
17:
18: import org.outerj.daisy.repository.Document;
19: import org.outerj.daisy.repository.Version;
20: import org.outerj.daisy.repository.Repository;
21:
22: /**
23: * A precompiled predicate expression. A predicate expression is an expression
24: * that evaluates to true or false, as used in the where clause of a Daisy query.
25: *
26: * <p>Obtained via {@link QueryManager#parsePredicateExpression}.
27: */
28: public interface PredicateExpression {
29: /**
30: * The version argument is optional, if not present (null) version-dependent information
31: * will be taken from the document object.
32: *
33: * <p>This is the same as calling evaluate(document, version, version == null).
34: */
35: boolean evaluate(Document document, Version version)
36: throws QueryException;
37:
38: /**
39: * Same as the other evaluate method, but allows to specify if, when traversing
40: * links (e.g. using the dereference operator "=>"), the last or live version
41: * should be used of the linked-to documents.
42: */
43: boolean evaluate(Document document, Version version,
44: boolean searchLastVersion) throws QueryException;
45:
46: boolean evaluate(Document document, Version version,
47: boolean searchLastVersion,
48: EvaluationContext evaluationContext) throws QueryException;
49:
50: /**
51: * This evaluate allows to specify a specific repository to use during evaluation.
52: *
53: * <p>This can be useful if you want to compile an expression just once, but then
54: * evaluate it on multiple occasions for different users.
55: *
56: * <p>Note that many expressions don't need access to a repository at all, it is only
57: * some expressions (like dereferencing) which might need access to the repository.
58: */
59: boolean evaluate(Document document, Version version,
60: boolean searchLastVersion, Repository repository)
61: throws QueryException;
62:
63: boolean evaluate(Document document, Version version,
64: boolean searchLastVersion,
65: EvaluationContext evaluationContext, Repository repository)
66: throws QueryException;
67: }
|