01: package org.apache.velocity.util.introspection;
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: * 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: private int line;
31: private int column;
32: private String templateName;
33:
34: /**
35: * @param source Usually a template name.
36: * @param line The line number from <code>source</code>.
37: * @param column The column number from <code>source</code>.
38: */
39: public Info(String source, int line, int column) {
40: this .templateName = source;
41: this .line = line;
42: this .column = column;
43: }
44:
45: /**
46: * Force callers to set the location information.
47: */
48: private Info() {
49: }
50:
51: /**
52: * @return The template name.
53: */
54: public String getTemplateName() {
55: return templateName;
56: }
57:
58: /**
59: * @return The line number.
60: */
61: public int getLine() {
62: return line;
63: }
64:
65: /**
66: * @return The column number.
67: */
68: public int getColumn() {
69: return column;
70: }
71:
72: /**
73: * Formats a textual representation of this object as <code>SOURCE
74: * [line X, column Y]</code>.
75: *
76: * @return String representing this object.
77: */
78: public String toString() {
79: return getTemplateName() + " [line " + getLine() + ", column "
80: + getColumn() + ']';
81: }
82: }
|