01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.kernel.exps;
20:
21: import java.io.Serializable;
22:
23: import org.apache.openjpa.kernel.ExpressionStoreQuery;
24: import org.apache.openjpa.meta.ClassMetaData;
25:
26: /**
27: * Parser for query languages that will be used by a {@link ExpressionQuery}.
28: * A QueryParser is responsible for translating from some string-based query
29: * language into {@link Expression}s. Parsers should be stateless.
30: *
31: * @author Marc Prud'hommeaux
32: * @nojavadoc
33: */
34: public interface ExpressionParser extends Serializable {
35:
36: /**
37: * Return a string key describing the language that this instance parses.
38: */
39: public String getLanguage();
40:
41: /**
42: * Return a parsed intermediate form of the given query string.
43: */
44: public Object parse(String ql, ExpressionStoreQuery query);
45:
46: /**
47: * Use the parsed query form to set information such as candidate type,
48: * result type, etc that was encoded in the query string.
49: */
50: public void populate(Object parsed, ExpressionStoreQuery query);
51:
52: /**
53: * Parse the given query string.
54: */
55: public QueryExpressions eval(Object parsed,
56: ExpressionStoreQuery query, ExpressionFactory factory,
57: ClassMetaData candidate);
58:
59: /**
60: * Parse the given value clauses.
61: */
62: public Value[] eval(String[] vals, ExpressionStoreQuery query,
63: ExpressionFactory factory, ClassMetaData candidate);
64: }
|