01: package org.apache.torque.engine.sql;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: /**
23: * A single token returned by SQLScanner. This class is used internally
24: * by SQLScanner and you should probably never need to create objects
25: * of this class unless you are working on SQLScanner.
26: *
27: * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
28: * @version $Id: Token.java 473814 2006-11-11 22:30:30Z tv $
29: */
30:
31: public class Token {
32: /** string representation */
33: private String str;
34: /** line number */
35: private int line;
36: /** column number */
37: private int col;
38:
39: /**
40: * Creates a new token without positioning.
41: *
42: * @param str string representation
43: */
44: public Token(String str) {
45: this (str, 0, 0);
46: }
47:
48: /**
49: * Creates a new token with positioning settings.
50: *
51: * @param str string representation
52: * @param line line number
53: * @param col column number
54: */
55: public Token(String str, int line, int col) {
56: this .str = str;
57: this .line = line;
58: this .col = col;
59: }
60:
61: /**
62: * Returns the string representation of this token.
63: *
64: * @return the string representation
65: */
66: public String getStr() {
67: return str;
68: }
69:
70: /**
71: * Get the line number of this token.
72: *
73: * @return the line number
74: */
75: public int getLine() {
76: return line;
77: }
78:
79: /**
80: * Get the column number of this token.
81: *
82: * @return the column number
83: */
84: public int getCol() {
85: return col;
86: }
87:
88: /**
89: * The same as getStr()
90: *
91: * @return the string representation
92: */
93: public String toString() {
94: return str;
95: }
96: }
|