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