Project Report: fawkez

Packagesummary org.jcoderz.phoenix.sqlparser

org.jcoderz.phoenix.sqlparser.TokenType

LineHitsNoteSource
1  /*
2   * $Id: TokenType.java 1011 2008-06-16 17:57:36Z amandel $
3   *
4   * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5   *
6   * Redistribution and use in source and binary forms, with or without
7   * modification, are permitted provided that the following conditions are
8   * met:
9   *
10   *    * Redistributions of source code must retain the above copyright
11   *      notice, this list of conditions and the following disclaimer.
12   *    * Redistributions in binary form must reproduce the above
13   *      copyright notice, this list of conditions and the following
14   *      disclaimer in the documentation and/or other materials
15   *      provided with the distribution.
16   *    * Neither the name of the jCoderZ.org Project nor the names of
17   *      its contributors may be used to endorse or promote products
18   *      derived from this software without specific prior written
19   *      permission.
20   *
21   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24   * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   */
33  package org.jcoderz.phoenix.sqlparser;
34  
35  
36  import java.io.ObjectStreamException;
37  import java.io.Serializable;
38  import java.util.Arrays;
39  import java.util.Collections;
40  import java.util.Map;
41  import java.util.HashMap;
42  import java.util.List;
43  
44  
45  /**
46   * Enumerated type of a token type.
47   *
48   * Instances of this class are immutable.
49   *
50   * The following token types are defined:
51   * <ul>
52   *    <li>TokenType.CREATE</li>
53   *    <li>TokenType.TABLE</li>
54   *    <li>TokenType.OPEN_PAREN</li>
55   *    <li>TokenType.CLOSE_PAREN</li>
56   *    <li>TokenType.IDENTIFIER</li>
57   *    <li>TokenType.COMMA</li>
58   *    <li>TokenType.SEMICOLON</li>
59   *    <li>TokenType.WHITESPACE</li>
60   *    <li>TokenType.NEWLINE</li>
61   *    <li>TokenType.STRING_LITERAL</li>
62   *    <li>TokenType.NUMERIC_LITERAL</li>
63   *    <li>TokenType.COMMENT</li>
64   *    <li>TokenType.NOT</li>
65   *    <li>TokenType.NULL</li>
66   *    <li>TokenType.CONSTRAINT</li>
67   *    <li>TokenType.PRIMARY</li>
68   *    <li>TokenType.KEY</li>
69   *    <li>TokenType.UNIQUE</li>
70   *    <li>TokenType.CHECK</li>
71   *    <li>TokenType.IN</li>
72   *    <li>TokenType.EOF</li>
73   * </ul>
74   *
75   * @author Michael Griffel
76   */
77  public final class TokenType
78          implements Serializable
79  {
80      private static final long serialVersionUID = 1L;
81  
82      /** The name of the token type */
83      private final transient String mName;
84  
85      /** Ordinal of next token type to be created */
86100     private static int sNextOrdinal = 0;
87  
88      /** Assign a ordinal to this token type */
89100     private final int mOrdinal = sNextOrdinal++;
90  
91      /** Maps a string representation to an enumerated value */
92100     private static final Map FROM_STRING = new HashMap();
93  
94      /** The token type create. */
95100     public static final TokenType CREATE = new TokenType("create");
96  
97      /** The token type table. */
98100     public static final TokenType TABLE = new TokenType("table");
99  
100      /** The token type open_paren. */
101100     public static final TokenType OPEN_PAREN = new TokenType("open_paren");
102  
103      /** The token type close_paren. */
104100     public static final TokenType CLOSE_PAREN = new TokenType("close_paren");
105  
106      /** The token type identifier. */
107100     public static final TokenType IDENTIFIER = new TokenType("identifier");
108  
109      /** The token type comma. */
110100     public static final TokenType COMMA = new TokenType("comma");
111  
112      /** The token type semicolon. */
113100     public static final TokenType SEMICOLON = new TokenType("semicolon");
114  
115      /** The token type slash. */
116100     public static final TokenType SLASH = new TokenType("slash");
117  
118      /** The token type whitespace. */
119100     public static final TokenType WHITESPACE = new TokenType("whitespace");
120  
121      /** The token type newline. */
122100     public static final TokenType NEWLINE = new TokenType("newline");
123  
124      /** The token type string_literal. */
125100     public static final TokenType STRING_LITERAL = new TokenType(
126              "string_literal");
127  
128      /** The token type numeric_literal. */
129100     public static final TokenType NUMERIC_LITERAL = new TokenType(
130              "numeric_literal");
131  
132      /** The token type comment. */
133100     public static final TokenType COMMENT = new TokenType("comment");
134  
135      /** The token type not. */
136100     public static final TokenType NOT = new TokenType("not");
137  
138      /** The token type null. */
139100     public static final TokenType NULL = new TokenType("null");
140  
141      /** The token type constraint. */
142100     public static final TokenType CONSTRAINT = new TokenType("constraint");
143  
144      /** The token type primary. */
145100     public static final TokenType PRIMARY = new TokenType("primary");
146  
147      /** The token type key. */
148100     public static final TokenType KEY = new TokenType("key");
149  
150      /** The token type unique. */
151100     public static final TokenType UNIQUE = new TokenType("unique");
152  
153      /** The token type check. */
154100     public static final TokenType CHECK = new TokenType("check");
155  
156      /** The token type in. */
157100     public static final TokenType IN = new TokenType("in");
158  
159      /** The token type eof. */
160100     public static final TokenType EOF = new TokenType("eof");
161  
162      /** The token type foreign. */
163100     public static final TokenType FOREIGN = new TokenType("foreign");
164  
165      /** The token type default. */
166100     public static final TokenType DEFAULT = new TokenType("default");
167  
168      /** The token type references. */
169100     public static final TokenType REFERENCES = new TokenType("references");
170  
171      /** The token type on. */
172100     public static final TokenType ON = new TokenType("on");
173  
174      /** The token type delete. */
175100     public static final TokenType DELETE = new TokenType("delete");
176  
177      /** The token type set. */
178100     public static final TokenType SET = new TokenType("set");
179  
180      /** The token type cascade. */
181100     public static final TokenType CASCADE = new TokenType("cascade");
182  
183      /** The token type enable. */
184100     public static final TokenType ENABLE = new TokenType("enable");
185  
186      /** The token type disable. */
187100     public static final TokenType DISABLE = new TokenType("disable");
188  
189      /** The token type alter. */
190100     public static final TokenType ALTER = new TokenType("alter");
191  
192      /** The token type drop. */
193100     public static final TokenType DROP = new TokenType("drop");
194  
195      /** The token type insert. */
196100     public static final TokenType INSERT = new TokenType("insert");
197  
198      /** The token type delete. */
199100     public static final TokenType SELECT = new TokenType("select");
200  
201      /** The token type index. */
202100     public static final TokenType INDEX = new TokenType("index");
203  
204      /** The token type bitmap. */
205100     public static final TokenType BITMAP = new TokenType("bitmap");
206  
207      /** The token type sequence. */
208100     public static final TokenType SEQUENCE = new TokenType("sequence");
209  
210      /** The token type increment. */
211100     public static final TokenType INCREMENT = new TokenType("increment");
212  
213100(1)    public static final TokenType BY = new TokenType("by");
214  
215100(2)    public static final TokenType START = new TokenType("start");
216  
217100(3)    public static final TokenType WITH = new TokenType("with");
218  
219100(4)    public static final TokenType MAXVALUE = new TokenType("maxvalue");
220  
221100(5)    public static final TokenType NOMAXVALUE = new TokenType("nomaxvalue");
222  
223100(6)    public static final TokenType MINVALUE = new TokenType("minvalue");
224  
225100(7)    public static final TokenType NOMINVALUE = new TokenType("nominvalue");
226  
227100(8)    public static final TokenType CYCLE = new TokenType("cycle");
228  
229100(9)    public static final TokenType NOCYCLE = new TokenType("nocycle");
230  
231100(10)    public static final TokenType CACHE = new TokenType("cache");
232  
233100(11)    public static final TokenType NOCACHE = new TokenType("nocache");
234  
235100(12)    public static final TokenType ORDER = new TokenType("order");
236  
237100(13)    public static final TokenType NOORDER = new TokenType("noorder");
238  
239100(14)    public static final TokenType OPERATOR = new TokenType("operator");
240  
241      /** Internal list of all available token types */
242100     private static final TokenType[] PRIVATE_VALUES = {TokenType.CREATE,
243              TokenType.TABLE, TokenType.OPEN_PAREN, TokenType.CLOSE_PAREN,
244              TokenType.IDENTIFIER, TokenType.COMMA, TokenType.SEMICOLON,
245              TokenType.SLASH, TokenType.WHITESPACE, TokenType.NEWLINE,
246              TokenType.STRING_LITERAL, TokenType.NUMERIC_LITERAL,
247              TokenType.COMMENT, TokenType.NOT, TokenType.NULL,
248              TokenType.CONSTRAINT, TokenType.PRIMARY, TokenType.KEY,
249              TokenType.UNIQUE, TokenType.CHECK, TokenType.IN, TokenType.EOF,
250              TokenType.FOREIGN, TokenType.DEFAULT, TokenType.REFERENCES,
251              TokenType.ON, TokenType.DELETE, TokenType.SET, TokenType.CASCADE,
252              TokenType.ENABLE, TokenType.DISABLE, TokenType.ALTER,
253              TokenType.DROP, TokenType.INSERT, TokenType.SELECT,
254              TokenType.INDEX, TokenType.BITMAP, TokenType.SEQUENCE,
255              TokenType.INCREMENT, TokenType.BY, TokenType.START, TokenType.WITH,
256              TokenType.MAXVALUE, TokenType.NOMAXVALUE, TokenType.MINVALUE,
257              TokenType.NOMINVALUE, TokenType.CYCLE, TokenType.NOCYCLE,
258              TokenType.CACHE, TokenType.NOCACHE, TokenType.ORDER,
259              TokenType.NOORDER, TokenType.OPERATOR};
260  
261      /** Immutable list of the token types. */
262100     public static final List VALUES = Collections.unmodifiableList(Arrays
263              .asList(PRIVATE_VALUES));
264  
265      /** Private Constructor */
266      private TokenType (String name)
267100     {
268100         mName = name;
269100         FROM_STRING.put(mName, this);
270100     }
271  
272      /**
273       * Creates a TokenType object from its int representation.
274       *
275       * @param i the int representation of the token type to be returned.
276       * @return the TokenType object represented by this int.
277       * @throws IllegalArgumentException If the assigned int value isn't
278       *      listed in the internal token type table
279       */
280      public static TokenType fromInt (int i)
281              throws IllegalArgumentException
282      {
283          try
284          {
2850             return PRIVATE_VALUES[i];
286          }
2870         catch (ArrayIndexOutOfBoundsException e)
288          {
2890             final IllegalArgumentException ex = new IllegalArgumentException(
290                      "Illegal int representation of TokenType");
2910             ex.initCause(e);
2920(15)            throw ex;
293          }
294      }
295  
296      /**
297       * Creates a TokenType object from its String representation.
298       *
299       * @param str the str representation of the token type to be returned.
300       * @return the TokenType object represented by this str.
301       * @throws IllegalArgumentException If the given str value isn't listed
302       *          in the internal token type table.
303       */
304      public static TokenType fromString (String str)
305              throws IllegalArgumentException
306      {
307100         final TokenType result = (TokenType) FROM_STRING.get(str);
308100         if (result == null)
309          {
310100(16)            throw new IllegalArgumentException(
311                      "Illegal string representation of TokenType");
312          }
313100         return result;
314      }
315  
316      /**
317       * Returns the int representation of this token type.
318       *
319       * @return the int representation of this token type.
320       */
321      public int toInt ()
322      {
3230         return mOrdinal;
324      }
325  
326      /**
327       * Returns the String representation of this token type.
328       *
329       * @return the String representation of this token type.
330       */
331      public String toString ()
332      {
333100         return mName;
334      }
335  
336      /**
337       * Resolves instances being deserialized to a single instance
338       * per token type.
339       */
340      private Object readResolve ()
341              throws ObjectStreamException
342      {
3430         return PRIVATE_VALUES[mOrdinal];
344      }
345  }

