Make ListOrderedMap Serializable [18815]

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131629 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2004-04-07 23:17:25 +00:00
parent bef34f2326
commit 70dc4fb1c3
5 changed files with 43 additions and 3 deletions

View File

@ -37,6 +37,7 @@ No interface changes, or deprecations have occurred.
<li>FixedSizeSortedMap - Make Serializable [18815]</li>
<li>LazyMap - Make Serializable [18815]</li>
<li>LazySortedMap - Make Serializable [18815]</li>
<li>ListOrderedMap - 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.

View File

@ -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.AbstractCollection;
import java.util.AbstractSet;
import java.util.ArrayList;
@ -48,13 +52,17 @@ import org.apache.commons.collections.list.UnmodifiableList;
* original position in the iteration.
*
* @since Commons Collections 3.0
* @version $Revision: 1.13 $ $Date: 2004/04/01 22:18:12 $
* @version $Revision: 1.14 $ $Date: 2004/04/07 23:17:25 $
*
* @author Henri Yandell
* @author Stephen Colebourne
*/
public class ListOrderedMap
extends AbstractMapDecorator implements OrderedMap {
extends AbstractMapDecorator
implements OrderedMap, Serializable {
/** Serialization version */
private static final long serialVersionUID = 2728177751851003750L;
/** Internal list to hold the sequence of objects */
protected final List insertOrder = new ArrayList();
@ -83,6 +91,23 @@ public class ListOrderedMap
insertOrder.addAll(getMap().keySet());
}
//-----------------------------------------------------------------------
/**
* 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();
}
// Implement OrderedMap
//-----------------------------------------------------------------------
public MapIterator mapIterator() {

View File

@ -31,7 +31,7 @@ import org.apache.commons.collections.list.AbstractTestList;
* implementation.
*
* @since Commons Collections 3.0
* @version $Revision: 1.8 $ $Date: 2004/02/18 01:20:38 $
* @version $Revision: 1.9 $ $Date: 2004/04/07 23:17:25 $
*
* @author Henri Yandell
* @author Stephen Colebourne
@ -191,4 +191,18 @@ public class TestListOrderedMap extends AbstractTestOrderedMap {
}
public String getCompatibilityVersion() {
return "3.1";
}
// public void testCreate() throws Exception {
// resetEmpty();
// writeExternalFormToDisk(
// (java.io.Serializable) map,
// "D:/dev/collections/data/test/ListOrderedMap.emptyCollection.version3.1.obj");
// resetFull();
// writeExternalFormToDisk(
// (java.io.Serializable) map,
// "D:/dev/collections/data/test/ListOrderedMap.fullCollection.version3.1.obj");
// }
}