01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package javax.microedition.jcrmi;
28:
29: /**
30: * The <code>RemoteStub</code> class is the common superclass for stubs of
31: * remote objects.<p>
32: */
33:
34: public class RemoteStub {
35:
36: /**
37: * The remote reference associated with this stub object.
38: * The stub uses this reference to perform a remote method call.
39: */
40: protected RemoteRef ref;
41:
42: /**
43: * Constructs a <code>RemoteStub</code>.
44: */
45: public RemoteStub() {
46: }
47:
48: /**
49: * Sets the remote reference associated with this stub object.
50: * @param ref the remote reference
51: */
52: public void setRef(RemoteRef ref) {
53:
54: this .ref = ref;
55: }
56:
57: /**
58: * Compares two remote objects for equality. Two remote objects are
59: * equal if their remote references are non-null and equal.
60: *
61: * @param obj the Object to compare with
62: * @return true if these Objects are equal; false otherwise
63: */
64:
65: public boolean equals(Object obj) {
66:
67: if (obj instanceof RemoteStub) {
68: if (ref == null) {
69: return obj == this ;
70: } else {
71: return ref.remoteEquals(((RemoteStub) obj).ref);
72: }
73: }
74: return false;
75: }
76:
77: /**
78: * Returns a hashcode for a remote object. Two remote object stubs
79: * that refer to the same remote object will have the same hash code.
80: *
81: * @return remote object hashcode
82: */
83: public int hashCode() {
84: return (ref == null) ? super.hashCode() : ref.remoteHashCode();
85: }
86: }
|