1 package org.apache.velocity.util.introspection;
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 * Little class to carry in info such as template name, line and column
24 * for information error reporting from the uberspector implementations
25 *
26 * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
27 * @version $Id: Info.java 463298 2006-10-12 16:10:32Z henning $
28 */
29 public class Info
30 {
31 private int line;
32 private int column;
33 private String templateName;
34
35 /**
36 * @param source Usually a template name.
37 * @param line The line number from <code>source</code>.
38 * @param column The column number from <code>source</code>.
39 */
40 public Info(String source, int line, int column)
41 {
42 this.templateName = source;
43 this.line = line;
44 this.column = column;
45 }
46
47 /**
48 * Force callers to set the location information.
49 */
50 private Info()
51 {
52 }
53
54 /**
55 * @return The template name.
56 */
57 public String getTemplateName()
58 {
59 return templateName;
60 }
61
62 /**
63 * @return The line number.
64 */
65 public int getLine()
66 {
67 return line;
68 }
69
70 /**
71 * @return The column number.
72 */
73 public int getColumn()
74 {
75 return column;
76 }
77
78 /**
79 * Formats a textual representation of this object as <code>SOURCE
80 * [line X, column Y]</code>.
81 *
82 * @return String representing this object.
83 */
84 public String toString()
85 {
86 return getTemplateName() + " [line " + getLine() + ", column " +
87 getColumn() + ']';
88 }
89 }