001: /* Copyright (c) 2001-2005, The HSQL Development Group
002: * All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * Redistributions of source code must retain the above copyright notice, this
008: * list of conditions and the following disclaimer.
009: *
010: * Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * Neither the name of the HSQL Development Group nor the names of its
015: * contributors may be used to endorse or promote products derived from this
016: * software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
022: * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
026: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
028: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030:
031: package org.hsqldb;
032:
033: import org.hsqldb.lib.HashSet;
034: import org.hsqldb.lib.IntValueHashMap;
035:
036: /**
037: * Defines and enumerates reserved and non-reserved SQL
038: * keywords. <p>
039: *
040: * @author Nitin Chauhan
041: * @author fredt@users
042: * @since 1.7.2
043: * @version 1.7.2
044: */
045: public class Token {
046:
047: private static IntValueHashMap commandSet;
048:
049: //
050: static final String T_ASTERISK = "*";
051: static final String T_COMMA = ",";
052: static final String T_CLOSEBRACKET = ")";
053: static final String T_EQUALS = "=";
054: public static final String T_DIVIDE = "/";
055: static final String T_OPENBRACKET = "(";
056: static final String T_SEMICOLON = ";";
057: static final String T_MULTIPLY = "*";
058: static final String T_PERCENT = "%";
059: static final String T_PLUS = "+";
060: static final String T_QUESTION = "?";
061:
062: // SQL 200n reserved tokens
063: static final String T_ADD = "ADD"; //reserved
064: static final String T_ALL = "ALL"; //reserved
065: static final String T_ALLOCATE = "ALLOCATE"; //reserved
066: public static final String T_ALTER = "ALTER"; //reserved
067: static final String T_AND = "AND"; //reserved
068: static final String T_ANY = "ANY"; //reserved
069: static final String T_ARE = "ARE"; //reserved
070: static final String T_ARRAY = "ARRAY"; //reserved
071: static final String T_AS = "AS"; //reserved
072: static final String T_ASENSITIVE = "ASENSITIVE"; //reserved
073: static final String T_ASYMMETRIC = "ASYMMETRIC"; //reserved
074: static final String T_AT = "AT"; //reserved
075: static final String T_ATOMIC = "ATOMIC"; //reserved
076: static final String T_AUTHORIZATION = "AUTHORIZATION"; //reserved
077: static final String T_BEGIN = "BEGIN"; //reserved
078: static final String T_BETWEEN = "BETWEEN";
079: static final String T_BIGINT = "BIGINT"; //reserved
080: public static final String T_BINARY = "BINARY"; //reserved
081: static final String T_BLOB = "BLOB"; //reserved
082: static final String T_BOOLEAN = "BOOLEAN"; //reserved
083: static final String T_BOTH = "BOTH";
084: static final String T_BY = "BY"; //reserved
085: static final String T_CALL = "CALL"; //reserved
086: static final String T_CALLED = "CALLED"; //reserved
087: static final String T_CASCADED = "CASCADED"; //reserved
088: static final String T_CASE = "CASE"; //reserved
089: static final String T_CAST = "CAST"; //reserved
090: static final String T_CHAR = "CHAR"; //reserved
091: static final String T_CHARACTER = "CHARACTER"; //reserved
092: static final String T_CHECK = "CHECK"; //reserved
093: static final String T_CLOB = "CLOB"; //reserved
094: static final String T_CLOSE = "CLOSE"; //reserved
095: static final String T_COLLATE = "COLLATE"; //reserved
096: static final String T_COLUMN = "COLUMN"; //reserved
097: public static final String T_COMMIT = "COMMIT"; //reserved
098: static final String T_CONDITION = "CONDIITON"; //reserved
099: static final String T_CONNECT = "CONNECT"; //reserved
100: static final String T_CONSTRAINT = "CONSTRAINT"; //reserved
101: static final String T_CONTINUE = "CONTINUE"; //reserved
102: static final String T_CORRESPONDING = "CORRESPONDING"; //reserved
103: static final String T_CREATE = "CREATE"; //reserved
104: static final String T_CROSS = "CROSS"; //reserved
105: static final String T_CUBE = "CUBE"; //reserved
106: static final String T_CURRENT = "CURRENT"; //reserved
107: static final String T_CURRENT_DATE = "CURRENT_DATE"; //reserved
108: static final String T_CURRENT_DEFAULT_TRANS_GROUP = "CURRENT_DEFAULT_TRANSFORM_GROUP"; //reserved
109: static final String T_CURRENT_PATH = "CURRENT_PATH"; //reserved
110: static final String T_CURRENT_ROLE = "CURRENT_ROLE"; //reserved
111: static final String T_CURRENT_TIME = "CURRENT_TIME"; //reserved
112: static final String T_CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP"; //reserved
113: static final String T_CURRENT_TRANS_TROUP_FOR_TYPE = "CURRENT_TRANSFORM_GROUP_FOR_TYPE"; //reserved
114: static final String T_CURRENT_USER = "CURRENT_USER"; //reserved
115: static final String T_CURSOR = "CURSOR"; //reserved
116: static final String T_CYCLE = "CYCLE"; //reserved
117: static final String T_DATE = "DATE"; //reserved
118: static final String T_DAY = "DAY"; //reserved
119: static final String T_DEALLOCATE = "DEALLOCATE"; //reserved
120: static final String T_DEC = "DEC"; //reserved
121: static final String T_DECIMAL = "DECIMAL"; //reserved
122: static final String T_DECLARE = "DECLARE"; //reserved
123: static final String T_DEFAULT = "DEFAULT"; //reserved
124: public static final String T_DELETE = "DELETE"; //reserved
125: static final String T_DEREF = "DEREF"; //reserved
126: static final String T_DESCRIBE = "DESCRIBE"; //reserved
127: static final String T_DETERMINISTIC = "DETERMINISTIC"; //reserved
128: static final String T_DISCONNECT = "DISCONNECT"; //reserved
129: static final String T_DISTINCT = "DISTINCT"; //reserved
130: static final String T_DO = "DO"; //reserved
131: static final String T_DOUBLE = "DOUBLE"; //reserved
132: static final String T_DOW = "DAYOFWEEK"; //reserved
133: static final String T_DROP = "DROP"; //reserved
134: static final String T_DYNAMIC = "DYNAMIC"; //reserved
135: static final String T_EACH = "EACH"; //reserved
136: static final String T_ELEMENT = "ELEMENT"; //reserved
137: static final String T_ELSE = "ELSE"; //reserved
138: static final String T_ELSEIF = "ELSEIF"; //reserved
139: static final String T_END = "END"; //reserved
140: static final String T_ESCAPE = "ESCAPE"; //reserved
141: static final String T_EXCEPT = "EXCEPT"; //reserved
142: static final String T_EXEC = "EXEC"; //reserved
143: static final String T_EXECUTE = "EXECUTE"; //reserved
144: static final String T_EXISTS = "EXISTS"; //reserved
145: static final String T_EXIT = "EXIT"; //reserved
146: static final String T_EXTERNAL = "EXTERNAL"; //reserved
147: static final String T_FALSE = "FALSE"; //reserved
148: static final String T_FETCH = "FETCH"; //reserved
149: static final String T_FILTER = "FILTER"; //reserved
150: static final String T_FLOAT = "FLOAT"; //reserved
151: static final String T_FOR = "FOR"; //reserved
152: static final String T_FOREIGN = "FOREIGN"; //reserved
153: static final String T_FREE = "FREE"; //reserved
154: static final String T_FROM = "FROM"; //reserved
155: static final String T_FULL = "FULL"; //reserved
156: static final String T_FUNCTION = "FUNCTION"; //reserved
157: static final String T_GET = "GET"; //reserved
158: static final String T_GLOBAL = "GLOBAL"; //reserved
159: static final String T_GRANT = "GRANT"; //reserved
160: static final String T_GROUP = "GROUP"; //reserved
161: static final String T_GROUPING = "GROUPING"; //reserved
162: static final String T_HANDLER = "HANDLER"; //reserved
163: static final String T_HAVING = "HAVING"; //reserved
164: static final String T_HEADER = "HEADER"; //reserved
165: static final String T_HOLD = "HOLD"; //reserved
166: static final String T_HOUR = "HOUR"; //reserved
167: static final String T_IDENTITY = "IDENTITY"; //reserved
168: static final String T_IF = "IF"; //reserved
169: static final String T_IMMEDIATE = "IMMEDIATE"; //reserved
170: static final String T_IN = "IN"; //reserved
171: static final String T_INDICATOR = "INDICATOR"; //reserved
172: static final String T_INNER = "INNER"; //reserved
173: static final String T_INOUT = "INOUT"; //reserved
174: static final String T_INPUT = "INPUT"; //reserved
175: static final String T_INSENSITIVE = "INSENSITIVE"; //reserved
176: public static final String T_INSERT = "INSERT"; //reserved
177: static final String T_INT = "INT"; //reserved
178: static final String T_INTEGER = "INTEGER"; //reserved
179: static final String T_INTERSECT = "INTERSECT"; //reserved
180: static final String T_INTERVAL = "INTERVAL"; //reserved
181: static final String T_INTO = "INTO"; //reserved
182: static final String T_IS = "IS"; //reserved
183: static final String T_ITERATE = "ITERATE"; //reserved
184: static final String T_JOIN = "JOIN"; //reserved
185: static final String T_LANGUAGE = "LANGUAGE"; //reserved
186: static final String T_LARGE = "LARGE"; //reserved
187: static final String T_LATERAL = "LATERAL"; //reserved
188: static final String T_LEADING = "LEADING"; //reserved
189: static final String T_LEAVE = "LEAVE"; //reserved
190: static final String T_LEFT = "LEFT"; //reserved
191: static final String T_LIKE = "LIKE"; //reserved
192: static final String T_LOCAL = "LOCAL"; //reserved
193: static final String T_LOCALTIME = "LOCALTIME"; //reserved
194: static final String T_LOCALTIMESTAMP = "LOCALTIMESTAMP"; //reserved
195: static final String T_LOOP = "LOOP"; //reserved
196: static final String T_MATCH = "MATCH"; //reserved
197: static final String T_MEMBER = "MEMBER"; //reserved
198: static final String T_METHOD = "METHOD"; //reserved
199: static final String T_MINUTE = "MINUTE"; //reserved
200: static final String T_MODIFIES = "MODIFIES"; //reserved
201: static final String T_MODULE = "MODULE"; //reserved
202: static final String T_MONTH = "MONTH"; //reserved
203: static final String T_MULTISET = "MULTISET"; //reserved
204: static final String T_NATIONAL = "NATIONAL"; //reserved
205: static final String T_NATURAL = "NAUTRAL"; //reserved
206: static final String T_NCHAR = "NCHAR"; //reserved
207: static final String T_NCLOB = "NCLOB"; //reserved
208: static final String T_NEW = "NEW"; //reserved
209: static final String T_NEXT = "NEXT"; //reserved
210: static final String T_NO = "NO"; //reserved
211: static final String T_NONE = "NONE"; //reserved
212: static final String T_NOT = "NOT"; //reserved
213: static final String T_NULL = "NULL"; //reserved
214: static final String T_NUMERIC = "NUMERIC"; //reserved
215: static final String T_OF = "OF"; //reserved
216: static final String T_OLD = "OLD"; //reserved
217: static final String T_ON = "ON"; //reserved
218: static final String T_ONLY = "ONLY"; //reserved
219: static final String T_OPEN = "OPEN"; //reserved
220: static final String T_OR = "OR"; //reserved
221: static final String T_ORDER = "ORDER"; //reserved
222: static final String T_OUT = "OUT"; //reserved
223: static final String T_OUTER = "OUTER"; //reserved
224: static final String T_OUTPUT = "OUTPUT"; //reserved
225: static final String T_OVER = "OVER"; //reserved
226: static final String T_OVERLAPS = "OVERLAPS"; //reserved
227: static final String T_PARAMETER = "PARAMETER"; //reserved
228: static final String T_PARTITION = "PARTITION"; //reserved
229: static final String T_PRECISION = "PRECISION"; //reserved
230: static final String T_PREPARE = "PREPARE"; //reserved
231: static final String T_PRIMARY = "PRIMARY"; //reserved
232: static final String T_PROCEDURE = "PROCEDURE"; //reserved
233: static final String T_RANGE = "RANGE"; //reserved
234: static final String T_READS = "READS"; //reserved
235: static final String T_REAL = "REAL"; //reserved
236: static final String T_RECURSIVE = "RECURSIVE"; //reserved
237: static final String T_REF = "REF"; //reserved
238: static final String T_REFERENCES = "REFERENCES"; //reserved
239: static final String T_REFERENCING = "REFERENCING"; //reserved
240: static final String T_RELEASE = "RELEASE"; //reserved
241: static final String T_REPEAT = "REPEAT"; //reserved
242: static final String T_RESIGNAL = "RESIGNAL"; //reserved
243: static final String T_RESULT = "RESULT"; //reserved
244: static final String T_RETURN = "RETURN"; //reserved
245: static final String T_RETURNS = "RETURNS"; //reserved
246: static final String T_REVOKE = "REVOKE"; //reserved
247: static final String T_RIGHT = "RIGHT"; //reserved
248: static final String T_ROLLBACK = "ROLLBACK"; //reserved
249: static final String T_ROLLUP = "ROLLUP"; //reserved
250: static final String T_ROW = "ROW"; //reserved
251: static final String T_ROWS = "ROWS"; //reserved
252: static final String T_SAVEPOINT = "SAVEPOINT"; //reserved
253: static final String T_SCOPE = "SCOPE"; //reserved
254: static final String T_SCROLL = "SCROLL"; //reserved
255: static final String T_SECOND = "SECOND"; //reserved
256: static final String T_SEARCH = "SEARCH"; //reserved
257: static final String T_SELECT = "SELECT"; //reserved
258: static final String T_SENSITIVE = "SENSITIVE"; //reserved
259: static final String T_SESSION_USER = "SESSION_USER"; //reserved
260: public static final String T_SET = "SET"; //reserved
261: static final String T_SIGNAL = "SIGNAL"; //reserved
262: static final String T_SIMILAR = "SIMILAR"; //reserved
263: static final String T_SMALLINT = "SMALLINT"; //reserved
264: static final String T_SOME = "SOME"; //reserved
265: static final String T_SPECIFIC = "SPECIFIC"; //reserved
266: static final String T_SPECIFICTYPE = "SPECIFICTYPE"; //reserved
267: static final String T_SQL = "SQL"; //reserved
268: static final String T_SQLEXCEPTION = "SQLEXCEPTION"; //reserved
269: static final String T_SQLSTATE = "SQLSTATE"; //reserved
270: static final String T_SQLWARNING = "SQLWARNING"; //reserved
271: static final String T_START = "START"; //reserved
272: static final String T_STATIC = "STATIC"; //reserved
273: static final String T_SUBMULTISET = "SUBMULTISET"; //reserved
274: static final String T_SYMMETRIC = "SYMMETRIC"; //reserved
275: static final String T_SYSTEM = "SYSTEM"; //reserved
276: static final String T_SYSTEM_USER = "SYSTEM_USER"; //reserved
277: public static final String T_TABLE = "TABLE"; //reserved
278: static final String T_TABLESAMPLE = "TABLESAMPLE"; //reserved
279: static final String T_THEN = "THEN"; //reserved
280: static final String T_TIME = "TIME"; //reserved
281: static final String T_TIMESTAMP = "TIMESTAMP"; //reserved
282: static final String T_TIMEZONE_HOUR = "TIMEZONE_HOUR"; //reserved
283: static final String T_TIMEZONE_MINUTE = "TIMEZONE_MINUTE"; //reserved
284: static final String T_TO = "TO"; //reserved
285: static final String T_TRAILING = "TRAILING"; //reserved
286: static final String T_TRANSLATION = "TRANSLATION"; //reserved
287: static final String T_TREAT = "TREAT"; //reserved
288: static final String T_TRIGGER = "TRIGGER"; //reserved
289: static final String T_TRUE = "TRUE"; //reserved
290: static final String T_UNDO = "UNDO"; //reserved
291: static final String T_UNION = "UNION"; //reserved
292: static final String T_UNIQUE = "UNIQUE"; //reserved
293: static final String T_UNKNOWN = "UNKNOWN"; //reserved
294: static final String T_UNNEST = "UNNEST"; //reserved
295: static final String T_UNTIL = "UNTIL"; //reserved
296: static final String T_UPDATE = "UPDATE"; //reserved
297: static final String T_USER = "USER"; //reserved
298: static final String T_USING = "USING"; //reserved
299: static final String T_VALUE = "VALUE"; //reserved
300: static final String T_VALUES = "VALUES"; //reserved
301: static final String T_VARCHAR = "VARCHAR"; //reserved
302: static final String T_VARYING = "VARYING"; //reserved
303: static final String T_WHEN = "WHEN"; //reserved
304: static final String T_WHENEVER = "WHENEVER"; //reserved
305: static final String T_WHERE = "WHERE"; //reserved
306: static final String T_WHILE = "WHILE"; //reserved
307: static final String T_WINDOW = "WINDOW"; //reserved
308: static final String T_WITH = "WITH"; //reserved
309: static final String T_WITHIN = "WITHIN"; //reserved
310: static final String T_WITHOUT = "WITHOUT"; //reserved
311: static final String T_YEAR = "YEAR"; //reserved
312:
313: // other tokens
314: static final String T_ALWAYS = "ALWAYS";
315: static final String T_ACTION = "ACTION";
316: static final String T_ADMIN = "ADMIN";
317: static final String T_AFTER = "AFTER";
318: static final String T_ALIAS = "ALIAS";
319: static final String T_ASC = "ASC";
320: static final String T_AUTOCOMMIT = "AUTOCOMMIT";
321: static final String T_AVG = "AVG";
322: static final String T_BACKUP = "BACKUP";
323: static final String T_BEFORE = "BEFORE";
324: static final String T_CACHED = "CACHED";
325: static final String T_CASCADE = "CASCADE";
326: static final String T_CASEWHEN = "CASEWHEN";
327: static final String T_CHECKPOINT = "CHECKPOINT";
328: static final String T_CLASS = "CLASS";
329: static final String T_COALESCE = "COALESCE";
330: static final String T_COLLATION = "COLLATION";
331: static final String T_COMPACT = "COMPACT";
332: public static final String T_COMPRESSED = "COMPRESSED";
333: static final String T_CONVERT = "CONVERT";
334: static final String T_COUNT = "COUNT";
335: static final String T_DATABASE = "DATABASE";
336: static final String T_DEFRAG = "DEFRAG";
337: static final String T_DESC = "DESC";
338: static final String T_EVERY = "EVERY";
339: static final String T_EXPLAIN = "EXPLAIN";
340: static final String T_EXTRACT = "EXTRACT";
341: static final String T_GENERATED = "GENERATED";
342: static final String T_IFNULL = "IFNULL";
343: static final String T_IGNORECASE = "IGNORECASE";
344: static final String T_IMMEDIATELY = "IMMEDIATELY";
345: static final String T_INCREMENT = "INCREMENT";
346: static final String T_INDEX = "INDEX";
347: static final String T_INITIAL = "INITIAL";
348: static final String T_KEY = "KEY";
349: static final String T_LIMIT = "LIMIT";
350: static final String T_LOGSIZE = "LOGSIZE";
351: static final String T_MAX = "MAX";
352: static final String T_MAXROWS = "MAXROWS";
353: static final String T_MEMORY = "MEMORY";
354: static final String T_MERGE = "MERGE";
355: static final String T_MIN = "MIN";
356: static final String T_MINUS = "MINUS";
357: static final String T_NOW = "NOW";
358: static final String T_NOWAIT = "NOWAIT";
359: static final String T_NULLIF = "NULLIF";
360: static final String T_NVL = "NVL";
361: static final String T_OFFSET = "OFFSET";
362: static final String T_PASSWORD = "PASSWORD";
363: public static final String T_SCHEMA = "SCHEMA";
364: static final String T_PLAN = "PLAN";
365: static final String T_PRESERVE = "PRESERVE";
366: static final String T_PRIVILEGES = "PRIVILEGES";
367: static final String T_POSITION = "POSITION";
368: static final String T_PROPERTY = "PROPERTY";
369: static final String T_PUBLIC = "PUBLIC";
370: static final String T_QUEUE = "QUEUE";
371: static final String T_READONLY = "READONLY";
372: static final String T_REFERENTIAL_INTEGRITY = "REFERENTIAL_INTEGRITY";
373: static final String T_RENAME = "RENAME";
374: static final String T_RESTART = "RESTART";
375: static final String T_RESTRICT = "RESTRICT";
376: static final String T_ROLE = "ROLE";
377: static final String T_SCRIPT = "SCRIPT";
378: static final String T_SCRIPTFORMAT = "SCRIPTFORMAT";
379: static final String T_SEQUENCE = "SEQUENCE";
380: static final String T_SHUTDOWN = "SHUTDOWN";
381: public static final String T_SOURCE = "SOURCE";
382: static final String T_STDDEV_POP = "STDDEV_POP";
383: static final String T_STDDEV_SAMP = "STDDEV_SAMP";
384: static final String T_SUBSTRING = "SUBSTRING";
385: static final String T_SUM = "SUM";
386: static final String T_SYSDATE = "SYSDATE";
387: static final String T_TEMP = "TEMP";
388: static final String T_TEMPORARY = "TEMPORARY";
389: public static final String T_TEXT = "TEXT";
390: static final String T_TODAY = "TODAY";
391: static final String T_TOP = "TOP";
392: static final String T_TRIM = "TRIM";
393: static final String T_VAR_POP = "VAR_POP";
394: static final String T_VAR_SAMP = "VAR_SAMP";
395: static final String T_VIEW = "VIEW";
396: static final String T_WORK = "WORK";
397: static final String T_WRITE_DELAY = "WRITE_DELAY";
398: public static final String T_OFF = "OFF";
399:
400: // SQL 200n token values
401: static final int ADD = 1;
402: static final int ALL = 2;
403: static final int ALLOCATE = 3;
404: static final int ALTER = 4;
405: static final int AND = 5;
406: static final int ANY = 6;
407: static final int ARE = 7;
408: static final int ARRAY = 8;
409: static final int AS = 9;
410: static final int ASENSITIVE = 10;
411: static final int ASYMMETRIC = 11;
412: static final int AT = 12;
413: static final int ATOMIC = 13;
414: static final int AUTHORIZATION = 14;
415: static final int BEGIN = 15;
416: static final int BETWEEN = 16;
417: static final int BIGINT = 17;
418: static final int BINARY = 18;
419: static final int BLOB = 19;
420: static final int BOOLEAN = 20;
421: static final int BOTH = 21;
422: static final int BY = 22;
423: public static final int CALL = 23;
424: static final int CALLED = 24;
425: static final int CASCADED = 25;
426: static final int CASE = 26;
427: static final int CAST = 27;
428: static final int CHAR = 28;
429: static final int CHARACTER = 29;
430: static final int CHECK = 30;
431: static final int CLOB = 31;
432: static final int CLOSE = 32;
433: static final int COLLATE = 33;
434: static final int COLUMN = 34;
435: static final int COMMIT = 35;
436: static final int CONDITION = 36;
437: static final int CONNECT = 37;
438: static final int CONSTRAINT = 38;
439: static final int CONTINUE = 39;
440: static final int CORRESPONDING = 40;
441: static final int CREATE = 41;
442: static final int CROSS = 42;
443: static final int CUBE = 43;
444: static final int CURRENT = 44;
445: static final int CURRENT_DATE = 45;
446: static final int CURRENT_DEFAULT_TRANSFORM_GRO = 46;
447: static final int CURRENT_PATH = 47;
448: static final int CURRENT_ROLE = 48;
449: static final int CURRENT_TIME = 49;
450: static final int CURRENT_TIMESTAMP = 50;
451: static final int CURRENT_TRANSFORM_GROUP_FOR_T = 51;
452: static final int CURRENT_USER = 52;
453: static final int CURSOR = 53;
454: static final int CYCLE = 54;
455: static final int DATE = 55;
456: static final int DAY = 56;
457: static final int DEALLOCATE = 57;
458: static final int DEC = 58;
459: static final int DECIMAL = 59;
460: static final int DECLARE = 60;
461: static final int DEFAULT = 61;
462: public static final int DELETE = 62;
463: static final int DEREF = 63;
464: static final int DESCRIBE = 64;
465: static final int DETERMINISTIC = 65;
466: static final int DISCONNECT = 66;
467: static final int DISTINCT = 67;
468: static final int DO = 68;
469: static final int DOUBLE = 69;
470: static final int DROP = 70;
471: static final int DYNAMIC = 71;
472: static final int EACH = 72;
473: static final int ELEMENT = 73;
474: static final int ELSE = 74;
475: static final int ELSEIF = 75;
476: static final int END = 76;
477: static final int ESCAPE = 77;
478: static final int EXCEPT = 78;
479: static final int EXEC = 79;
480: static final int EXECUTE = 80;
481: static final int EXISTS = 81;
482: static final int EXIT = 82;
483: static final int EXTERNAL = 83;
484: static final int FALSE = 84;
485: static final int FETCH = 85;
486: static final int FILTER = 86;
487: static final int FLOAT = 87;
488: static final int FOR = 88;
489: static final int FOREIGN = 89;
490: static final int FREE = 90;
491: static final int FROM = 91;
492: static final int FULL = 92;
493: static final int FUNCTION = 93;
494: static final int GET = 94;
495: static final int GLOBAL = 95;
496: static final int GRANT = 96;
497: static final int GROUP = 97;
498: static final int GROUPING = 98;
499: static final int HANDLER = 99;
500: static final int HAVING = 100;
501: static final int HOLD = 101;
502: static final int HOUR = 102;
503: static final int IDENTITY = 103;
504: static final int IF = 104;
505: static final int IMMEDIATE = 105;
506: static final int IN = 106;
507: static final int INDICATOR = 107;
508: static final int INNER = 108;
509: static final int INOUT = 109;
510: static final int INPUT = 110;
511: static final int INSENSITIVE = 111;
512: public static final int INSERT = 112;
513: static final int INT = 113;
514: static final int INTEGER = 114;
515: static final int INTERSECT = 115;
516: static final int INTERVAL = 116;
517: static final int INTO = 117;
518: static final int IS = 118;
519: static final int ITERATE = 119;
520: static final int JOIN = 120;
521: static final int LANGUAGE = 121;
522: static final int LARGE = 122;
523: static final int LATERAL = 123;
524: static final int LEADING = 124;
525: static final int LEAVE = 125;
526: static final int LEFT = 126;
527: static final int LIKE = 127;
528: static final int LOCAL = 128;
529: static final int LOCALTIME = 129;
530: static final int LOCALTIMESTAMP = 130;
531: static final int LOOP = 131;
532: static final int MATCH = 132;
533: static final int MEMBER = 133;
534: static final int MERGE = 134;
535: static final int METHOD = 135;
536: static final int MINUTE = 136;
537: static final int MODIFIES = 137;
538: static final int MODULE = 138;
539: static final int MONTH = 139;
540: static final int MULTISET = 140;
541: static final int NATIONAL = 141;
542: static final int NATURAL = 142;
543: static final int NCHAR = 143;
544: static final int NCLOB = 144;
545: static final int NEW = 145;
546: static final int NO = 146;
547: static final int NONE = 147;
548: static final int NOT = 148;
549: static final int NULL = 149;
550: static final int NUMERIC = 150;
551: static final int OF = 151;
552: static final int OLD = 152;
553: static final int ON = 153;
554: static final int ONLY = 154;
555: static final int OPEN = 155;
556: static final int OR = 156;
557: static final int ORDER = 157;
558: static final int OUT = 158;
559: static final int OUTER = 159;
560: static final int OUTPUT = 160;
561: static final int OVER = 161;
562: static final int OVERLAPS = 162;
563: static final int PARAMETER = 163;
564: static final int PARTITION = 164;
565: static final int PRECISION = 165;
566: static final int PREPARE = 166;
567: static final int PRIMARY = 167;
568: static final int PROCEDURE = 168;
569: static final int RANGE = 169;
570: static final int READS = 170;
571: static final int REAL = 171;
572: static final int RECURSIVE = 172;
573: static final int REF = 173;
574: static final int REFERENCES = 174;
575: static final int REFERENCING = 175;
576: static final int RELEASE = 176;
577: static final int REPEAT = 177;
578: static final int RESIGNAL = 178;
579: static final int RESULT = 179;
580: static final int RETURN = 180;
581: static final int RETURNS = 181;
582: static final int REVOKE = 182;
583: static final int RIGHT = 183;
584: static final int ROLLBACK = 184;
585: static final int ROLLUP = 185;
586: static final int ROW = 186;
587: static final int ROWS = 187;
588: static final int SAVEPOINT = 188;
589: static final int SCOPE = 189;
590: static final int SCROLL = 190;
591: static final int SEARCH = 191;
592: static final int SECOND = 192;
593: public static final int SELECT = 193;
594: static final int SENSITIVE = 194;
595: static final int SESSION_USER = 195;
596: static final int SET = 196;
597: static final int SIGNAL = 197;
598: static final int SIMILAR = 198;
599: static final int SMALLINT = 199;
600: static final int SOME = 200;
601: static final int SPECIFIC = 201;
602: static final int SPECIFICTYPE = 202;
603: static final int SQL = 203;
604: static final int SQLEXCEPTION = 204;
605: static final int SQLSTATE = 205;
606: static final int SQLWARNING = 206;
607: static final int START = 207;
608: static final int STATIC = 208;
609: static final int SUBMULTISET = 209;
610: static final int SYMMETRIC = 210;
611: static final int SYSTEM = 211;
612: static final int SYSTEM_USER = 212;
613: static final int TABLE = 213;
614: static final int TABLESAMPLE = 214;
615: static final int THEN = 215;
616: static final int TIME = 216;
617: static final int TIMESTAMP = 217;
618: static final int TIMEZONE_HOUR = 218;
619: static final int TIMEZONE_MINUTE = 219;
620: static final int TO = 220;
621: static final int TRAILING = 221;
622: static final int TRANSLATION = 222;
623: static final int TREAT = 223;
624: static final int TRIGGER = 224;
625: static final int TRUE = 225;
626: static final int UNDO = 226;
627: static final int UNION = 227;
628: static final int UNIQUE = 228;
629: static final int UNKNOWN = 229;
630: static final int UNNEST = 220;
631: static final int UNTIL = 221;
632: public static final int UPDATE = 222;
633: static final int USER = 223;
634: static final int USING = 224;
635: static final int VALUE = 225;
636: static final int VALUES = 226;
637: static final int VARCHAR = 227;
638: static final int VARYING = 228;
639: static final int WHEN = 229;
640: static final int WHENEVER = 230;
641: static final int WHERE = 231;
642: static final int WHILE = 232;
643: static final int WINDOW = 233;
644: static final int WITH = 234;
645: static final int WITHIN = 235;
646: static final int WITHOUT = 236;
647: static final int YEAR = 237;
648:
649: // other token values used as switch cases
650: public static final int UNKNOWNTOKEN = -1;
651: static final int ALIAS = 300;
652: static final int AUTOCOMMIT = 301;
653: static final int CACHED = 302;
654: static final int CHECKPOINT = 303;
655: static final int EXPLAIN = 304;
656: static final int IGNORECASE = 305;
657: static final int INDEX = 306;
658: static final int LOGSIZE = 307;
659: static final int MATCHED = 308;
660: static final int MAXROWS = 309;
661: static final int MEMORY = 310;
662: static final int MINUS = 311;
663: static final int NEXT = 312;
664: static final int OPENBRACKET = 313;
665: static final int PASSWORD = 314;
666: static final int PLAN = 315;
667: static final int PROPERTY = 316;
668: static final int READONLY = 317;
669: static final int REFERENTIAL_INTEGRITY = 318;
670: static final int RENAME = 319;
671: static final int RESTART = 320;
672: static final int SCRIPT = 321;
673: static final int SCRIPTFORMAT = 322;
674: static final int SEMICOLON = 323;
675: static final int SEQUENCE = 324;
676: static final int SHUTDOWN = 325;
677: static final int SOURCE = 326;
678: static final int TEMP = 327;
679: static final int TEXT = 328;
680: static final int VIEW = 329;
681: static final int WRITE_DELAY = 330;
682:
683: // added stuff
684: static final int VAR_POP = 330;
685: static final int VAR_SAMP = 331;
686: static final int STDDEV_POP = 332;
687: static final int STDDEV_SAMP = 333;
688: static final int DEFRAG = 334;
689: static final int INCREMENT = 335;
690: static final int TOCHAR = 336;
691: static final int DATABASE = 337;
692: static final int SCHEMA = 338;
693: static final int ROLE = 339;
694: static final int DOW = 340;
695: static final int INITIAL = 341;
696:
697: //
698: static {
699: commandSet = newCommandSet();
700: }
701:
702: /**
703: * Retrieves a new map from set of string tokens to numeric tokens for
704: * commonly encountered database command token occurences.
705: *
706: * @return a new map for the database command token set
707: */
708: private static IntValueHashMap newCommandSet() {
709:
710: IntValueHashMap commandSet;
711:
712: commandSet = new IntValueHashMap(67);
713:
714: commandSet.put(T_ADD, ADD);
715: commandSet.put(T_ALIAS, ALIAS);
716: commandSet.put(T_ALTER, ALTER);
717: commandSet.put(T_AUTOCOMMIT, AUTOCOMMIT);
718: commandSet.put(T_CACHED, CACHED);
719: commandSet.put(T_CALL, CALL);
720: commandSet.put(T_CHECK, CHECK);
721: commandSet.put(T_CHECKPOINT, CHECKPOINT);
722: commandSet.put(T_COLUMN, COLUMN);
723: commandSet.put(T_COMMIT, COMMIT);
724: commandSet.put(T_CONNECT, CONNECT);
725: commandSet.put(T_CONSTRAINT, CONSTRAINT);
726: commandSet.put(T_CREATE, CREATE);
727: commandSet.put(T_DATABASE, DATABASE);
728: commandSet.put(T_DELETE, DELETE);
729: commandSet.put(T_DEFRAG, DEFRAG);
730: commandSet.put(T_DISCONNECT, DISCONNECT);
731: commandSet.put(T_DROP, DROP);
732: commandSet.put(T_EXCEPT, EXCEPT);
733: commandSet.put(T_EXPLAIN, EXPLAIN);
734: commandSet.put(T_FOREIGN, FOREIGN);
735: commandSet.put(T_GRANT, GRANT);
736: commandSet.put(T_IGNORECASE, IGNORECASE);
737: commandSet.put(T_INCREMENT, INCREMENT);
738: commandSet.put(T_INDEX, INDEX);
739: commandSet.put(T_INITIAL, INITIAL);
740: commandSet.put(T_INSERT, INSERT);
741: commandSet.put(T_INTERSECT, INTERSECT);
742: commandSet.put(T_LOGSIZE, LOGSIZE);
743: commandSet.put(T_MAXROWS, MAXROWS);
744: commandSet.put(T_MEMORY, MEMORY);
745: commandSet.put(T_MINUS, MINUS);
746: commandSet.put(T_NEXT, NEXT);
747: commandSet.put(T_NOT, NOT);
748: commandSet.put(T_OPENBRACKET, OPENBRACKET);
749: commandSet.put(T_PASSWORD, PASSWORD);
750: commandSet.put(T_PLAN, PLAN);
751: commandSet.put(T_PRIMARY, PRIMARY);
752: commandSet.put(T_PROPERTY, PROPERTY);
753: commandSet.put(T_READONLY, READONLY);
754: commandSet.put(T_REFERENTIAL_INTEGRITY, REFERENTIAL_INTEGRITY);
755: commandSet.put(T_RELEASE, RELEASE);
756: commandSet.put(T_RENAME, RENAME);
757: commandSet.put(T_RESTART, RESTART);
758: commandSet.put(T_REVOKE, REVOKE);
759: commandSet.put(T_ROLE, ROLE);
760: commandSet.put(T_ROLLBACK, ROLLBACK);
761: commandSet.put(T_SAVEPOINT, SAVEPOINT);
762: commandSet.put(T_SCRIPT, SCRIPT);
763: commandSet.put(T_SCRIPTFORMAT, SCRIPTFORMAT);
764: commandSet.put(T_SELECT, SELECT);
765: commandSet.put(T_SEMICOLON, SEMICOLON);
766: commandSet.put(T_SEQUENCE, SEQUENCE);
767: commandSet.put(T_SET, SET);
768: commandSet.put(T_SHUTDOWN, SHUTDOWN);
769: commandSet.put(T_SOURCE, SOURCE);
770: commandSet.put(T_TABLE, TABLE);
771: commandSet.put(T_TEMP, TEMP);
772: commandSet.put(T_TEXT, TEXT);
773: commandSet.put(T_TRIGGER, TRIGGER);
774: commandSet.put(T_UNIQUE, UNIQUE);
775: commandSet.put(T_UPDATE, UPDATE);
776: commandSet.put(T_UNION, UNION);
777: commandSet.put(T_USER, USER);
778: commandSet.put(T_VALUES, VALUES);
779: commandSet.put(T_VIEW, VIEW);
780: commandSet.put(T_WRITE_DELAY, WRITE_DELAY);
781: commandSet.put(T_SCHEMA, SCHEMA);
782:
783: return commandSet;
784: }
785:
786: public static int get(String token) {
787: return commandSet.get(token, -1);
788: }
789:
790: private static HashSet keywords;
791: static IntValueHashMap valueTokens;
792:
793: static {
794:
795: // literals not allowed as table / column names
796: keywords = new HashSet(67);
797:
798: // fredt - if we add MONTH, DAY, YEAR etc. MONTH(), DAY() et al will no longer work
799: // following tokens are values
800:
801: /* "FALSE",*/
802: /* "TRUE",*/
803: /* "NULL", */
804:
805: /** @todo perhaps rename LEFT() */
806:
807: // following token is excluded to allow LEFT() function to work
808: /* "LEFT" ,*/
809: String[] keyword = { Token.T_AS, Token.T_AND, Token.T_ALL,
810: Token.T_ANY, Token.T_AVG, Token.T_BY, Token.T_BETWEEN,
811: Token.T_BOTH, Token.T_CALL, Token.T_CASE,
812: Token.T_CASEWHEN, Token.T_CAST, Token.T_CONVERT,
813: Token.T_COUNT, Token.T_COALESCE, Token.T_DISTINCT,
814: Token.T_ELSE, Token.T_END, Token.T_EVERY,
815: Token.T_EXISTS, Token.T_EXCEPT, Token.T_EXTRACT,
816: Token.T_FOR, Token.T_FROM, Token.T_GROUP,
817: Token.T_HAVING, Token.T_IF, Token.T_INTO,
818: Token.T_IFNULL, Token.T_IS, Token.T_IN,
819: Token.T_INTERSECT, Token.T_JOIN, Token.T_INNER,
820: Token.T_LEADING, Token.T_LIKE, Token.T_MAX,
821: Token.T_MIN, Token.T_NEXT, Token.T_NULLIF, Token.T_NOT,
822: Token.T_NVL, Token.T_MINUS, Token.T_ON, Token.T_ORDER,
823: Token.T_OR, Token.T_OUTER, Token.T_POSITION,
824: Token.T_PRIMARY, Token.T_SELECT, Token.T_SET,
825: Token.T_SOME, Token.T_STDDEV_POP, Token.T_STDDEV_SAMP,
826: Token.T_SUBSTRING, Token.T_SUM, Token.T_THEN,
827: Token.T_TO, Token.T_TRAILING, Token.T_TRIM,
828: Token.T_UNIQUE, Token.T_UNION, Token.T_VALUES,
829: Token.T_VAR_POP, Token.T_VAR_SAMP, Token.T_WHEN,
830: Token.T_WHERE, };
831:
832: for (int i = 0; i < keyword.length; i++) {
833: keywords.add(keyword[i]);
834: }
835: }
836:
837: public static boolean isKeyword(String token) {
838: return keywords.contains(token);
839: }
840: }
|