From b09e8a2033b4e0602677f28aa0b71b8b634cd904 Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Fri, 2 Apr 2004 21:15:05 +0000 Subject: [PATCH] Make FixedSizeMap Serializable [18815] git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131623 13f79535-47bb-0310-9956-ffa450edef68 --- RELEASE-NOTES.html | 1 + ...ixedSizeMap.emptyCollection.version3.1.obj | Bin 0 -> 147 bytes ...FixedSizeMap.fullCollection.version3.1.obj | Bin 0 -> 398 bytes .../commons/collections/map/FixedSizeMap.java | 31 ++++++++++++++++-- .../collections/map/TestFixedSizeMap.java | 16 ++++++++- 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 data/test/FixedSizeMap.emptyCollection.version3.1.obj create mode 100644 data/test/FixedSizeMap.fullCollection.version3.1.obj diff --git a/RELEASE-NOTES.html b/RELEASE-NOTES.html index 55e085988..24b4db57a 100644 --- a/RELEASE-NOTES.html +++ b/RELEASE-NOTES.html @@ -33,6 +33,7 @@ No interface changes, or deprecations have occurred.
  • ReferenceMap - Changed to extend AbstractHashedMap, thus gaining a mapIterator() and subclassability
  • Fast3Map - Make Serializable [27946]
  • Fast3Map - Add clone() method
  • +
  • FixedSizeMap - Make Serializable [18815]
  • MultiKey - Add getKey(index) and size() methods and make constructor public
  • MultiHashMap - Add five methods to improve the API
  • AbstractHashedMap,AbstractLinkedMap - Add methods to access entry methods when protected scope blocks
  • diff --git a/data/test/FixedSizeMap.emptyCollection.version3.1.obj b/data/test/FixedSizeMap.emptyCollection.version3.1.obj new file mode 100644 index 0000000000000000000000000000000000000000..a22abc377e6a618b1718361e5506c450b63ce6e4 GIT binary patch literal 147 zcmZ4UmVvdnh(SNUC|xhHATc>3RWCU|H#a}87)a;jq$ZbSg4nr<1$u6o6{#t~nN_L2 zi3REDOc&SlT`XZ{V5len>KDvPEKAfYEy>K$^GGbt0IFbRzjg4iSi(hS1|~NKuAKbD m6t~3WlKdi12F{XTafqwoFX`I;sb0G;{=@A#7>&@z>AQ01L6g}@(2FV zS%am_?Ck7p5`X+s<~zEwozB^DS*yIXZEM#aY>X;HBX!FzFPc$RkIhy+u+w_B`#jo( zglKfgAHVRxc^?{+-?6VTku83{zR#X^3C#*RG?uG^%V4{EItX>Ad~HoNx|>^)bG}&u zFYufMN}jC^lmdr9*+yL&6KEb8jl?Sj7bs%ITL_?x*2)+p=aK*1F1nq#thrgkjf_V6 zs-|o72R1!6F0{4PYC^UAuVlkydrSgFAmC)5;Tkz1>FW4BKoOyp2_QtKae))w7#WRJ VTQ5nW!M)Ktog%{Wdns@j$2|eyeZc?# literal 0 HcmV?d00001 diff --git a/src/java/org/apache/commons/collections/map/FixedSizeMap.java b/src/java/org/apache/commons/collections/map/FixedSizeMap.java index d2fde29d3..64831648a 100644 --- a/src/java/org/apache/commons/collections/map/FixedSizeMap.java +++ b/src/java/org/apache/commons/collections/map/FixedSizeMap.java @@ -15,6 +15,10 @@ */ package org.apache.commons.collections.map; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.Collection; import java.util.Iterator; import java.util.Map; @@ -38,13 +42,17 @@ import org.apache.commons.collections.set.UnmodifiableSet; * is not always unsupported. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:13:19 $ + * @version $Revision: 1.6 $ $Date: 2004/04/02 21:15:05 $ * * @author Stephen Colebourne * @author Paul Jack */ public class FixedSizeMap - extends AbstractMapDecorator implements Map, BoundedMap { + extends AbstractMapDecorator + implements Map, BoundedMap, Serializable { + + /** Serialization version */ + private static final long serialVersionUID = 7450927208116179316L; /** * Factory method to create a fixed size map. @@ -66,7 +74,24 @@ public class FixedSizeMap protected FixedSizeMap(Map map) { super(map); } - + + //----------------------------------------------------------------------- + /** + * Write the map out using a custom routine. + */ + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(map); + } + + /** + * Read the map in using a custom routine. + */ + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + map = (Map) in.readObject(); + } + //----------------------------------------------------------------------- public Object put(Object key, Object value) { if (map.containsKey(key) == false) { diff --git a/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java b/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java index 3af2e59cb..982af6253 100644 --- a/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java +++ b/src/test/org/apache/commons/collections/map/TestFixedSizeMap.java @@ -26,7 +26,7 @@ import junit.framework.TestSuite; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:38 $ + * @version $Revision: 1.6 $ $Date: 2004/04/02 21:15:05 $ * * @author Stephen Colebourne */ @@ -63,4 +63,18 @@ public class TestFixedSizeMap extends AbstractTestMap { return false; } + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk( +// (java.io.Serializable) map, +// "D:/dev/collections/data/test/FixedSizeMap.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk( +// (java.io.Serializable) map, +// "D:/dev/collections/data/test/FixedSizeMap.fullCollection.version3.1.obj"); +// } }