01: package vqwiki.utils;
02:
03: /*
04: Very Quick Wiki - WikiWikiWeb clone
05: Copyright (C) 2001-2002 Gareth Cronin
06:
07: This program is free software; you can redistribute it and/or modify
08: it under the terms of the latest version of the GNU Lesser General
09: Public License as published by the Free Software Foundation;
10:
11: This program is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU Lesser General Public License for more details.
15:
16: You should have received a copy of the GNU Lesser General Public License
17: along with this program (gpl.txt); if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19:
20: */
21:
22: public class ComparablePair implements Comparable {
23:
24: Comparable one;
25: Object two;
26:
27: /**
28: *
29: */
30: public ComparablePair(Comparable one, Object two) {
31: this .one = one;
32: this .two = two;
33: }
34:
35: /**
36: *
37: */
38: public int compareTo(Object o) {
39: ComparablePair other = (ComparablePair) o;
40: if (one.compareTo(other.getOne()) == 0)
41: return -1;
42: return -one.compareTo(other.getOne());
43: }
44:
45: /**
46: *
47: */
48: public Object getOne() {
49: return this .one;
50: }
51:
52: /**
53: *
54: */
55: public Object getTwo() {
56: return this .two;
57: }
58:
59: /**
60: *
61: */
62: public int hashCode() {
63: return (two.hashCode() + one.hashCode()) % Integer.MAX_VALUE;
64: }
65:
66: /**
67: *
68: */
69: public boolean equals(Object o) {
70: ComparablePair other = (ComparablePair) o;
71: if (other.getOne().equals(this .one)
72: && other.getTwo().equals(this .two)) {
73: return true;
74: }
75: return false;
76: }
77:
78: /**
79: *
80: */
81: public String toString() {
82: return this .one + ":" + this.two;
83: }
84: }
|