KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > hql > ast > HqlToken


1 // $Id: HqlToken.java,v 1.2 2004/08/15 17:03:43 pgmjsd Exp $
2
package org.hibernate.hql.ast;
3
4 /**
5  * A custom token class for the HQL grammar.
6  * <p><i>NOTE:<i> This class must be public becuase it is instantiated by the ANTLR library. Ignore any suggestions
7  * by various code 'analyzers' about this class being package local.</p>
8  */

9 public class HqlToken extends antlr.CommonToken {
10     /**
11      * True if this token could be an identifier. *
12      */

13     private boolean possibleID = false;
14     /**
15      * The previous token type. *
16      */

17     private int tokenType;
18
19     /**
20      * Returns true if the token could be an identifier.
21      *
22      * @return True if the token could be interpreted as in identifier,
23      * false if not.
24      */

25     public boolean isPossibleID() {
26         return possibleID;
27     }
28
29     /**
30      * Sets the type of the token, remembering the previous type.
31      *
32      * @param t The new token type.
33      */

34     public void setType(int t) {
35         this.tokenType = getType();
36         super.setType( t );
37     }
38
39     /**
40      * Returns the previous token type.
41      *
42      * @return int - The old token type.
43      */

44     private int getPreviousType() {
45         return tokenType;
46     }
47
48     /**
49      * Set to true if this token can be interpreted as an identifier,
50      * false if not.
51      *
52      * @param possibleID True if this is a keyword/identifier, false if not.
53      */

54     public void setPossibleID(boolean possibleID) {
55         this.possibleID = possibleID;
56     }
57
58     /**
59      * Returns a string representation of the object.
60      *
61      * @return String - The debug string.
62      */

63     public String JavaDoc toString() {
64         return "[\""
65                 + getText()
66                 + "\",<" + getType() + "> previously: <" + getPreviousType() + ">,line="
67                 + line + ",col="
68                 + col + ",possibleID=" + possibleID + "]";
69     }
70
71 }
72
Popular Tags