View Javadoc
1   /* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
2   /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=false */
3   /*
4    * #%L
5    * JsonParser.jj - mongodb-async-driver - Allanbank Consulting, Inc.
6    * %%
7    * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc.
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  package com.allanbank.mongodb.bson.json;
23  
24  /**
25   * Describes the input token stream.
26   */
27  
28  class Token implements java.io.Serializable {
29  
30    /**
31     * The version identifier for this Serializable class.
32     * Increment only if the <i>serialized</i> form of the
33     * class changes.
34     */
35    private static final long serialVersionUID = 1L;
36  
37    /**
38     * An integer that describes the kind of this token.  This numbering
39     * system is determined by JavaCCParser, and a table of these numbers is
40     * stored in the file ...Constants.java.
41     */
42    public int kind;
43  
44    /** The line number of the first character of this Token. */
45    public int beginLine;
46    /** The column number of the first character of this Token. */
47    public int beginColumn;
48    /** The line number of the last character of this Token. */
49    public int endLine;
50    /** The column number of the last character of this Token. */
51    public int endColumn;
52  
53    /**
54     * The string image of the token.
55     */
56    public String image;
57  
58    /**
59     * A reference to the next regular (non-special) token from the input
60     * stream.  If this is the last token from the input stream, or if the
61     * token manager has not read tokens beyond this one, this field is
62     * set to null.  This is true only if this token is also a regular
63     * token.  Otherwise, see below for a description of the contents of
64     * this field.
65     */
66    public Token next;
67  
68    /**
69     * This field is used to access special tokens that occur prior to this
70     * token, but after the immediately preceding regular (non-special) token.
71     * If there are no such special tokens, this field is set to null.
72     * When there are more than one such special token, this field refers
73     * to the last of these special tokens, which in turn refers to the next
74     * previous special token through its specialToken field, and so on
75     * until the first special token (whose specialToken field is null).
76     * The next fields of special tokens refer to other special tokens that
77     * immediately follow it (without an intervening regular token).  If there
78     * is no such token, this field is null.
79     */
80    public Token specialToken;
81  
82    /**
83     * An optional attribute value of the Token.
84     * Tokens which are not used as syntactic sugar will often contain
85     * meaningful values that will be used later on by the compiler or
86     * interpreter. This attribute value is often different from the image.
87     * Any subclass of Token that actually wants to return a non-null value can
88     * override this method as appropriate.
89     */
90    public Object getValue() {
91      return null;
92    }
93  
94    /**
95     * No-argument constructor
96     */
97    public Token() {}
98  
99    /**
100    * Constructs a new token for the specified Image.
101    */
102   public Token(int kind)
103   {
104     this(kind, null);
105   }
106 
107   /**
108    * Constructs a new token for the specified Image and Kind.
109    */
110   public Token(int kind, String image)
111   {
112     this.kind = kind;
113     this.image = image;
114   }
115 
116   /**
117    * Returns the image.
118    */
119   public String toString()
120   {
121     return image;
122   }
123 
124   /**
125    * Returns a new Token object, by default. However, if you want, you
126    * can create and return subclass objects based on the value of ofKind.
127    * Simply add the cases to the switch for all those special cases.
128    * For example, if you have a subclass of Token called IDToken that
129    * you want to create if ofKind is ID, simply add something like :
130    *
131    *    case MyParserConstants.ID : return new IDToken(ofKind, image);
132    *
133    * to the following switch statement. Then you can cast matchedToken
134    * variable to the appropriate type and use sit in your lexical actions.
135    */
136   public static Token newToken(int ofKind, String image)
137   {
138     switch(ofKind)
139     {
140       default : return new Token(ofKind, image);
141     }
142   }
143 
144   public static Token newToken(int ofKind)
145   {
146     return newToken(ofKind, null);
147   }
148 
149 }
150 /* JavaCC - OriginalChecksum=07da52b28f04f6fa1011669ca2adddbc (do not edit this line) */