diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-09-06 17:47:45 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-09-06 17:47:45 +0000 |
commit | 694a053f933d048af63c71bca417831dacc65618 (patch) | |
tree | 22295ed931f2cf23ff08e34a445c0eb2aa8da52c /java/src | |
parent | Removed bad throw; from end of SslTransceiver::close(). (diff) | |
download | ice-694a053f933d048af63c71bca417831dacc65618.tar.bz2 ice-694a053f933d048af63c71bca417831dacc65618.tar.xz ice-694a053f933d048af63c71bca417831dacc65618.zip |
adding clone() support for abstract objects
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/Object.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/java/src/Ice/Object.java b/java/src/Ice/Object.java index a48cd2ab632..7135b123407 100644 --- a/java/src/Ice/Object.java +++ b/java/src/Ice/Object.java @@ -31,6 +31,55 @@ public class Object return false; } + public java.lang.Object + clone() + throws java.lang.CloneNotSupportedException + { + Object result = null; + + try + { + result = (Object)getClass().newInstance(); + result.ice_copyStateFrom(this); + } + catch(InstantiationException ex) + { + CloneNotSupportedException e = new CloneNotSupportedException(); + e.initCause(ex); + throw e; + } + catch(IllegalAccessException ex) + { + CloneNotSupportedException e = new CloneNotSupportedException(); + e.initCause(ex); + throw e; + } + + return result; + } + + protected void + ice_copyStateFrom(Object obj) + throws java.lang.CloneNotSupportedException + { + // + // Clone facets. + // + synchronized(obj._activeFacetMap) + { + if(!obj._activeFacetMap.isEmpty()) + { + java.util.Iterator p = obj._activeFacetMap.entrySet().iterator(); + while(p.hasNext()) + { + java.util.Map.Entry e = (java.util.Map.Entry)p.next(); + Object facet = (Object)e.getValue(); + _activeFacetMap.put(e.getKey(), facet.clone()); + } + } + } + } + public int ice_hash() { |