KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > amber > expr > LoadEmbeddedExpr


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  * Free Software Foundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Rodrigo Westrupp
27  */

28
29 package com.caucho.amber.expr;
30
31 import com.caucho.amber.entity.Embeddable;
32 import com.caucho.amber.field.AmberField;
33 import com.caucho.amber.manager.AmberConnection;
34 import com.caucho.amber.query.FromItem;
35 import com.caucho.amber.query.QueryParser;
36 import com.caucho.amber.table.LinkColumns;
37 import com.caucho.amber.table.Table;
38 import com.caucho.amber.type.EmbeddableType;
39 import com.caucho.amber.type.Type;
40 import com.caucho.util.CharBuffer;
41
42 import java.lang.reflect.Method JavaDoc;
43 import java.sql.ResultSet JavaDoc;
44 import java.sql.SQLException JavaDoc;
45 import java.util.ArrayList JavaDoc;
46 import java.util.HashSet JavaDoc;
47 import java.util.Iterator JavaDoc;
48 import java.util.Map JavaDoc;
49
50 /**
51  * An embedded expression which should be loaded.
52  */

53 public class LoadEmbeddedExpr extends LoadExpr {
54
55   LoadEmbeddedExpr(PathExpr expr)
56   {
57     super(expr);
58   }
59
60   /**
61    * Returns the embeddable type.
62    */

63   public EmbeddableType getEmbeddableType()
64   {
65     return (EmbeddableType) getType();
66   }
67
68   /**
69    * Binds the expression as a select item.
70    */

71   public AmberExpr bindSelect(QueryParser parser)
72   {
73     _fromItem = _expr.bindSubPath(parser);
74
75     if (_fromItem == null)
76       throw new NullPointerException JavaDoc(_expr.getClass().getName() + " " + _expr);
77
78     return this;
79   }
80
81   /**
82    * Returns the object for the expr.
83    */

84   public Object JavaDoc getObject(AmberConnection aConn, ResultSet JavaDoc rs, int index)
85     throws SQLException JavaDoc
86   {
87     Embeddable embeddable = getEmbeddableType().createObject();
88
89     embeddable.__caucho_load(aConn, rs, index);
90
91     return embeddable;
92   }
93
94   /**
95    * Returns the object for the expr.
96    */

97   public Object JavaDoc getCacheObject(AmberConnection aConn,
98                                ResultSet JavaDoc rs,
99                                int index)
100     throws SQLException JavaDoc
101   {
102     // XXX: needs to handle embeddable type caching.
103

104     return getObject(aConn, rs, index);
105   }
106 }
107
Popular Tags