KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > ejbql > parser > CompiledExpression


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
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.cayenne.ejbql.parser;
20
21 import java.util.Map JavaDoc;
22
23 import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
24 import org.apache.cayenne.ejbql.EJBQLExpression;
25 import org.apache.cayenne.map.ObjRelationship;
26 import org.apache.cayenne.query.SQLResultSetMapping;
27 import org.apache.cayenne.reflect.ClassDescriptor;
28
29 /**
30  * A compiled EJBQL expression.
31  *
32  * @since 3.0
33  * @author Andrus Adamchik
34  */

35 class CompiledExpression implements EJBQLCompiledExpression {
36
37     private String JavaDoc source;
38     private String JavaDoc rootId;
39     private Map JavaDoc descriptorsById;
40     private Map JavaDoc incomingById;
41     private EJBQLExpression expression;
42     private SQLResultSetMapping resultSetMapping;
43
44     public ClassDescriptor getEntityDescriptor(String JavaDoc idVariable) {
45         if (idVariable == null) {
46             return null;
47         }
48
49         return (ClassDescriptor) descriptorsById
50                 .get(Compiler.normalizeIdPath(idVariable));
51     }
52     
53     public SQLResultSetMapping getResultSetMapping() {
54         return resultSetMapping;
55     }
56
57     public ClassDescriptor getRootDescriptor() {
58         return rootId != null ? getEntityDescriptor(rootId) : null;
59     }
60
61     public ObjRelationship getIncomingRelationship(String JavaDoc identifier) {
62         return (ObjRelationship) incomingById.get(identifier);
63     }
64
65     public EJBQLExpression getExpression() {
66         return expression;
67     }
68
69     public String JavaDoc getSource() {
70         return source;
71     }
72
73     void setExpression(EJBQLExpression expression) {
74         this.expression = expression;
75     }
76
77     void setDescriptorsById(Map JavaDoc descriptorsById) {
78         this.descriptorsById = descriptorsById;
79     }
80
81     void setIncomingById(Map JavaDoc incomingById) {
82         this.incomingById = incomingById;
83     }
84
85     void setSource(String JavaDoc source) {
86         this.source = source;
87     }
88
89     void setRootId(String JavaDoc rootId) {
90         this.rootId = rootId;
91     }
92     
93     void setResultSetMapping(SQLResultSetMapping resultSetMapping) {
94         this.resultSetMapping = resultSetMapping;
95     }
96 }
97
Popular Tags