01: /*
02: * Copyright 2005 by Lars Torunski
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: */
17: package com.torunski.crawler.link;
18:
19: /**
20: * Contains the URI of the link.
21: *
22: * @author Lars Torunski
23: * @version $Revision: 1.4 $
24: */
25: public class Link implements Comparable {
26:
27: /** the URI of the link */
28: private String uri;
29:
30: /**
31: * @param uri the URI of the link
32: */
33: public Link(String uri) {
34: if (uri == null)
35: throw new IllegalArgumentException("Parameter uri is null.");
36: this .uri = uri;
37: }
38:
39: /**
40: * @return Returns the link.
41: */
42: public String getURI() {
43: return uri;
44: }
45:
46: /**
47: * @param uri The URI to set.
48: */
49: public void setURI(String uri) {
50: this .uri = uri;
51: }
52:
53: /**
54: * @see java.lang.Object#equals(java.lang.Object)
55: */
56: public boolean equals(Object obj) {
57: if (obj instanceof Link) {
58: Link l = (Link) obj;
59: return uri.equals(l.getURI());
60: }
61: return false;
62: }
63:
64: /**
65: * @see java.lang.Object#hashCode()
66: */
67: public int hashCode() {
68: return uri.hashCode();
69: }
70:
71: /**
72: * @see java.lang.Object#toString()
73: */
74: public String toString() {
75: return uri;
76: }
77:
78: /**
79: * @see java.lang.Comparable#compareTo(java.lang.Object)
80: */
81: public int compareTo(Object obj) {
82: Link l = (Link) obj;
83: return uri.compareTo(l.getURI());
84: }
85:
86: }
|