01: // $Id: Rsp.java,v 1.5 2006/05/12 09:58:33 belaban Exp $
02:
03: package org.jgroups.util;
04:
05: import org.jgroups.Address;
06:
07: /**
08: * class that represents a response from a communication
09: */
10: public class Rsp {
11: /* flag that represents whether the response was received */
12: boolean received = false;
13:
14: /* flag that represents whether the response was suspected */
15: boolean suspected = false;
16:
17: /* The sender of this response */
18: Address sender = null;
19:
20: /* the value from the response */
21: Object retval = null;
22:
23: public Rsp(Address sender) {
24: this .sender = sender;
25: }
26:
27: public Rsp(Address sender, boolean suspected) {
28: this .sender = sender;
29: this .suspected = suspected;
30: }
31:
32: public Rsp(Address sender, Object retval) {
33: this .sender = sender;
34: this .retval = retval;
35: received = true;
36: }
37:
38: public boolean equals(Object obj) {
39: Rsp other = (Rsp) obj;
40: if (sender != null)
41: return sender.equals(other.sender);
42: return other.sender == null;
43: }
44:
45: public Object getValue() {
46: return retval;
47: }
48:
49: public void setValue(Object val) {
50: this .retval = val;
51: }
52:
53: public Address getSender() {
54: return sender;
55: }
56:
57: public boolean wasReceived() {
58: return received;
59: }
60:
61: public void setReceived(boolean received) {
62: this .received = received;
63: if (received)
64: suspected = false;
65: }
66:
67: public boolean wasSuspected() {
68: return suspected;
69: }
70:
71: public void setSuspected(boolean suspected) {
72: this .suspected = suspected;
73: if (suspected)
74: received = false;
75: }
76:
77: public String toString() {
78: return new StringBuffer("sender=").append(sender).append(
79: ", retval=").append(retval).append(", received=")
80: .append(received).append(", suspected=").append(
81: suspected).toString();
82: }
83: }
|