Author: bayard
Date: Mon May 12 23:53:35 2008
New Revision: 655751
URL: http://svn.apache.org/viewvc?rev=655751&view=rev
Log:
Applying my patch from COLLECTIONS-221 - making the CompositeMap, CompositeSet
and CompositeCollection serializable. The only difference from the patch is
that the creation of the obj files in TestCompositeMap is commented out
Added:
commons/proper/collections/trunk/data/test/CompositeCollection.emptyCollection.version3.3.obj
(with props)
commons/proper/collections/trunk/data/test/CompositeCollection.fullCollection.version3.3.obj
(with props)
commons/proper/collections/trunk/data/test/CompositeMap.emptyCollection.version3.3.obj
(with props)
commons/proper/collections/trunk/data/test/CompositeMap.fullCollection.version3.3.obj
(with props)
commons/proper/collections/trunk/data/test/CompositeSet.emptyCollection.version3.3.obj
(with props)
commons/proper/collections/trunk/data/test/CompositeSet.fullCollection.version3.3.obj
(with props)
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/EmptyMapMutator.java
(with props)
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/EmptySetMutator.java
(with props)
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/CompositeCollection.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java
Added:
commons/proper/collections/trunk/data/test/CompositeCollection.emptyCollection.version3.3.obj
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/data/test/CompositeCollection.emptyCollection.version3.3.obj?rev=655751&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/collections/trunk/data/test/CompositeCollection.emptyCollection.version3.3.obj
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
commons/proper/collections/trunk/data/test/CompositeCollection.fullCollection.version3.3.obj
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/data/test/CompositeCollection.fullCollection.version3.3.obj?rev=655751&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/collections/trunk/data/test/CompositeCollection.fullCollection.version3.3.obj
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
commons/proper/collections/trunk/data/test/CompositeMap.emptyCollection.version3.3.obj
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/data/test/CompositeMap.emptyCollection.version3.3.obj?rev=655751&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/collections/trunk/data/test/CompositeMap.emptyCollection.version3.3.obj
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
commons/proper/collections/trunk/data/test/CompositeMap.fullCollection.version3.3.obj
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/data/test/CompositeMap.fullCollection.version3.3.obj?rev=655751&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/collections/trunk/data/test/CompositeMap.fullCollection.version3.3.obj
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
commons/proper/collections/trunk/data/test/CompositeSet.emptyCollection.version3.3.obj
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/data/test/CompositeSet.emptyCollection.version3.3.obj?rev=655751&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/collections/trunk/data/test/CompositeSet.emptyCollection.version3.3.obj
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
commons/proper/collections/trunk/data/test/CompositeSet.fullCollection.version3.3.obj
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/data/test/CompositeSet.fullCollection.version3.3.obj?rev=655751&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
commons/proper/collections/trunk/data/test/CompositeSet.fullCollection.version3.3.obj
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/CompositeCollection.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/CompositeCollection.java?rev=655751&r1=655750&r2=655751&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/CompositeCollection.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/CompositeCollection.java
Mon May 12 23:53:35 2008
@@ -16,6 +16,7 @@
*/
package org.apache.commons.collections.collection;
+import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
@@ -40,7 +41,7 @@
* @author Stephen Colebourne
* @author Phil Steitz
*/
-public class CompositeCollection implements Collection {
+public class CompositeCollection implements Collection, Serializable {
/** CollectionMutator to handle changes to the collection */
protected CollectionMutator mutator;
@@ -393,7 +394,7 @@
/**
* Pluggable strategy to handle changes to the composite.
*/
- public interface CollectionMutator {
+ public interface CollectionMutator extends Serializable {
/**
* Called when an object is to be added to the composite.
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java?rev=655751&r1=655750&r2=655751&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/CompositeMap.java
Mon May 12 23:53:35 2008
@@ -16,6 +16,8 @@
*/
package org.apache.commons.collections.map;
+import java.io.Serializable;
+
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
@@ -43,7 +45,7 @@
*
* @author Brian McCallister
*/
-public class CompositeMap implements Map {
+public class CompositeMap implements Map, Serializable {
/** Array of all maps in the composite */
private Map[] composite;
@@ -479,7 +481,7 @@
* mutators in a CompositeMap, as well as providing a hook for
* callbacks on key collisions.
*/
- public static interface MapMutator {
+ public static interface MapMutator extends Serializable {
/**
* Called when adding a new Composited Map results in a
* key collision.
Modified:
commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java?rev=655751&r1=655750&r2=655751&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java
(original)
+++
commons/proper/collections/trunk/src/test/org/apache/commons/collections/collection/TestCompositeCollection.java
Mon May 12 23:53:35 2008
@@ -355,4 +355,16 @@
assertTrue(c.contains("1"));
assertEquals(2, c.size());
}
+
+ public String getCompatibilityVersion() {
+ return "3.3";
+ }
+
+// public void testCreate() throws Exception {
+// resetEmpty();
+// writeExternalFormToDisk((java.io.Serializable) collection,
"/tmp/CompositeCollection.emptyCollection.version3.3.obj");
+// resetFull();
+// writeExternalFormToDisk((java.io.Serializable) collection,
"/tmp/CompositeCollection.fullCollection.version3.3.obj");
+// }
+
}
Added:
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/EmptyMapMutator.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/EmptyMapMutator.java?rev=655751&view=auto
==============================================================================
---
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/EmptyMapMutator.java
(added)
+++
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/EmptyMapMutator.java
Mon May 12 23:53:35 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections.map;
+
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * This class is used in TestCompositeMap. When testing serialization,
+ * the class has to be separate of TestCompositeMap, else the test
+ * class also has to be serialized.
+ */
+class EmptyMapMutator implements CompositeMap.MapMutator {
+ public void resolveCollision(CompositeMap composite,
+ Map existing,
+ Map added,
+ Collection intersect) {
+ // Do nothing
+ }
+
+ public Object put(CompositeMap map, Map[] composited, Object key, Object
value) {
+ return composited[0].put(key, value);
+ }
+
+ public void putAll(CompositeMap map, Map[] composited, Map t) {
+ composited[0].putAll(t);
+ }
+
+}
Propchange:
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/EmptyMapMutator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java?rev=655751&r1=655750&r2=655751&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java
(original)
+++
commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestCompositeMap.java
Mon May 12 23:53:35 2008
@@ -58,23 +58,7 @@
public Map makeEmptyMap() {
CompositeMap map = new CompositeMap();
map.addComposited(new HashMap());
- map.setMutator(new CompositeMap.MapMutator() {
- public void resolveCollision(CompositeMap composite,
- Map existing,
- Map added,
- Collection intersect) {
- // Do nothing
- }
-
- public Object put(CompositeMap map, Map[] composited, Object key,
Object value) {
- return composited[0].put(key, value);
- }
-
- public void putAll(CompositeMap map, Map[] composited, Map t) {
- composited[0].putAll(t);
- }
-
- });
+ map.setMutator( new EmptyMapMutator() );
return map;
}
@@ -223,5 +207,16 @@
map.putAll(null);
assertTrue(pass);
}
-}
+ public String getCompatibilityVersion() {
+ return "3.3";
+ }
+
+// public void testCreate() throws Exception {
+// resetEmpty();
+// writeExternalFormToDisk((java.io.Serializable) map,
"/tmp/CompositeMap.emptyCollection.version3.3.obj");
+// resetFull();
+// writeExternalFormToDisk((java.io.Serializable) map,
"/tmp/CompositeMap.fullCollection.version3.3.obj");
+// }
+
+}
Added:
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/EmptySetMutator.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/EmptySetMutator.java?rev=655751&view=auto
==============================================================================
---
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/EmptySetMutator.java
(added)
+++
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/EmptySetMutator.java
Mon May 12 23:53:35 2008
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections.set;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.apache.commons.collections.collection.CompositeCollection;
+
+/**
+ * This class is used in TestCompositeSet. When testing serialization,
+ * the class has to be separate of TestCompositeSet, else the test
+ * class also has to be serialized.
+ */
+class EmptySetMutator implements CompositeSet.SetMutator {
+ private Set contained;
+
+ public EmptySetMutator(Set set) {
+ this.contained = set;
+ }
+
+ public void resolveCollision(CompositeSet comp, Set existing,
+ Set added, Collection intersects) {
+ throw new IllegalArgumentException();
+ }
+
+ public boolean add(CompositeCollection composite,
+ Collection[] collections, Object obj) {
+ return contained.add(obj);
+ }
+
+ public boolean addAll(CompositeCollection composite,
+ Collection[] collections, Collection coll) {
+ return contained.addAll(coll);
+ }
+
+ public boolean remove(CompositeCollection composite,
+ Collection[] collections, Object obj) {
+ return contained.remove(obj);
+ }
+}
Propchange:
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/EmptySetMutator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java?rev=655751&r1=655750&r2=655751&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java
(original)
+++
commons/proper/collections/trunk/src/test/org/apache/commons/collections/set/TestCompositeSet.java
Mon May 12 23:53:35 2008
@@ -48,27 +48,7 @@
public Set makeEmptySet() {
final HashSet contained = new HashSet();
CompositeSet set = new CompositeSet(contained);
- set.setMutator(new CompositeSet.SetMutator() {
- public void resolveCollision(CompositeSet comp, Set existing,
- Set added, Collection intersects) {
- throw new IllegalArgumentException();
- }
-
- public boolean add(CompositeCollection composite,
- Collection[] collections, Object obj) {
- return contained.add(obj);
- }
-
- public boolean addAll(CompositeCollection composite,
- Collection[] collections, Collection coll) {
- return contained.addAll(coll);
- }
-
- public boolean remove(CompositeCollection composite,
- Collection[] collections, Object obj) {
- return contained.remove(obj);
- }
- });
+ set.setMutator( new EmptySetMutator(contained) );
return set;
}
@@ -173,4 +153,16 @@
// expected
}
}
+
+ public String getCompatibilityVersion() {
+ return "3.3";
+ }
+
+// public void testCreate() throws Exception {
+// resetEmpty();
+// writeExternalFormToDisk((java.io.Serializable) collection,
"/tmp/CompositeSet.emptyCollection.version3.3.obj");
+// resetFull();
+// writeExternalFormToDisk((java.io.Serializable) collection,
"/tmp/CompositeSet.fullCollection.version3.3.obj");
+// }
+
}