KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > commons > xml > parser > Token


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19
20
21 /* Generated By:JavaCC: Do not edit this line. Token.java Version 2.1 */
22 package org.openharmonise.commons.xml.parser;
23
24 /**
25  * Describes the input token stream.
26  */

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

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

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

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

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

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

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

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