View Javadoc

1   package org.apache.torque.engine.sql;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "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  {
33      /*** string representation */
34      private String str;
35      /*** line number */
36      private int line;
37      /*** column number */
38      private int col;
39  
40      /***
41       * Creates a new token without positioning.
42       *
43       * @param str string representation
44       */
45      public Token(String str)
46      {
47          this (str, 0, 0);
48      }
49  
50      /***
51       * Creates a new token with positioning settings.
52       *
53       * @param str string representation
54       * @param line line number
55       * @param col column number
56       */
57      public Token(String str, int line, int col)
58      {
59          this.str = str;
60          this.line = line;
61          this.col = col;
62      }
63  
64      /***
65       * Returns the string representation of this token.
66       *
67       * @return the string representation
68       */
69      public String getStr()
70      {
71          return str;
72      }
73  
74      /***
75       * Get the line number of this token.
76       *
77       * @return the line number
78       */
79      public int getLine()
80      {
81          return line;
82      }
83  
84      /***
85       * Get the column number of this token.
86       *
87       * @return the column number
88       */
89      public int getCol()
90      {
91          return col;
92      }
93  
94      /***
95       * The same as getStr()
96       *
97       * @return the string representation
98       */
99      public String toString()
100     {
101         return str;
102     }
103 }