KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > el > parser > Token


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  *
21  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
22  */
/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
23 package com.sun.el.parser;
24
25 /**
26  * Describes the input token stream.
27  */

28
29 public class Token {
30
31   /**
32    * An integer that describes the kind of this token. This numbering
33    * system is determined by JavaCCParser, and a table of these numbers is
34    * stored in the file ...Constants.java.
35    */

36   public int kind;
37
38   /**
39    * beginLine and beginColumn describe the position of the first character
40    * of this token; endLine and endColumn describe the position of the
41    * last character of this token.
42    */

43   public int beginLine, beginColumn, endLine, endColumn;
44
45   /**
46    * The string image of the token.
47    */

48   public String JavaDoc image;
49
50   /**
51    * A reference to the next regular (non-special) token from the input
52    * stream. If this is the last token from the input stream, or if the
53    * token manager has not read tokens beyond this one, this field is
54    * set to null. This is true only if this token is also a regular
55    * token. Otherwise, see below for a description of the contents of
56    * this field.
57    */

58   public Token next;
59
60   /**
61    * This field is used to access special tokens that occur prior to this
62    * token, but after the immediately preceding regular (non-special) token.
63    * If there are no such special tokens, this field is set to null.
64    * When there are more than one such special token, this field refers
65    * to the last of these special tokens, which in turn refers to the next
66    * previous special token through its specialToken field, and so on
67    * until the first special token (whose specialToken field is null).
68    * The next fields of special tokens refer to other special tokens that
69    * immediately follow it (without an intervening regular token). If there
70    * is no such token, this field is null.
71    */

72   public Token specialToken;
73
74   /**
75    * Returns the image.
76    */

77   public String JavaDoc toString()
78   {
79      return image;
80   }
81
82   /**
83    * Returns a new Token object, by default. However, if you want, you
84    * can create and return subclass objects based on the value of ofKind.
85    * Simply add the cases to the switch for all those special cases.
86    * For example, if you have a subclass of Token called IDToken that
87    * you want to create if ofKind is ID, simlpy add something like :
88    *
89    * case MyParserConstants.ID : return new IDToken();
90    *
91    * to the following switch statement. Then you can cast matchedToken
92    * variable to the appropriate type and use it in your lexical actions.
93    */

94   public static final Token newToken(int ofKind)
95   {
96      switch(ofKind)
97      {
98        default : return new Token();
99      }
100   }
101
102 }
103
Popular Tags