Make LazyMap/LazySortedMap Serializable [18815]
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131628 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2d1415ed14
commit
bef34f2326
|
@ -35,6 +35,8 @@ No interface changes, or deprecations have occurred.
|
||||||
<li>Fast3Map - Add clone() method</li>
|
<li>Fast3Map - Add clone() method</li>
|
||||||
<li>FixedSizeMap - Make Serializable [18815]</li>
|
<li>FixedSizeMap - Make Serializable [18815]</li>
|
||||||
<li>FixedSizeSortedMap - Make Serializable [18815]</li>
|
<li>FixedSizeSortedMap - Make Serializable [18815]</li>
|
||||||
|
<li>LazyMap - Make Serializable [18815]</li>
|
||||||
|
<li>LazySortedMap - Make Serializable [18815]</li>
|
||||||
<li>MultiKey - Add getKey(index) and size() methods and make constructor public</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>MultiHashMap - Add five methods to improve the API</li>
|
||||||
<li>AbstractHashedMap,AbstractLinkedMap - Add methods to access entry methods when protected scope blocks</li>
|
<li>AbstractHashedMap,AbstractLinkedMap - Add methods to access entry methods when protected scope blocks</li>
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -15,6 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.collections.map;
|
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.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.collections.Factory;
|
import org.apache.commons.collections.Factory;
|
||||||
|
@ -44,13 +48,17 @@ import org.apache.commons.collections.TransformerUtils;
|
||||||
* instance is mapped to the "NOW" key in the map.
|
* instance is mapped to the "NOW" key in the map.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2004/02/18 01:13:19 $
|
* @version $Revision: 1.5 $ $Date: 2004/04/07 23:05:37 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Paul Jack
|
* @author Paul Jack
|
||||||
*/
|
*/
|
||||||
public class LazyMap
|
public class LazyMap
|
||||||
extends AbstractMapDecorator implements Map {
|
extends AbstractMapDecorator
|
||||||
|
implements Map, Serializable {
|
||||||
|
|
||||||
|
/** Serialization version */
|
||||||
|
private static final long serialVersionUID = 7990956402564206740L;
|
||||||
|
|
||||||
/** The factory to use to construct elements */
|
/** The factory to use to construct elements */
|
||||||
protected final Transformer factory;
|
protected final Transformer factory;
|
||||||
|
@ -108,6 +116,23 @@ public class LazyMap
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* 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 get(Object key) {
|
public Object get(Object key) {
|
||||||
// create value for key if key is not currently in the map
|
// create value for key if key is not currently in the map
|
||||||
|
|
|
@ -15,7 +15,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.collections.map;
|
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.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
import org.apache.commons.collections.Factory;
|
import org.apache.commons.collections.Factory;
|
||||||
|
@ -44,13 +49,17 @@ import org.apache.commons.collections.Transformer;
|
||||||
* instance is mapped to the "NOW" key in the map.
|
* instance is mapped to the "NOW" key in the map.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2004/02/18 01:13:19 $
|
* @version $Revision: 1.5 $ $Date: 2004/04/07 23:05:37 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Paul Jack
|
* @author Paul Jack
|
||||||
*/
|
*/
|
||||||
public class LazySortedMap
|
public class LazySortedMap
|
||||||
extends LazyMap implements SortedMap {
|
extends LazyMap
|
||||||
|
implements SortedMap, Serializable {
|
||||||
|
|
||||||
|
/** Serialization version */
|
||||||
|
private static final long serialVersionUID = 2715322183617658933L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a lazily instantiated sorted map.
|
* Factory method to create a lazily instantiated sorted map.
|
||||||
|
@ -97,6 +106,23 @@ public class LazySortedMap
|
||||||
super(map, factory);
|
super(map, factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.collections.FactoryUtils;
|
||||||
* {@link LazyMap} implementation.
|
* {@link LazyMap} implementation.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:38 $
|
* @version $Revision: 1.6 $ $Date: 2004/04/07 23:05:37 $
|
||||||
*
|
*
|
||||||
* @author Phil Steitz
|
* @author Phil Steitz
|
||||||
*/
|
*/
|
||||||
|
@ -84,4 +84,19 @@ public class TestLazyMap extends AbstractTestMap {
|
||||||
assertEquals(1, map.size());
|
assertEquals(1, map.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCompatibilityVersion() {
|
||||||
|
return "3.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void testCreate() throws Exception {
|
||||||
|
// resetEmpty();
|
||||||
|
// writeExternalFormToDisk(
|
||||||
|
// (java.io.Serializable) map,
|
||||||
|
// "D:/dev/collections/data/test/LazyMap.emptyCollection.version3.1.obj");
|
||||||
|
// resetFull();
|
||||||
|
// writeExternalFormToDisk(
|
||||||
|
// (java.io.Serializable) map,
|
||||||
|
// "D:/dev/collections/data/test/LazyMap.fullCollection.version3.1.obj");
|
||||||
|
// }
|
||||||
}
|
}
|
|
@ -32,7 +32,7 @@ import org.apache.commons.collections.TransformerUtils;
|
||||||
* {@link LazySortedMap} implementation.
|
* {@link LazySortedMap} implementation.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2004/02/18 01:20:38 $
|
* @version $Revision: 1.5 $ $Date: 2004/04/07 23:05:37 $
|
||||||
*
|
*
|
||||||
* @author Phil Steitz
|
* @author Phil Steitz
|
||||||
*/
|
*/
|
||||||
|
@ -107,4 +107,19 @@ public class TestLazySortedMap extends TestLazyMap {
|
||||||
// expected
|
// expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCompatibilityVersion() {
|
||||||
|
return "3.1";
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void testCreate() throws Exception {
|
||||||
|
// resetEmpty();
|
||||||
|
// writeExternalFormToDisk(
|
||||||
|
// (java.io.Serializable) map,
|
||||||
|
// "D:/dev/collections/data/test/LazySortedMap.emptyCollection.version3.1.obj");
|
||||||
|
// resetFull();
|
||||||
|
// writeExternalFormToDisk(
|
||||||
|
// (java.io.Serializable) map,
|
||||||
|
// "D:/dev/collections/data/test/LazySortedMap.fullCollection.version3.1.obj");
|
||||||
|
// }
|
||||||
}
|
}
|
Loading…
Reference in New Issue