View Javadoc
1   /* Generated by: ParserGeneratorCC: Do not edit this line. Token.java Version 1.1 */
2   /* ParserGeneratorCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COLUMN=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
3   package org.apache.commons.jexl3.parser;
4   
5   /**
6    * Describes the input token stream.
7    */
8   
9   public class Token 
10  implements java.io.Serializable {
11    /**
12     * The version identifier for this Serializable class.
13     * Increment only if the <i>serialized</i> form of the
14     * class changes.
15     */
16    private static final long serialVersionUID = 1L;
17  
18    /**
19     * An integer that describes the kind of this token.  This numbering
20     * system is determined by JavaCCParser, and a table of these numbers is
21     * stored in the file ...Constants.java.
22     */
23    public int kind;
24  
25    /** The line number of the first character of this Token. */
26    public int beginLine;
27    /** The column number of the first character of this Token. */
28    public int beginColumn;
29    /** The line number of the last character of this Token. */
30    public int endLine;
31    /** The column number of the last character of this Token. */
32    public int endColumn;
33  
34    /**
35     * The string image of the token.
36     */
37    public String image;
38  
39    /**
40     * A reference to the next regular (non-special) token from the input
41     * stream.  If this is the last token from the input stream, or if the
42     * token manager has not read tokens beyond this one, this field is
43     * set to null.  This is true only if this token is also a regular
44     * token.  Otherwise, see below for a description of the contents of
45     * this field.
46     */
47    public Token next;
48  
49    /**
50     * This field is used to access special tokens that occur prior to this
51     * token, but after the immediately preceding regular (non-special) token.
52     * If there are no such special tokens, this field is set to null.
53     * When there are more than one such special token, this field refers
54     * to the last of these special tokens, which in turn refers to the next
55     * previous special token through its specialToken field, and so on
56     * until the first special token (whose specialToken field is null).
57     * The next fields of special tokens refer to other special tokens that
58     * immediately follow it (without an intervening regular token).  If there
59     * is no such token, this field is null.
60     */
61    public Token specialToken;
62  
63    /**
64     * No-argument constructor
65     */
66    public Token() {}
67  
68    /**
69     * Constructs a new token for the specified Image.
70     */
71    public Token(final int nKind)
72    {
73      this(nKind, null);
74    }
75  
76    /**
77     * Constructs a new token for the specified Image and Kind.
78     */
79    public Token(final int nKind, final String sImage)
80    {
81      this.kind = nKind;
82      this.image = sImage;
83    }
84  
85    /**
86     * An optional attribute value of the Token.
87     * Tokens which are not used as syntactic sugar will often contain
88     * meaningful values that will be used later on by the compiler or
89     * interpreter. This attribute value is often different from the image.
90     * Any subclass of Token that actually wants to return a non-null value can
91     * override this method as appropriate.
92     */
93    public Object getValue() {
94      return null;
95    }
96  
97    /**
98     * Returns the image.
99     */
100   @Override
101   public String toString()
102   {
103     return image;
104   }
105 
106   /**
107    * Returns a new Token object, by default. However, if you want, you
108    * can create and return subclass objects based on the value of ofKind.
109    * Simply add the cases to the switch for all those special cases.
110    * For example, if you have a subclass of Token called IDToken that
111    * you want to create if ofKind is ID, simply add something like :
112    *
113    *    case MyParserConstants.ID : return new IDToken(ofKind, image);
114    *
115    * to the following switch statement. Then you can cast matchedToken
116    * variable to the appropriate type and use sit in your lexical actions.
117    */
118   public static Token newToken(int ofKind, String image)
119   {
120     switch(ofKind)
121     {
122       default : return new Token(ofKind, image);
123     }
124   }
125 
126   public static Token newToken(int ofKind)
127   {
128     return newToken(ofKind, null);
129   }
130 
131 }
132 /* ParserGeneratorCC - OriginalChecksum=5e5f51d13d543320fa2b6a4c81ab6bfe (do not edit this line) */