KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > Token


1 /*
2  * FindBugs - Find bugs in Java programs
3  * Copyright (C) 2003,2004 University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs;
21
22 /**
23  * Simple token class.
24  *
25  * @author David Hovemeyer
26  * @see Tokenizer
27  */

28 public class Token {
29     /**
30      * End of file.
31      */

32     public static final int EOF = -1;
33
34     /**
35      * End of line.
36      */

37     public static final int EOL = -2;
38
39     /**
40      * An ordinary word, number, etc.
41      */

42     public static final int WORD = 0;
43
44     /**
45      * A string or character literal.
46      */

47     public static final int STRING = 1;
48
49     /**
50      * A single character token.
51      */

52     public static final int SINGLE = 2;
53
54     /**
55      * A comment.
56      */

57     public static final int COMMENT = 3;
58
59     private int kind;
60     private String JavaDoc lexeme;
61
62     /**
63      * Constructor.
64      *
65      * @param kind the kind of token
66      * @param lexeme the text value of the token
67      */

68     public Token(int kind, String JavaDoc lexeme) {
69         this.kind = kind;
70         this.lexeme = lexeme;
71     }
72
73     /**
74      * Constructor when there is no text.
75      * E.g., EOF and EOL.
76      *
77      * @param kind the kind of token
78      */

79     public Token(int kind) {
80         this.kind = kind;
81         this.lexeme = "";
82     }
83
84     /**
85      * Get the kind of token.
86      */

87     public int getKind() {
88         return kind;
89     }
90
91     /**
92      * Get the text value of the token.
93      */

94     public String JavaDoc getLexeme() {
95         return lexeme;
96     }
97 }
98
99 // vim:ts=4
100
Popular Tags