01: /*
02: * ErrorInfo.java - part of the CodeAid plugin.
03: * Copyright (C) 1999 Jason Ginchereau
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * as published by the Free Software Foundation; either version 2
08: * of the License, or any later version.
09: *
10: * This program is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU General Public License for more details.
14: *
15: * You should have received a copy of the GNU General Public License
16: * along with this program; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18: */
19:
20: //package codeaid.info;
21: package org.acm.seguin.completer.info;
22:
23: // Collections API
24: // java.lang.Comparable
25:
26: public final class ErrorInfo implements Comparable {
27: private SourceLocation sourceLocation;
28: private String description;
29:
30: public ErrorInfo(SourceLocation sourceLocation, String description) {
31: this .sourceLocation = sourceLocation;
32: this .description = description;
33: }
34:
35: public SourceLocation getSourceLocation() {
36: return sourceLocation;
37: }
38:
39: public String getDescription() {
40: return description;
41: }
42:
43: public int compareTo(Object o) {
44: ErrorInfo ei = (ErrorInfo) o;
45: int sc = sourceLocation.compareTo(ei.sourceLocation);
46: if (sc == 0) {
47: if (description == null && ei.description == null) {
48: return 0;
49: } else if (description == null && ei.description != null) {
50: return -1;
51: } else if (description != null && ei.description == null) {
52: return 1;
53: } else {
54: return description.compareTo(ei.description);
55: }
56: } else {
57: return sc;
58: }
59: }
60:
61: public boolean equals(Object o) {
62: return compareTo(o) == 0;
63: }
64:
65: public int hashCode() {
66: return sourceLocation.hashCode();
67: }
68:
69: public String toString() {
70: return sourceLocation.toString() + ": " + description;
71: }
72: }
|