summaryrefslogtreecommitdiff
path: root/java/src/Ice/ProxyIdentityFacetKey.java
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2004-01-23 03:48:41 +0000
committerMark Spruiell <mes@zeroc.com>2004-01-23 03:48:41 +0000
commit0898fff0f86ed99ba04c8b7183d1b420cddf3b48 (patch)
treeba819238bc856917b53161897ea10f8cf7ec3d75 /java/src/Ice/ProxyIdentityFacetKey.java
parentcleanup (diff)
downloadice-0898fff0f86ed99ba04c8b7183d1b420cddf3b48.tar.bz2
ice-0898fff0f86ed99ba04c8b7183d1b420cddf3b48.tar.xz
ice-0898fff0f86ed99ba04c8b7183d1b420cddf3b48.zip
for Matthew
Diffstat (limited to 'java/src/Ice/ProxyIdentityFacetKey.java')
-rw-r--r--java/src/Ice/ProxyIdentityFacetKey.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/java/src/Ice/ProxyIdentityFacetKey.java b/java/src/Ice/ProxyIdentityFacetKey.java
new file mode 100644
index 00000000000..cb17925f229
--- /dev/null
+++ b/java/src/Ice/ProxyIdentityFacetKey.java
@@ -0,0 +1,66 @@
+// **********************************************************************
+//
+// Copyright (c) 2004
+// ZeroC, Inc.
+// Billerica, MA, USA
+//
+// All Rights Reserved.
+//
+// Ice is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// **********************************************************************
+
+package Ice;
+
+//
+// This class wraps a proxy and supplies the necessary methods to allow
+// it to be used as a key in a hashed collection. The proxy's identity
+// and facet are used in comparisons.
+//
+public class ProxyIdentityFacetKey
+{
+ public
+ ProxyIdentityFacetKey(Ice.ObjectPrx proxy)
+ {
+ _proxy = proxy;
+
+ //
+ // Cache the identity and facet, and compute the hash code.
+ //
+ _identity = proxy.ice_getIdentity();
+ _facet = proxy.ice_getFacet();
+ int h = _identity.hashCode();
+ for(int i = 0; i < _facet.length; i++)
+ {
+ h = 5 * h + _facet[i].hashCode();
+ }
+ _hashCode = h;
+ }
+
+ public int
+ hashCode()
+ {
+ return _hashCode;
+ }
+
+ public boolean
+ equals(java.lang.Object obj)
+ {
+ ProxyIdentityFacetKey other = (ProxyIdentityFacetKey)obj;
+ return (_hashCode == other._hashCode) && _identity.equals(other._identity) &&
+ java.util.Arrays.equals(_facet, other._facet);
+ }
+
+ public Ice.ObjectPrx
+ getProxy()
+ {
+ return _proxy;
+ }
+
+ final private Ice.ObjectPrx _proxy;
+ final private Ice.Identity _identity;
+ final private String[] _facet;
+ final private int _hashCode;
+}