KickJava   Java API By Example, From Geeks To Geeks.

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


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 Scott Ferguson
27  */

28
29 package com.caucho.amber.expr;
30
31 import com.caucho.amber.entity.EntityItem;
32 import com.caucho.amber.manager.AmberConnection;
33 import com.caucho.amber.query.FromItem;
34 import com.caucho.amber.query.QueryParseException;
35 import com.caucho.amber.query.QueryParser;
36 import com.caucho.amber.type.Type;
37 import com.caucho.util.CharBuffer;
38
39 import java.sql.ResultSet JavaDoc;
40 import java.sql.SQLException JavaDoc;
41
42 /**
43  * Represents an Amber query expression
44  */

45 public interface AmberExpr {
46   public final static int USES_DATA = 0;
47   public final static int IS_INNER_JOIN = 1;
48
49   /**
50    * Returns true for a boolean expression.
51    */

52   boolean isBoolean();
53
54   /**
55    * Returns the expr type.
56    */

57   Type getType();
58
59   /**
60    * Binds the expression as a select item.
61    */

62   AmberExpr bindSelect(QueryParser parser);
63
64   /**
65    * Returns true if the expression uses the from item.
66    */

67   boolean usesFrom(FromItem from, int type);
68
69   /**
70    * Returns true if the expression uses the from item.
71    */

72   boolean usesFrom(FromItem from, int type, boolean isNot);
73
74   /**
75    * Returns true if the item is required to exist by the expression, e.g.
76    * foo.id='1' forces foo to exist.
77    */

78   boolean exists(FromItem from);
79
80   /**
81    * Returns true if the expression item is required to exist, e.g.
82    * constants and arguments.
83    *
84    * (Can also apply to arguments required to exist after a particular
85    * from item, i.e. from items already proved to exist.)
86    */

87   boolean exists();
88
89   /**
90    * Returns true if the expression uses the from item.
91    */

92   AmberExpr replaceJoin(JoinExpr join);
93
94   /**
95    * Generates the where expression.
96    */

97   void generateWhere(CharBuffer cb);
98
99   /**
100    * Generates the (update) where expression.
101    */

102   void generateUpdateWhere(CharBuffer cb);
103
104   /**
105    * Generates the having expression.
106    */

107   void generateHaving(CharBuffer cb);
108
109   /**
110    * Generates the where expression.
111    */

112   void generateJoin(CharBuffer cb);
113
114   /**
115    * Generates the select expression.
116    */

117   void generateSelect(CharBuffer cb);
118
119   /**
120    * Converts to a boolean expression.
121    */

122   public AmberExpr createBoolean()
123     throws QueryParseException;
124
125   /**
126    * Returns the object for the expr.
127    */

128   public Object JavaDoc getObject(AmberConnection aConn, ResultSet JavaDoc rs, int index)
129     throws SQLException JavaDoc;
130
131   /**
132    * Returns the cache object for the expr.
133    */

134   public Object JavaDoc getCacheObject(AmberConnection aConn,
135                                ResultSet JavaDoc rs, int index)
136     throws SQLException JavaDoc;
137
138   /**
139    * Returns the object for the expr.
140    */

141   public EntityItem findItem(AmberConnection aConn,
142                              ResultSet JavaDoc rs, int index)
143     throws SQLException JavaDoc;
144 }
145
Popular Tags