KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > ejb > ql > Query


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 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.ejb.ql;
30
31 import com.caucho.bytecode.JMethod;
32 import com.caucho.config.ConfigException;
33 import com.caucho.ejb.cfg.EjbConfig;
34 import com.caucho.util.IntArray;
35
36 /**
37  * A select/find query
38  */

39 class Query {
40   final static int IDENTIFIER = 128;
41   final static int INTEGER = IDENTIFIER + 1;
42   final static int LONG = INTEGER + 1;
43   final static int DOUBLE = LONG + 1;
44   final static int STRING = DOUBLE + 1;
45   final static int TRUE = STRING + 1;
46   final static int FALSE = TRUE + 1;
47   final static int UNKNOWN = FALSE + 1;
48   final static int MEMBER = UNKNOWN + 1;
49   final static int OF = MEMBER + 1;
50   final static int EMPTY = OF + 1;
51   final static int NULL = EMPTY + 1;
52   
53   final static int FROM = NULL + 1;
54   final static int IN = FROM + 1;
55   final static int SELECT = IN + 1;
56   final static int DISTINCT = SELECT + 1;
57   final static int WHERE = SELECT + 1;
58   final static int AS = WHERE + 1;
59   final static int ORDER = AS + 1;
60   final static int BY = ORDER + 1;
61   final static int ASC = BY + 1;
62   final static int DESC = ASC + 1;
63   final static int LIMIT = DESC + 1;
64   final static int OFFSET = LIMIT + 1;
65   
66   final static int BETWEEN = OFFSET + 1;
67   final static int LIKE = BETWEEN + 1;
68   final static int ESCAPE = LIKE + 1;
69   final static int IS = ESCAPE + 1;
70   
71   final static int EQ = IS + 1;
72   final static int NE = EQ + 1;
73   final static int LT = NE + 1;
74   final static int LE = LT + 1;
75   final static int GT = LE + 1;
76   final static int GE = GT + 1;
77   
78   final static int AND = GE + 1;
79   final static int OR = AND + 1;
80   final static int NOT = OR + 1;
81
82   final static int EXTERNAL_DOT = NOT + 1;
83   
84   final static int ARG = EXTERNAL_DOT + 1;
85   final static int THIS = ARG + 1;
86
87   private JMethod _method;
88   private EjbConfig _config;
89
90   private IntArray _argSize = new IntArray();
91
92   JMethod getMethod()
93   {
94     return _method;
95   }
96
97   void setMethod(JMethod method)
98   {
99     _method = method;
100   }
101
102   void setConfig(EjbConfig config)
103   {
104     _config = config;
105   }
106
107   EjbConfig getConfig()
108   {
109     return _config;
110   }
111
112   /**
113    * Sets the number of sub-arguments for an arg.
114    */

115   public void setArgSize(int index, int size)
116   {
117     while (_argSize.size() < index) {
118       _argSize.add(0);
119     }
120
121     _argSize.set(index - 1, size);
122   }
123
124   /**
125    * Sets the number of sub-arguments for an arg.
126    */

127   public int getArgIndex(int index)
128   {
129     int size = 1;
130     
131     for (int i = 0; i < index - 1; i++) {
132       size += _argSize.get(i);
133     }
134
135     return size;
136   }
137   
138   /**
139    * Creates an error.
140    */

141   public ConfigException error(String JavaDoc msg)
142   {
143     return new ConfigException(msg);
144     /*
145     msg += "\nin \"" + _query + "\"";
146     if (_qlConfig != null)
147       return new SelectLineParseException(_qlConfig.getFilename() + ":" +
148                       _qlConfig.getLine() + ": " +
149                       msg);
150     else if (_location != null)
151       return new SelectLineParseException(_location + msg);
152     else
153       return new SelectParseException(msg);
154     */

155   }
156 }
157
Popular Tags