KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > amber > field > AmberField


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.amber.field;
31
32 import com.caucho.amber.expr.AmberExpr;
33 import com.caucho.amber.expr.PathExpr;
34 import com.caucho.amber.manager.AmberConnection;
35 import com.caucho.amber.manager.AmberPersistenceUnit;
36 import com.caucho.amber.query.QueryParser;
37 import com.caucho.amber.table.Table;
38 import com.caucho.amber.type.AbstractStatefulType;
39 import com.caucho.bytecode.JMethod;
40 import com.caucho.bytecode.JType;
41 import com.caucho.config.ConfigException;
42 import com.caucho.java.JavaWriter;
43 import com.caucho.util.CharBuffer;
44
45 import java.io.IOException JavaDoc;
46 import java.io.Serializable JavaDoc;
47 import java.sql.SQLException JavaDoc;
48 import java.util.ArrayList JavaDoc;
49 import java.util.HashSet JavaDoc;
50
51 /**
52  * Configuration for a bean's property
53  */

54 public interface AmberField {
55   /**
56    * Returns the owning entity class.
57    */

58   public AbstractStatefulType getSourceType();
59
60   /**
61    * Returns true if and only if this is a LAZY field.
62    */

63   public boolean isLazy();
64
65   /**
66    * Returns the field name.
67    */

68   public String JavaDoc getName();
69
70   /**
71    * Returns the table containing the value (or null)
72    */

73   public Table getTable();
74
75   /**
76    * Returns the property index.
77    */

78   public int getIndex();
79
80   /**
81    * Returns the property's group index.
82    */

83   public int getLoadGroupIndex();
84
85   /**
86    * Returns the load group mask.
87    */

88   public long getCreateLoadMask(int group);
89
90   /**
91    * Returns the getter method.
92    */

93   public JMethod getGetterMethod();
94
95   /**
96    * Returns the getter name.
97    */

98   public String JavaDoc getGetterName();
99
100   /**
101    * Returns the type of the field
102    */

103   public JType getJavaType();
104
105   /**
106    * Returns the name of the java type.
107    */

108   public String JavaDoc getJavaTypeName();
109
110   /**
111    * Returns the setter method.
112    */

113   public JMethod getSetterMethod();
114
115   /**
116    * Returns the setter name.
117    */

118   public String JavaDoc getSetterName();
119
120   /**
121    * Returns true if the methods are abstract.
122    */

123   public boolean isAbstract();
124
125   /**
126    * Returns true if the field is cascadable.
127    */

128   public boolean isCascadable();
129
130   /**
131    * Returns true for an updateable field.
132    */

133   public boolean isUpdateable();
134
135   /**
136    * Links to the target.
137    */

138   public void setIndex(int index);
139
140   /**
141    * Links to the target.
142    */

143   public void init()
144     throws ConfigException;
145
146   /**
147    * Returns the actual data.
148    */

149   public String JavaDoc generateSuperGetter();
150
151   /**
152    * Sets the actual data.
153    */

154   public String JavaDoc generateSuperSetter(String JavaDoc value);
155
156   /**
157    * Generates any prologue.
158    */

159   public void generatePrologue(JavaWriter out, HashSet JavaDoc<Object JavaDoc> completedSet)
160     throws IOException JavaDoc;
161
162   /**
163    * Generates the post constructor fixup
164    */

165   public void generatePostConstructor(JavaWriter out)
166     throws IOException JavaDoc;
167
168   /**
169    * Generates the select clause for an entity load.
170    */

171   public String JavaDoc generateLoadSelect(Table table, String JavaDoc id);
172
173   /**
174    * Generates the select clause.
175    */

176   public String JavaDoc generateSelect(String JavaDoc id);
177
178   /**
179    * Generates the JPA QL select clause.
180    */

181   public String JavaDoc generateJavaSelect(String JavaDoc id);
182
183   /**
184    * Generates the where clause.
185    */

186   public String JavaDoc generateWhere(String JavaDoc id);
187
188   /**
189    * Generates the where clause.
190    */

191   public void generateUpdate(CharBuffer sql);
192
193   /**
194    * Generates loading cache
195    */

196   public void generateUpdate(JavaWriter out, String JavaDoc mask, String JavaDoc pstmt,
197                              String JavaDoc index)
198     throws IOException JavaDoc;
199
200   /**
201    * Generates loading code
202    */

203   public boolean hasLoadGroup(int index);
204
205   /**
206    * Generates loading code
207    */

208   public int generateLoad(JavaWriter out, String JavaDoc rs,
209                           String JavaDoc indexVar, int loadGroupIndex)
210     throws IOException JavaDoc;
211
212   /**
213    * Generates loading code
214    */

215   public int generateLoadEager(JavaWriter out, String JavaDoc rs,
216                                String JavaDoc indexVar, int index)
217     throws IOException JavaDoc;
218
219   /**
220    * Generates loading cache
221    */

222   public void generateLoadFromObject(JavaWriter out, String JavaDoc obj)
223     throws IOException JavaDoc;
224
225   /**
226    * Generates loading cache
227    */

228   public void generateSet(JavaWriter out, String JavaDoc obj)
229     throws IOException JavaDoc;
230
231   /**
232    * Generates loading cache
233    */

234   public void generateUpdateFromObject(JavaWriter out, String JavaDoc obj)
235     throws IOException JavaDoc;
236
237   /**
238    * Generates the field getter.
239    *
240    * @param value the non-null value
241    */

242   public void generateGet(JavaWriter out, String JavaDoc value)
243     throws IOException JavaDoc;
244
245   /**
246    * Generates the field getter.
247    *
248    * @param value the non-null value
249    */

250   public String JavaDoc generateGet(String JavaDoc value);
251
252   /**
253    * Generates the field setter.
254    *
255    * @param value the non-null value
256    */

257   public String JavaDoc generateSet(String JavaDoc obj, String JavaDoc value);
258
259   /**
260    * Generates the insert.
261    */

262   public void generateInsertColumns(ArrayList JavaDoc<String JavaDoc> columns);
263
264   /**
265    * Generates the get property.
266    */

267   public void generateGetProperty(JavaWriter out)
268     throws IOException JavaDoc;
269
270   /**
271    * Generates the set property.
272    */

273   public void generateSetProperty(JavaWriter out)
274     throws IOException JavaDoc;
275
276   /**
277    * Generates the get property.
278    */

279   public void generateSuperGetter(JavaWriter out)
280     throws IOException JavaDoc;
281
282   /**
283    * Generates the get property.
284    */

285   public void generateSuperSetter(JavaWriter out)
286     throws IOException JavaDoc;
287
288   /**
289    * Generates the table create.
290    */

291   public String JavaDoc generateCreateTableSQL(AmberPersistenceUnit manager);
292
293   /**
294    * Generates the set clause.
295    */

296   public void generateSet(JavaWriter out, String JavaDoc pstmt, String JavaDoc index)
297     throws IOException JavaDoc;
298
299   /**
300    * Generates the set clause for the insert clause.
301    */

302   public void generateInsertSet(JavaWriter out, String JavaDoc pstmt,
303                                 String JavaDoc index, String JavaDoc obj)
304     throws IOException JavaDoc;
305
306   /**
307    * Generates the set clause for the insert clause.
308    */

309   public void generateUpdateSet(JavaWriter out, String JavaDoc pstmt,
310                                 String JavaDoc index, String JavaDoc obj)
311     throws IOException JavaDoc;
312
313   /**
314    * Updates the cached copy.
315    */

316   public void generateCopyUpdateObject(JavaWriter out,
317                                        String JavaDoc dst, String JavaDoc src,
318                                        int updateIndex)
319     throws IOException JavaDoc;
320
321   /**
322    * Updates the cached copy.
323    */

324   public void generateCopyLoadObject(JavaWriter out,
325                                      String JavaDoc dst, String JavaDoc src,
326                                      int loadIndex)
327     throws IOException JavaDoc;
328
329   /**
330    * Generates the set clause.
331    */

332   public void generateSet(JavaWriter out, String JavaDoc pstmt,
333                           String JavaDoc index, String JavaDoc obj)
334     throws IOException JavaDoc;
335
336   /**
337    * Converts to an object.
338    */

339   public String JavaDoc toObject(String JavaDoc value);
340
341   /**
342    * Links to the target.
343    */

344   public void link();
345
346   /**
347    * Generates the delete foreign
348    */

349   public void generatePreDelete(JavaWriter out)
350     throws IOException JavaDoc;
351
352   /**
353    * Generates the delete foreign
354    */

355   public void generatePostDelete(JavaWriter out)
356     throws IOException JavaDoc;
357
358   /**
359    * Generates the expire code.
360    */

361   public void generateExpire(JavaWriter out)
362     throws IOException JavaDoc;
363
364   /**
365    * Generates code for foreign entity create/delete
366    */

367   public void generateInvalidateForeign(JavaWriter out)
368     throws IOException JavaDoc;
369
370   /**
371    * Deletes the children
372    */

373   public void childDelete(AmberConnection aConn, Serializable JavaDoc primaryKey)
374     throws SQLException JavaDoc;
375
376   /**
377    * Generates code to convert to the type from the object.
378    */

379   public String JavaDoc generateCastFromObject(String JavaDoc value);
380
381   /**
382    * Generates code to test the equals.
383    */

384   public String JavaDoc generateEquals(String JavaDoc leftBase, String JavaDoc value);
385
386   /**
387    * Creates the expression for the field.
388    */

389   public AmberExpr createExpr(QueryParser parser, PathExpr parent);
390 }
391
Popular Tags