KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > sqlmap > engine > scope > RequestScope


1 /*
2  * Copyright 2004 Clinton Begin
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 com.ibatis.sqlmap.engine.scope;
17
18 import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
19 import com.ibatis.sqlmap.engine.mapping.result.ResultMap;
20 import com.ibatis.sqlmap.engine.mapping.sql.Sql;
21 import com.ibatis.sqlmap.engine.mapping.statement.MappedStatement;
22
23 import java.sql.ResultSet JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.HashMap JavaDoc;
26
27 /**
28  * Request based implementation of Scope interface
29  */

30 public class RequestScope extends BaseScope {
31
32
33   // Used by Any
34
private SessionScope session;
35   private ErrorContext errorContext;
36   private MappedStatement statement;
37   private ParameterMap parameterMap;
38   private ResultMap resultMap;
39   private Sql sql;
40
41   // Used by DynamicSql
42
private ParameterMap dynamicParameterMap;
43   private String JavaDoc dynamicSql;
44
45   // Used by N+1 Select solution
46
private ResultSet JavaDoc resultSet;
47   private Map uniqueKeys;
48   private boolean rowDataFound;
49   /**
50    * Default constructor
51    */

52   public RequestScope() {
53     errorContext = new ErrorContext();
54     reset();
55   }
56
57   /**
58    * Get the request's error context
59    *
60    * @return - the request's error context
61    */

62   public ErrorContext getErrorContext() {
63     return errorContext;
64   }
65
66   /**
67    * Get the session of the request
68    *
69    * @return - the session
70    */

71   public SessionScope getSession() {
72     return session;
73   }
74
75   /**
76    * Set the session for the request
77    *
78    * @param session - the new session
79    */

80   public void setSession(SessionScope session) {
81     this.session = session;
82   }
83
84   /**
85    * Get the statement for the request
86    *
87    * @return - the statement
88    */

89   public MappedStatement getStatement() {
90     return statement;
91   }
92
93   /**
94    * Set the statement for the request
95    *
96    * @param statement - the statement
97    */

98   public void setStatement(MappedStatement statement) {
99     this.statement = statement;
100   }
101
102   /**
103    * Get the parameter map for the request
104    *
105    * @return - the parameter map
106    */

107   public ParameterMap getParameterMap() {
108     return parameterMap;
109   }
110
111   /**
112    * Set the parameter map for the request
113    * @param parameterMap - the new parameter map
114    */

115   public void setParameterMap(ParameterMap parameterMap) {
116     this.parameterMap = parameterMap;
117   }
118
119   /**
120    * Get the result map for the request
121    *
122    * @return - the result map
123    */

124   public ResultMap getResultMap() {
125     return resultMap;
126   }
127
128   /**
129    * Set the result map for the request
130    *
131    * @param resultMap - the result map
132    */

133   public void setResultMap(ResultMap resultMap) {
134     this.resultMap = resultMap;
135   }
136
137   /**
138    * Get the SQL for the request
139    *
140    * @return - the sql
141    */

142   public Sql getSql() {
143     return sql;
144   }
145
146   /**
147    * Set the SQL for the request
148    *
149    * @param sql - the sql
150    */

151   public void setSql(Sql sql) {
152     this.sql = sql;
153   }
154
155   /**
156    * Get the dynamic parameter for the request
157    *
158    * @return - the dynamic parameter
159    */

160   public ParameterMap getDynamicParameterMap() {
161     return dynamicParameterMap;
162   }
163
164   /**
165    * Set the dynamic parameter for the request
166    *
167    * @param dynamicParameterMap - the dynamic parameter
168    */

169   public void setDynamicParameterMap(ParameterMap dynamicParameterMap) {
170     this.dynamicParameterMap = dynamicParameterMap;
171   }
172
173   /**
174    * Get the dynamic SQL for the request
175    *
176    * @return - the dynamic SQL
177    */

178   public String JavaDoc getDynamicSql() {
179     return dynamicSql;
180   }
181
182   /**
183    * Set the dynamic SQL for the request
184    * @param dynamicSql - the dynamic SQL
185    */

186   public void setDynamicSql(String JavaDoc dynamicSql) {
187     this.dynamicSql = dynamicSql;
188   }
189
190   public ResultSet JavaDoc getResultSet() {
191     return resultSet;
192   }
193
194   public void setResultSet(ResultSet JavaDoc resultSet) {
195     this.resultSet = resultSet;
196   }
197
198   public Map getUniqueKeys(ResultMap map) {
199     if (uniqueKeys == null) {
200       return null;
201     }
202     return (Map)uniqueKeys.get(map);
203   }
204
205   public void setUniqueKeys(ResultMap map, Map keys) {
206     if (uniqueKeys == null) {
207       uniqueKeys = new HashMap JavaDoc();
208     }
209     this.uniqueKeys.put(map, keys);
210   }
211
212   public boolean isRowDataFound() {
213     return rowDataFound;
214   }
215
216   public void setRowDataFound(boolean rowDataFound) {
217     this.rowDataFound = rowDataFound;
218   }
219
220   public void reset() {
221     super.reset();
222     errorContext.reset();
223     session = null;
224     statement = null;
225     parameterMap = null;
226     resultMap = null;
227     sql = null;
228     dynamicParameterMap = null;
229     dynamicSql = null;
230     resultSet = null;
231     uniqueKeys = null;
232     rowDataFound = true;
233   }
234
235 }
236
Popular Tags