Make FixedSizeMap Serializable [18815]
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131623 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c0b68181f8
commit
b09e8a2033
|
@ -33,6 +33,7 @@ No interface changes, or deprecations have occurred.
|
|||
<li>ReferenceMap - Changed to extend AbstractHashedMap, thus gaining a mapIterator() and subclassability</li>
|
||||
<li>Fast3Map - Make Serializable [27946]</li>
|
||||
<li>Fast3Map - Add clone() method</li>
|
||||
<li>FixedSizeMap - Make Serializable [18815]</li>
|
||||
<li>MultiKey - Add getKey(index) and size() methods and make constructor public</li>
|
||||
<li>MultiHashMap - Add five methods to improve the API</li>
|
||||
<li>AbstractHashedMap,AbstractLinkedMap - Add methods to access entry methods when protected scope blocks</li>
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -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.
|
||||
|
@ -67,6 +75,23 @@ public class FixedSizeMap
|
|||
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) {
|
||||
|
|
|
@ -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");
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue