01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08:
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: package antlr;
21:
22: /**
23: *
24: * @author gorrus
25: */
26: public class TokenImpl implements Token {
27: // each Token has at least a token type
28: protected int type = INVALID_TYPE;
29:
30: // the illegal token object
31: public static Token badToken = new TokenImpl(INVALID_TYPE,
32: "<no text>");
33:
34: public static Token EOF_TOKEN = new TokenImpl(EOF_TYPE, "<EOF>");
35:
36: public TokenImpl() {
37: }
38:
39: public TokenImpl(int t) {
40: type = t;
41: }
42:
43: public TokenImpl(int t, String txt) {
44: type = t;
45: setText(txt);
46: }
47:
48: public int getColumn() {
49: return 0;
50: }
51:
52: public int getLine() {
53: return 0;
54: }
55:
56: public String getFilename() {
57: return null;
58: }
59:
60: public void setFilename(String name) {
61: }
62:
63: public String getText() {
64: return "<no text>";
65: }
66:
67: public void setText(String t) {
68: }
69:
70: public void setColumn(int c) {
71: }
72:
73: public void setLine(int l) {
74: }
75:
76: public int getType() {
77: return type;
78: }
79:
80: public void setType(int t) {
81: type = t;
82: }
83:
84: public String toString() {
85: return "[\"" + getText() + "\",<" + getType() + ">]";
86: }
87: }
|