001 /* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
002 /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
003 /****************************************************************
004 * Licensed to the Apache Software Foundation (ASF) under one *
005 * or more contributor license agreements. See the NOTICE file *
006 * distributed with this work for additional information *
007 * regarding copyright ownership. The ASF licenses this file *
008 * to you under the Apache License, Version 2.0 (the *
009 * "License"); you may not use this file except in compliance *
010 * with the License. You may obtain a copy of the License at *
011 * *
012 * http://www.apache.org/licenses/LICENSE-2.0 *
013 * *
014 * Unless required by applicable law or agreed to in writing, *
015 * software distributed under the License is distributed on an *
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
017 * KIND, either express or implied. See the License for the *
018 * specific language governing permissions and limitations *
019 * under the License. *
020 ****************************************************************/
021 package org.apache.james.mime4j.field.address;
022
023 /**
024 * Describes the input token stream.
025 */
026
027 public class Token implements java.io.Serializable {
028
029 /**
030 * The version identifier for this Serializable class.
031 * Increment only if the <i>serialized</i> form of the
032 * class changes.
033 */
034 private static final long serialVersionUID = 1L;
035
036 /**
037 * An integer that describes the kind of this token. This numbering
038 * system is determined by JavaCCParser, and a table of these numbers is
039 * stored in the file ...Constants.java.
040 */
041 public int kind;
042
043 /** The line number of the first character of this Token. */
044 public int beginLine;
045 /** The column number of the first character of this Token. */
046 public int beginColumn;
047 /** The line number of the last character of this Token. */
048 public int endLine;
049 /** The column number of the last character of this Token. */
050 public int endColumn;
051
052 /**
053 * The string image of the token.
054 */
055 public String image;
056
057 /**
058 * A reference to the next regular (non-special) token from the input
059 * stream. If this is the last token from the input stream, or if the
060 * token manager has not read tokens beyond this one, this field is
061 * set to null. This is true only if this token is also a regular
062 * token. Otherwise, see below for a description of the contents of
063 * this field.
064 */
065 public Token next;
066
067 /**
068 * This field is used to access special tokens that occur prior to this
069 * token, but after the immediately preceding regular (non-special) token.
070 * If there are no such special tokens, this field is set to null.
071 * When there are more than one such special token, this field refers
072 * to the last of these special tokens, which in turn refers to the next
073 * previous special token through its specialToken field, and so on
074 * until the first special token (whose specialToken field is null).
075 * The next fields of special tokens refer to other special tokens that
076 * immediately follow it (without an intervening regular token). If there
077 * is no such token, this field is null.
078 */
079 public Token specialToken;
080
081 /**
082 * An optional attribute value of the Token.
083 * Tokens which are not used as syntactic sugar will often contain
084 * meaningful values that will be used later on by the compiler or
085 * interpreter. This attribute value is often different from the image.
086 * Any subclass of Token that actually wants to return a non-null value can
087 * override this method as appropriate.
088 */
089 public Object getValue() {
090 return null;
091 }
092
093 /**
094 * No-argument constructor
095 */
096 public Token() {}
097
098 /**
099 * Constructs a new token for the specified Image.
100 */
101 public Token(int kind)
102 {
103 this(kind, null);
104 }
105
106 /**
107 * Constructs a new token for the specified Image and Kind.
108 */
109 public Token(int kind, String image)
110 {
111 this.kind = kind;
112 this.image = image;
113 }
114
115 /**
116 * Returns the image.
117 */
118 public String toString()
119 {
120 return image;
121 }
122
123 /**
124 * Returns a new Token object, by default. However, if you want, you
125 * can create and return subclass objects based on the value of ofKind.
126 * Simply add the cases to the switch for all those special cases.
127 * For example, if you have a subclass of Token called IDToken that
128 * you want to create if ofKind is ID, simply add something like :
129 *
130 * case MyParserConstants.ID : return new IDToken(ofKind, image);
131 *
132 * to the following switch statement. Then you can cast matchedToken
133 * variable to the appropriate type and use sit in your lexical actions.
134 */
135 public static Token newToken(int ofKind, String image)
136 {
137 switch(ofKind)
138 {
139 default : return new Token(ofKind, image);
140 }
141 }
142
143 public static Token newToken(int ofKind)
144 {
145 return newToken(ofKind, null);
146 }
147
148 }
149 /* JavaCC - OriginalChecksum=c59aac072256badf8bacf5de1086bbb5 (do not edit this line) */