KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright (c) 1998-2004 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 SoftwareFoundation, 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.query;
30
31 import java.sql.ResultSet;
32 import java.sql.SQLException;
33
34 import com.caucho.util.CharBuffer;
35
36 import com.caucho.amber.type.Type;
37
38 import com.caucho.amber.entity.EntityItem;
39
40 import com.caucho.amber.connection.AmberConnectionImpl;
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 expression uses the from item.
76    */

77   AmberExpr replaceJoin(JoinExpr join);
78   
79   /**
80    * Generates the where expression.
81    */

82   void generateWhere(CharBuffer cb);
83   
84   /**
85    * Generates the where expression.
86    */

87   void generateJoin(CharBuffer cb);
88   
89   /**
90    * Generates the select expression.
91    */

92   void generateSelect(CharBuffer cb);
93
94   /**
95    * Converts to a boolean expression.
96    */

97   public AmberExpr createBoolean()
98     throws QueryParseException;
99
100   /**
101    * Returns the object for the expr.
102    */

103   public Object getObject(AmberConnectionImpl aConn, ResultSet rs, int index)
104     throws SQLException;
105
106   /**
107    * Returns the cache object for the expr.
108    */

109   public Object getCacheObject(AmberConnectionImpl aConn,
110                    ResultSet rs, int index)
111     throws SQLException;
112
113   /**
114    * Returns the object for the expr.
115    */

116   public EntityItem findItem(AmberConnectionImpl aConn,
117                  ResultSet rs, int index)
118     throws SQLException;
119 }
120
Popular Tags