01: /*
02: * <copyright>
03: *
04: * Copyright 1997-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.lib.web.axis.distance;
28:
29: import org.cougaar.core.util.UID;
30: import org.cougaar.core.util.UniqueObject;
31:
32: /**
33: * A blackboard query object that the {@link DistanceQueryPlugin}
34: * subscribes to and fills in the "distance" result.
35: */
36: public final class DistanceQuery implements UniqueObject {
37:
38: private final UID uid;
39: private final String fromZip;
40: private final String toZip;
41: private double distance;
42:
43: public DistanceQuery(UID uid, String fromZip, String toZip) {
44: this .uid = uid;
45: this .fromZip = fromZip;
46: this .toZip = toZip;
47:
48: // make sure they're not null
49: String s = (uid == null ? "uid" : fromZip == null ? "fromZip"
50: : toZip == null ? "toZip" : null);
51: if (s != null) {
52: throw new IllegalArgumentException("null " + s);
53: }
54: }
55:
56: public UID getUID() {
57: return uid;
58: }
59:
60: public void setUID(UID uid) {
61: throw new UnsupportedOperationException("already set uid!)");
62: }
63:
64: public String getFromZip() {
65: return fromZip;
66: }
67:
68: public String getToZip() {
69: return toZip;
70: }
71:
72: public double getDistance() {
73: return distance;
74: }
75:
76: public void setDistance(double distance) {
77: this .distance = distance;
78: }
79:
80: public int hashCode() {
81: return uid.hashCode();
82: }
83:
84: public boolean equals(Object o) {
85: if (o == this ) {
86: return true;
87: } else if (o instanceof DistanceQuery) {
88: return uid.equals(((DistanceQuery) o).uid);
89: } else {
90: return false;
91: }
92: }
93:
94: public String toString() {
95: return "(distance-query uid=" + uid + " fromZip=" + fromZip
96: + " toZip=" + toZip + " distance=" + distance + ")";
97: }
98: }
|