Findings in this File

f (17) Static variable definition in wrong order. Ok.
f (18) Static variable definition in wrong order. Ok.
f (19) Static variable definition in wrong order. Ok.
f (20) Variable access definition in wrong order. Ok.
f (21) Static variable definition in wrong order. Ok.
f (22) Variable access definition in wrong order. Ok.
f (23) Static variable definition in wrong order. Ok.
f (24) Variable access definition in wrong order. Ok.
f (25) Static variable definition in wrong order. Ok.
f (26) Variable access definition in wrong order. Ok.
f (27) Static variable definition in wrong order. Ok.
f (28) Variable access definition in wrong order. Ok.
f (29) Static variable definition in wrong order. Ok.
f (30) Variable access definition in wrong order. Ok.
f (31) Static variable definition in wrong order. Ok.
f (32) Variable access definition in wrong order. Ok.
f (33) Static variable definition in wrong order. Ok.
f (34) Variable access definition in wrong order. Ok.
f (35) Static variable definition in wrong order. Ok.
f (36) Variable access definition in wrong order. Ok.
f (37) Static variable definition in wrong order. Ok.
f (38) Variable access definition in wrong order. Ok.
f (39) Static variable definition in wrong order. Ok.
f (40) Variable access definition in wrong order. Ok.
f (41) Static variable definition in wrong order. Ok.
f (42) Variable access definition in wrong order. Ok.
f (43) Static variable definition in wrong order. Ok.
f (44) Variable access definition in wrong order. Ok.
f (45) Static variable definition in wrong order. Ok.
f (46) Variable access definition in wrong order. Ok.
f (47) Static variable definition in wrong order. Ok.
f (48) Variable access definition in wrong order. Ok.
f (49) Static variable definition in wrong order. Ok.
f (50) Variable access definition in wrong order. Ok.
f (51) Static variable definition in wrong order. Ok.
f (52) Variable access definition in wrong order. Ok.
f (53) Static variable definition in wrong order. Ok.
f (54) Variable access definition in wrong order. Ok.
f (55) Static variable definition in wrong order. Ok.
f (56) Variable access definition in wrong order. Ok.
f (57) Static variable definition in wrong order. Ok.
f (58) Variable access definition in wrong order. Ok.
f (59) Static variable definition in wrong order. Ok.
f (60) Variable access definition in wrong order. Ok.
f (61) Static variable definition in wrong order. Ok.
f (62) Variable access definition in wrong order. Ok.
f (63) Static variable definition in wrong order. Ok.
f (64) Variable access definition in wrong order. Ok.
f (65) Static variable definition in wrong order. Ok.
f (66) Variable access definition in wrong order. Ok.
f (67) Static variable definition in wrong order. Ok.
f (68) Variable access definition in wrong order. Ok.
f (69) Static variable definition in wrong order. Ok.
f (70) Variable access definition in wrong order. Ok.
f (71) Static variable definition in wrong order. Ok.
f (72) Variable access definition in wrong order. Ok.
f (73) Static variable definition in wrong order. Ok.
f (74) Variable access definition in wrong order. Ok.
f (75) Static variable definition in wrong order. Ok.
f (76) Variable access definition in wrong order. Ok.
f (77) Static variable definition in wrong order. Ok.
f (78) Variable access definition in wrong order. Ok.
f (79) Static variable definition in wrong order. Ok.
f (80) Variable access definition in wrong order. Ok.
f (81) Static variable definition in wrong order. Ok.
f (82) Variable access definition in wrong order. Ok.
f (83) Static variable definition in wrong order. Ok.
f (84) Variable access definition in wrong order. Ok.
f (85) Static variable definition in wrong order. Ok.
f (86) Variable access definition in wrong order. Ok.
f (87) Static variable definition in wrong order. Ok.
f (88) Variable access definition in wrong order. Ok.
f (89) Static variable definition in wrong order. Ok.
f (90) Variable access definition in wrong order. Ok.
f (91) Static variable definition in wrong order. Ok.
f (92) Variable access definition in wrong order. Ok.
f (93) Static variable definition in wrong order. Ok.
f (94) Variable access definition in wrong order. Ok.
f (95) Static variable definition in wrong order. Ok.
f (96) Variable access definition in wrong order. Ok.
f (97) Static variable definition in wrong order. Ok.
f (98) Variable access definition in wrong order. Ok.
f (99) Static variable definition in wrong order. Ok.
f (100) Variable access definition in wrong order. Ok.
f (101) Static variable definition in wrong order. Ok.
f (102) Variable access definition in wrong order. Ok.
f (103) Static variable definition in wrong order. Ok.
f (104) Variable access definition in wrong order. Ok.
f (105) Static variable definition in wrong order. Ok.
f (106) Variable access definition in wrong order. Ok.
f (107) Static variable definition in wrong order. Ok.
f (108) Variable access definition in wrong order. Ok.
f (109) Static variable definition in wrong order. Ok.
f (110) Variable access definition in wrong order. Ok.
f (111) Static variable definition in wrong order. Ok.
f (112) Variable access definition in wrong order. Ok.
f (113) Static variable definition in wrong order. Ok.
f (114) Variable access definition in wrong order. Ok.
f (115) Static variable definition in wrong order. Ok.
f (116) Variable access definition in wrong order. Ok.
f (117) Static variable definition in wrong order. Ok.
f (118) Variable access definition in wrong order. Ok.
f (119) Static variable definition in wrong order. Ok.
f (120) Variable access definition in wrong order. Ok.
f (121) Static variable definition in wrong order. Ok.
f (122) Variable access definition in wrong order. Ok.
f (123) Static variable definition in wrong order. Ok.
f (124) Variable access definition in wrong order. Ok.
f (125) Static variable definition in wrong order. Ok.
f (126) Static variable definition in wrong order. Ok.
f (127) Variable access definition in wrong order. Ok.
c (1) 213 : 5 Missing a Javadoc comment.
c (2) 215 : 5 Missing a Javadoc comment.
c (3) 217 : 5 Missing a Javadoc comment.
c (4) 219 : 5 Missing a Javadoc comment.
c (5) 221 : 5 Missing a Javadoc comment.
c (6) 223 : 5 Missing a Javadoc comment.
c (7) 225 : 5 Missing a Javadoc comment.
c (8) 227 : 5 Missing a Javadoc comment.
c (9) 229 : 5 Missing a Javadoc comment.
c (10) 231 : 5 Missing a Javadoc comment.
c (11) 233 : 5 Missing a Javadoc comment.
c (12) 235 : 5 Missing a Javadoc comment.
c (13) 237 : 5 Missing a Javadoc comment.
c (14) 239 : 5 Missing a Javadoc comment.
i (15) 292 : 0 method org.jcoderz.phoenix.sqlparser.TokenType.fromInt(int) throws exception with static message string
i (16) 310 : 0 method org.jcoderz.phoenix.sqlparser.TokenType.fromString(String) throws exception with static message string