01: /*
02: * $Id: Location.java,v 1.3 2002/09/16 08:05:02 jkl Exp $
03: *
04: * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
05: *
06: * Use is subject to license terms, as defined in
07: * Anvil Sofware License, Version 1.1. See LICENSE
08: * file, or http://njet.org/license-1.1.txt
09: */
10: package anvil;
11:
12: import java.net.URL;
13: import java.net.MalformedURLException;
14:
15: /**
16: * class Location
17: *
18: * @author: Jani Lehtimäki
19: */
20: public class Location {
21:
22: private URL _url;
23: private int _line = 0;
24: private int _column = 0;
25:
26: public Location(URL url, int line, int column) {
27: _url = url;
28: _line = line;
29: _column = column;
30: }
31:
32: public Location(String url, int line, int column) {
33: try {
34: _url = new URL(url);
35: } catch (MalformedURLException e) {
36: }
37: _line = line;
38: _column = column;
39: }
40:
41: public Location(URL url, int line) {
42: _url = url;
43: _line = line;
44: _column = 0;
45: }
46:
47: public Location(String url, int line) {
48: try {
49: _url = new URL(url);
50: } catch (MalformedURLException e) {
51: }
52: _line = line;
53: }
54:
55: public Location(URL url) {
56: _url = url;
57: _line = 0;
58: _column = 0;
59: }
60:
61: public Location(String url) {
62: try {
63: _url = new URL(url);
64: } catch (MalformedURLException e) {
65: }
66: }
67:
68: public URL getURL() {
69: return _url;
70: }
71:
72: public int getLine() {
73: return _line;
74: }
75:
76: public int getColumn() {
77: return _column;
78: }
79:
80: public String toString() {
81: StringBuffer buffer = new StringBuffer();
82: buffer.append(_url);
83: buffer.append(' ');
84: if (_line > 0) {
85: buffer.append('(');
86: buffer.append(_line);
87: if (_column > 0) {
88: buffer.append(':');
89: buffer.append(_column);
90: }
91: buffer.append(')');
92: }
93: return buffer.toString();
94: }
95:
96: }
|