KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > lucene > html > Token


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: Token.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.lucene.html;
21
22
23 /**
24  * Describes the input token stream.
25  */

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

31     public int kind;
32
33     /**
34      * beginLine and beginColumn describe the position of the first character of this token;
35      * endLine and endColumn describe the position of the last character of this token.
36      */

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

43     public int beginColumn;
44
45     /**
46      * beginLine and beginColumn describe the position of the first character of this token;
47      * endLine and endColumn describe the position of the last character of this token.
48      */

49     public int endLine;
50
51     /**
52      * beginLine and beginColumn describe the position of the first character of this token;
53      * endLine and endColumn describe the position of the last character of this token.
54      */

55     public int endColumn;
56
57     /** The string image of the token. */
58     public String JavaDoc image;
59
60     /**
61      * A reference to the next regular (non-special) token from the input stream. If this is the
62      * last token from the input stream, or if the token manager has not read tokens beyond this
63      * one, this field is set to null. This is true only if this token is also a regular token.
64      * Otherwise, see below for a description of the contents of this field.
65      */

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

78     public Token specialToken;
79
80     /**
81      * Returns the image.
82      *
83      * @return DOCUMENT ME!
84      */

85     public final String JavaDoc toString() {
86         return image;
87     }
88
89     /**
90      * Returns a new Token object, by default. However, if you want, you can create and return
91      * subclass objects based on the value of ofKind. Simply add the cases to the switch for all
92      * those special cases. For example, if you have a subclass of Token called IDToken that you
93      * want to create if ofKind is ID, simlpy add something like : case MyParserConstants.ID :
94      * return new IDToken(); to the following switch statement. Then you can cast matchedToken
95      * variable to the appropriate type and use it in your lexical actions.
96      *
97      * @param ofKind DOCUMENT ME!
98      *
99      * @return DOCUMENT ME!
100      */

101     public static final Token newToken(int ofKind) {
102         switch (ofKind) {
103         default:
104             return new Token();
105         }
106     }
107 }
108
Popular Tags