From b9fbf5945b45fd1da455b486a1422e7527bee04a Mon Sep 17 00:00:00 2001 From: Rodney Waldhoff Date: Fri, 28 Feb 2003 21:21:51 +0000 Subject: [PATCH] better handling of serializablity w.r.t. sublists make some types final git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130982 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractIntCollectionCollection.java | 154 ++++++++++++++++ .../adapters/AbstractIntListList.java | 164 ++++++++++++++++++ .../adapters/CollectionIntCollection.java | 6 +- .../adapters/IntCollectionCollection.java | 121 ++----------- .../primitives/adapters/IntListList.java | 99 ++--------- ...onSerializableCollectionIntCollection.java | 6 +- ...onSerializableIntCollectionCollection.java | 82 +++++++++ .../adapters/NonSerializableIntListList.java | 83 +++++++++ .../adapters/NonSerializableListIntList.java | 6 +- .../primitives/TestArrayIntList.java | 21 ++- .../TestArrayUnsignedShortList.java | 22 ++- 11 files changed, 552 insertions(+), 212 deletions(-) create mode 100644 src/java/org/apache/commons/collections/primitives/adapters/AbstractIntCollectionCollection.java create mode 100644 src/java/org/apache/commons/collections/primitives/adapters/AbstractIntListList.java create mode 100644 src/java/org/apache/commons/collections/primitives/adapters/NonSerializableIntCollectionCollection.java create mode 100644 src/java/org/apache/commons/collections/primitives/adapters/NonSerializableIntListList.java diff --git a/src/java/org/apache/commons/collections/primitives/adapters/AbstractIntCollectionCollection.java b/src/java/org/apache/commons/collections/primitives/adapters/AbstractIntCollectionCollection.java new file mode 100644 index 000000000..23b7739ab --- /dev/null +++ b/src/java/org/apache/commons/collections/primitives/adapters/AbstractIntCollectionCollection.java @@ -0,0 +1,154 @@ +/* + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/AbstractIntCollectionCollection.java,v 1.1 2003/02/28 21:21:51 rwaldhoff Exp $ + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.commons.collections.primitives.adapters; + +import java.lang.reflect.Array; +import java.util.Collection; +import java.util.Iterator; + +import org.apache.commons.collections.primitives.IntCollection; + +/** + * @since Commons Collections 2.2 + * @version $Revision: 1.1 $ $Date: 2003/02/28 21:21:51 $ + * @author Rodney Waldhoff + */ +abstract class AbstractIntCollectionCollection implements Collection { + + public boolean add(Object element) { + return getIntCollection().add(((Number)element).intValue()); + } + + public boolean addAll(Collection c) { + return getIntCollection().addAll(CollectionIntCollection.wrap(c)); + } + + public void clear() { + getIntCollection().clear(); + } + + public boolean contains(Object element) { + return getIntCollection().contains(((Number)element).intValue()); + } + + + public boolean containsAll(Collection c) { + return getIntCollection().containsAll(CollectionIntCollection.wrap(c)); + } + + public String toString() { + return getIntCollection().toString(); + } + + public boolean isEmpty() { + return getIntCollection().isEmpty(); + } + + /** + * {@link IntIteratorIterator#wrap wraps} the + * {@link org.apache.commons.collections.primitives.IntIterator IntIterator} + * returned by my underlying + * {@link IntCollection IntCollection}, + * if any. + */ + public Iterator iterator() { + return IntIteratorIterator.wrap(getIntCollection().iterator()); + } + + public boolean remove(Object element) { + return getIntCollection().removeElement(((Number)element).intValue()); + } + + public boolean removeAll(Collection c) { + return getIntCollection().removeAll(CollectionIntCollection.wrap(c)); + } + + public boolean retainAll(Collection c) { + return getIntCollection().retainAll(CollectionIntCollection.wrap(c)); + } + + public int size() { + return getIntCollection().size(); + } + + public Object[] toArray() { + int[] a = getIntCollection().toArray(); + Object[] A = new Object[a.length]; + for(int i=0;i a.length) { + A[a.length] = null; + } + + return A; + } + + protected abstract IntCollection getIntCollection(); +} diff --git a/src/java/org/apache/commons/collections/primitives/adapters/AbstractIntListList.java b/src/java/org/apache/commons/collections/primitives/adapters/AbstractIntListList.java new file mode 100644 index 000000000..c4c36e6ea --- /dev/null +++ b/src/java/org/apache/commons/collections/primitives/adapters/AbstractIntListList.java @@ -0,0 +1,164 @@ +/* + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/AbstractIntListList.java,v 1.1 2003/02/28 21:21:51 rwaldhoff Exp $ + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.commons.collections.primitives.adapters; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +import org.apache.commons.collections.primitives.IntCollection; +import org.apache.commons.collections.primitives.IntList; + +/** + * @since Commons Collections 2.2 + * @version $Revision: 1.1 $ $Date: 2003/02/28 21:21:51 $ + * @author Rodney Waldhoff + */ +abstract class AbstractIntListList extends AbstractIntCollectionCollection implements List { + + public void add(int index, Object element) { + getIntList().add(index,((Number)element).intValue()); + } + + public boolean addAll(int index, Collection c) { + return getIntList().addAll(index,CollectionIntCollection.wrap(c)); + } + + public Object get(int index) { + return new Integer(getIntList().get(index)); + } + + public int indexOf(Object element) { + return getIntList().indexOf(((Number)element).intValue()); + } + + public int lastIndexOf(Object element) { + return getIntList().lastIndexOf(((Number)element).intValue()); + } + + /** + * {@link IntListIteratorListIterator#wrap wraps} the + * {@link org.apache.commons.collections.primitives.IntListIterator IntListIterator} + * returned by my underlying + * {@link IntList IntList}, + * if any. + */ + public ListIterator listIterator() { + return IntListIteratorListIterator.wrap(getIntList().listIterator()); + } + + /** + * {@link IntListIteratorListIterator#wrap wraps} the + * {@link org.apache.commons.collections.primitives.IntListIterator IntListIterator} + * returned by my underlying + * {@link IntList IntList}, + * if any. + */ + public ListIterator listIterator(int index) { + return IntListIteratorListIterator.wrap(getIntList().listIterator(index)); + } + + public Object remove(int index) { + return new Integer(getIntList().removeElementAt(index)); + } + + public Object set(int index, Object element) { + return new Integer(getIntList().set(index, ((Number)element).intValue() )); + } + + public List subList(int fromIndex, int toIndex) { + return IntListList.wrap(getIntList().subList(fromIndex,toIndex)); + } + + public boolean equals(Object obj) { + if(obj instanceof List) { + List that = (List)obj; + if(this == that) { + return true; + } else if(this.size() != that.size()) { + return false; + } else { + Iterator thisiter = iterator(); + Iterator thatiter = that.iterator(); + while(thisiter.hasNext()) { + Object thiselt = thisiter.next(); + Object thatelt = thatiter.next(); + if(null == thiselt ? null != thatelt : !(thiselt.equals(thatelt))) { + return false; + } + } + return true; + } + } else { + return false; + } + } + + public int hashCode() { + return getIntList().hashCode(); + } + + protected final IntCollection getIntCollection() { + return getIntList(); + } + + protected abstract IntList getIntList(); + + +} diff --git a/src/java/org/apache/commons/collections/primitives/adapters/CollectionIntCollection.java b/src/java/org/apache/commons/collections/primitives/adapters/CollectionIntCollection.java index 4b3628dd6..af6c911b4 100644 --- a/src/java/org/apache/commons/collections/primitives/adapters/CollectionIntCollection.java +++ b/src/java/org/apache/commons/collections/primitives/adapters/CollectionIntCollection.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/CollectionIntCollection.java,v 1.5 2003/02/28 00:17:53 rwaldhoff Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/CollectionIntCollection.java,v 1.6 2003/02/28 21:21:51 rwaldhoff Exp $ * ==================================================================== * The Apache Software License, Version 1.1 * @@ -72,10 +72,10 @@ import org.apache.commons.collections.primitives.IntCollection; * implementation in the "obvious" way. * * @since Commons Collections 2.2 - * @version $Revision: 1.5 $ $Date: 2003/02/28 00:17:53 $ + * @version $Revision: 1.6 $ $Date: 2003/02/28 21:21:51 $ * @author Rodney Waldhoff */ -public class CollectionIntCollection extends AbstractCollectionIntCollection implements Serializable { +final public class CollectionIntCollection extends AbstractCollectionIntCollection implements Serializable { /** * Create an {@link IntCollection IntCollection} wrapping * the specified {@link Collection Collection}. When diff --git a/src/java/org/apache/commons/collections/primitives/adapters/IntCollectionCollection.java b/src/java/org/apache/commons/collections/primitives/adapters/IntCollectionCollection.java index 26f0d6a0c..680599d9e 100644 --- a/src/java/org/apache/commons/collections/primitives/adapters/IntCollectionCollection.java +++ b/src/java/org/apache/commons/collections/primitives/adapters/IntCollectionCollection.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/IntCollectionCollection.java,v 1.4 2003/02/26 19:17:23 rwaldhoff Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/IntCollectionCollection.java,v 1.5 2003/02/28 21:21:51 rwaldhoff Exp $ * ==================================================================== * The Apache Software License, Version 1.1 * @@ -58,9 +58,7 @@ package org.apache.commons.collections.primitives.adapters; import java.io.Serializable; -import java.lang.reflect.Array; import java.util.Collection; -import java.util.Iterator; import org.apache.commons.collections.primitives.IntCollection; @@ -74,10 +72,10 @@ import org.apache.commons.collections.primitives.IntCollection; * implementation in the "obvious" way. * * @since Commons Collections 2.2 - * @version $Revision: 1.4 $ $Date: 2003/02/26 19:17:23 $ + * @version $Revision: 1.5 $ $Date: 2003/02/28 21:21:51 $ * @author Rodney Waldhoff */ -public class IntCollectionCollection implements Collection, Serializable { +final public class IntCollectionCollection extends AbstractIntCollectionCollection implements Serializable { /** * Create a {@link Collection Collection} wrapping @@ -92,7 +90,13 @@ public class IntCollectionCollection implements Collection, Serializable { * null. */ public static Collection wrap(IntCollection collection) { - return null == collection ? null : new IntCollectionCollection(collection); + if(null == collection) { + return null; + } else if(collection instanceof Serializable) { + return new IntCollectionCollection(collection); + } else { + return new NonSerializableIntCollectionCollection(collection); + } } /** @@ -110,111 +114,10 @@ public class IntCollectionCollection implements Collection, Serializable { _collection = collection; } - public boolean add(Object element) { - return _collection.add(((Number)element).intValue()); - } - public boolean addAll(Collection c) { - return _collection.addAll(CollectionIntCollection.wrap(c)); + protected IntCollection getIntCollection() { + return _collection; } - public void clear() { - _collection.clear(); - } - - public boolean contains(Object element) { - return _collection.contains(((Number)element).intValue()); - } - - - public boolean containsAll(Collection c) { - return _collection.containsAll(CollectionIntCollection.wrap(c)); - } - - /** - * If that is a {@link Collection Collection}, - * it is {@link CollectionIntCollection#wrap wrapped} and - * compared to my underlying - * {@link org.apache.commons.collections.primitives.IntCollection IntCollection}, - * otherwise this method simply delegates to my underlying - * IntCollection. - */ - public boolean equals(Object that) { - if(that instanceof Collection) { - try { - return _collection.equals(CollectionIntCollection.wrap((Collection)that)); - } catch(ClassCastException e) { - return false; - } catch(NullPointerException e) { - return false; - } - } else { - return _collection.equals(that); - } - } - - public int hashCode() { - return _collection.hashCode(); - } - - public String toString() { - return _collection.toString(); - } - - public boolean isEmpty() { - return _collection.isEmpty(); - } - - /** - * {@link IntIteratorIterator#wrap wraps} the - * {@link org.apache.commons.collections.primitives.IntIterator IntIterator} - * returned by my underlying - * {@link IntCollection IntCollection}, - * if any. - */ - public Iterator iterator() { - return IntIteratorIterator.wrap(_collection.iterator()); - } - - public boolean remove(Object element) { - return _collection.removeElement(((Number)element).intValue()); - } - - public boolean removeAll(Collection c) { - return _collection.removeAll(CollectionIntCollection.wrap(c)); - } - - public boolean retainAll(Collection c) { - return _collection.retainAll(CollectionIntCollection.wrap(c)); - } - - public int size() { - return _collection.size(); - } - - public Object[] toArray() { - int[] a = _collection.toArray(); - Object[] A = new Object[a.length]; - for(int i=0;i a.length) { - A[a.length] = null; - } - - return A; - } - private IntCollection _collection = null; } diff --git a/src/java/org/apache/commons/collections/primitives/adapters/IntListList.java b/src/java/org/apache/commons/collections/primitives/adapters/IntListList.java index ff4f5f272..ad78c2713 100644 --- a/src/java/org/apache/commons/collections/primitives/adapters/IntListList.java +++ b/src/java/org/apache/commons/collections/primitives/adapters/IntListList.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/IntListList.java,v 1.4 2003/02/26 19:17:23 rwaldhoff Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/IntListList.java,v 1.5 2003/02/28 21:21:51 rwaldhoff Exp $ * ==================================================================== * The Apache Software License, Version 1.1 * @@ -58,10 +58,7 @@ package org.apache.commons.collections.primitives.adapters; import java.io.Serializable; -import java.util.Collection; -import java.util.Iterator; import java.util.List; -import java.util.ListIterator; import org.apache.commons.collections.primitives.IntList; @@ -74,10 +71,10 @@ import org.apache.commons.collections.primitives.IntList; * implementation in the "obvious" way. * * @since Commons Collections 2.2 - * @version $Revision: 1.4 $ $Date: 2003/02/26 19:17:23 $ + * @version $Revision: 1.5 $ $Date: 2003/02/28 21:21:51 $ * @author Rodney Waldhoff */ -public class IntListList extends IntCollectionCollection implements List, Serializable { +final public class IntListList extends AbstractIntListList implements Serializable { /** * Create a {@link List List} wrapping @@ -92,7 +89,13 @@ public class IntListList extends IntCollectionCollection implements List, Serial * null. */ public static List wrap(IntList list) { - return null == list ? null : new IntListList(list); + if(null == list) { + return null; + } else if(list instanceof Serializable) { + return new IntListList(list); + } else { + return new NonSerializableIntListList(list); + } } /** @@ -107,88 +110,12 @@ public class IntListList extends IntCollectionCollection implements List, Serial * @see #wrap */ public IntListList(IntList list) { - super(list); _list = list; } - public void add(int index, Object element) { - _list.add(index,((Number)element).intValue()); - } - - public boolean addAll(int index, Collection c) { - return _list.addAll(index,CollectionIntCollection.wrap(c)); - } - - public Object get(int index) { - return new Integer(_list.get(index)); - } - - public int indexOf(Object element) { - return _list.indexOf(((Number)element).intValue()); - } - - public int lastIndexOf(Object element) { - return _list.lastIndexOf(((Number)element).intValue()); - } - - /** - * {@link IntListIteratorListIterator#wrap wraps} the - * {@link org.apache.commons.collections.primitives.IntListIterator IntListIterator} - * returned by my underlying - * {@link IntList IntList}, - * if any. - */ - public ListIterator listIterator() { - return IntListIteratorListIterator.wrap(_list.listIterator()); - } - - /** - * {@link IntListIteratorListIterator#wrap wraps} the - * {@link org.apache.commons.collections.primitives.IntListIterator IntListIterator} - * returned by my underlying - * {@link IntList IntList}, - * if any. - */ - public ListIterator listIterator(int index) { - return IntListIteratorListIterator.wrap(_list.listIterator(index)); - } - - public Object remove(int index) { - return new Integer(_list.removeElementAt(index)); - } - - public Object set(int index, Object element) { - return new Integer(_list.set(index, ((Number)element).intValue() )); - } - - public List subList(int fromIndex, int toIndex) { - return IntListList.wrap(_list.subList(fromIndex,toIndex)); - } - - public boolean equals(Object obj) { - if(obj instanceof List) { - List that = (List)obj; - if(this == that) { - return true; - } else if(this.size() != that.size()) { - return false; - } else { - Iterator thisiter = iterator(); - Iterator thatiter = that.iterator(); - while(thisiter.hasNext()) { - Object thiselt = thisiter.next(); - Object thatelt = thatiter.next(); - if(null == thiselt ? null != thatelt : !(thiselt.equals(thatelt))) { - return false; - } - } - return true; - } - } else { - return false; - } - } + protected IntList getIntList() { + return _list; + } private IntList _list = null; - } diff --git a/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableCollectionIntCollection.java b/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableCollectionIntCollection.java index 0bcf4ddef..aab69081a 100644 --- a/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableCollectionIntCollection.java +++ b/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableCollectionIntCollection.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/NonSerializableCollectionIntCollection.java,v 1.1 2003/02/28 00:17:53 rwaldhoff Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/NonSerializableCollectionIntCollection.java,v 1.2 2003/02/28 21:21:51 rwaldhoff Exp $ * ==================================================================== * The Apache Software License, Version 1.1 * @@ -61,10 +61,10 @@ import java.util.Collection; /** * @since Commons Collections 2.2 - * @version $Revision: 1.1 $ $Date: 2003/02/28 00:17:53 $ + * @version $Revision: 1.2 $ $Date: 2003/02/28 21:21:51 $ * @author Rodney Waldhoff */ -class NonSerializableCollectionIntCollection extends AbstractCollectionIntCollection { +final class NonSerializableCollectionIntCollection extends AbstractCollectionIntCollection { public NonSerializableCollectionIntCollection(Collection collection) { _collection = collection; } diff --git a/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableIntCollectionCollection.java b/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableIntCollectionCollection.java new file mode 100644 index 000000000..8a1f0d4f6 --- /dev/null +++ b/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableIntCollectionCollection.java @@ -0,0 +1,82 @@ +/* + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/NonSerializableIntCollectionCollection.java,v 1.1 2003/02/28 21:21:51 rwaldhoff Exp $ + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.commons.collections.primitives.adapters; + +import org.apache.commons.collections.primitives.IntCollection; + +/** + * @since Commons Collections 2.2 + * @version $Revision: 1.1 $ $Date: 2003/02/28 21:21:51 $ + * @author Rodney Waldhoff + */ +final class NonSerializableIntCollectionCollection extends AbstractIntCollectionCollection { + + /** + * Creates a {@link Collection Collection} wrapping + * the specified {@link IntCollection IntCollection}. + */ + public NonSerializableIntCollectionCollection(IntCollection collection) { + _collection = collection; + } + + protected IntCollection getIntCollection() { + return _collection; + } + + private IntCollection _collection = null; +} diff --git a/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableIntListList.java b/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableIntListList.java new file mode 100644 index 000000000..dc92dea6f --- /dev/null +++ b/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableIntListList.java @@ -0,0 +1,83 @@ +/* + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/NonSerializableIntListList.java,v 1.1 2003/02/28 21:21:51 rwaldhoff Exp $ + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.commons.collections.primitives.adapters; + +import org.apache.commons.collections.primitives.IntList; + +/** + * @since Commons Collections 2.2 + * @version $Revision: 1.1 $ $Date: 2003/02/28 21:21:51 $ + * @author Rodney Waldhoff + */ +final class NonSerializableIntListList extends AbstractIntListList { + + /** + * Creates a {@link List List} wrapping + * the specified {@link IntList IntList}. + */ + public NonSerializableIntListList(IntList list) { + _list = list; + } + + protected IntList getIntList() { + return _list; + } + + private IntList _list = null; + +} diff --git a/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableListIntList.java b/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableListIntList.java index b14ad7217..1518ba261 100644 --- a/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableListIntList.java +++ b/src/java/org/apache/commons/collections/primitives/adapters/NonSerializableListIntList.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/NonSerializableListIntList.java,v 1.1 2003/02/28 00:17:53 rwaldhoff Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/NonSerializableListIntList.java,v 1.2 2003/02/28 21:21:51 rwaldhoff Exp $ * ==================================================================== * The Apache Software License, Version 1.1 * @@ -62,10 +62,10 @@ import java.util.List; /** * * @since Commons Collections 2.2 - * @version $Revision: 1.1 $ $Date: 2003/02/28 00:17:53 $ + * @version $Revision: 1.2 $ $Date: 2003/02/28 21:21:51 $ * @author Rodney Waldhoff */ -class NonSerializableListIntList extends AbstractListIntList { +final class NonSerializableListIntList extends AbstractListIntList { protected NonSerializableListIntList(List list) { _list = list; diff --git a/src/test/org/apache/commons/collections/primitives/TestArrayIntList.java b/src/test/org/apache/commons/collections/primitives/TestArrayIntList.java index 6f85f26a5..6b78855cf 100644 --- a/src/test/org/apache/commons/collections/primitives/TestArrayIntList.java +++ b/src/test/org/apache/commons/collections/primitives/TestArrayIntList.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestArrayIntList.java,v 1.9 2003/02/28 00:17:53 rwaldhoff Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestArrayIntList.java,v 1.10 2003/02/28 21:21:51 rwaldhoff Exp $ * ==================================================================== * The Apache Software License, Version 1.1 * @@ -63,7 +63,7 @@ import junit.framework.TestSuite; import org.apache.commons.collections.BulkTest; /** - * @version $Revision: 1.9 $ $Date: 2003/02/28 00:17:53 $ + * @version $Revision: 1.10 $ $Date: 2003/02/28 21:21:51 $ * @author Rodney Waldhoff */ public class TestArrayIntList extends TestIntList { @@ -76,8 +76,7 @@ public class TestArrayIntList extends TestIntList { } public static Test suite() { - // BulkTests won't work, sublists are not serializable - TestSuite suite = new TestSuite(TestArrayIntList.class); + TestSuite suite = BulkTest.makeSuite(TestArrayIntList.class); return suite; } @@ -88,6 +87,20 @@ public class TestArrayIntList extends TestIntList { return new ArrayIntList(); } + public String[] ignoredSimpleTests() { + // sublists are not serializable + return new String[] { + "TestArrayIntList.bulkTestSubList.testFullListSerialization", + "TestArrayIntList.bulkTestSubList.testEmptyListSerialization", + "TestArrayIntList.bulkTestSubList.testCanonicalEmptyCollectionExists", + "TestArrayIntList.bulkTestSubList.testCanonicalFullCollectionExists", + "TestArrayIntList.bulkTestSubList.testEmptyListCompatibility", + "TestArrayIntList.bulkTestSubList.testFullListCompatibility", + "TestArrayIntList.bulkTestSubList.testSerializeDeserializeThenCompare", + "TestArrayIntList.bulkTestSubList.testSimpleSerialization" + }; + } + // tests // ------------------------------------------------------------------------ diff --git a/src/test/org/apache/commons/collections/primitives/TestArrayUnsignedShortList.java b/src/test/org/apache/commons/collections/primitives/TestArrayUnsignedShortList.java index 1c6f0e13e..2f317bbdb 100644 --- a/src/test/org/apache/commons/collections/primitives/TestArrayUnsignedShortList.java +++ b/src/test/org/apache/commons/collections/primitives/TestArrayUnsignedShortList.java @@ -1,5 +1,5 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestArrayUnsignedShortList.java,v 1.9 2003/02/28 00:17:53 rwaldhoff Exp $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestArrayUnsignedShortList.java,v 1.10 2003/02/28 21:21:51 rwaldhoff Exp $ * ==================================================================== * The Apache Software License, Version 1.1 * @@ -63,7 +63,7 @@ import junit.framework.TestSuite; import org.apache.commons.collections.BulkTest; /** - * @version $Revision: 1.9 $ $Date: 2003/02/28 00:17:53 $ + * @version $Revision: 1.10 $ $Date: 2003/02/28 21:21:51 $ * @author Rodney Waldhoff */ public class TestArrayUnsignedShortList extends TestIntList { @@ -76,8 +76,8 @@ public class TestArrayUnsignedShortList extends TestIntList { } public static Test suite() { - // BulkTests won't work, sublists are not serializable - return new TestSuite(TestArrayUnsignedShortList.class); + TestSuite suite = BulkTest.makeSuite(TestArrayUnsignedShortList.class); + return suite; } // collections testing framework @@ -87,6 +87,20 @@ public class TestArrayUnsignedShortList extends TestIntList { return new ArrayUnsignedShortList(); } + public String[] ignoredSimpleTests() { + // sublists are not serializable + return new String[] { + "TestArrayUnsignedShortList.bulkTestSubList.testFullListSerialization", + "TestArrayUnsignedShortList.bulkTestSubList.testEmptyListSerialization", + "TestArrayUnsignedShortList.bulkTestSubList.testCanonicalEmptyCollectionExists", + "TestArrayUnsignedShortList.bulkTestSubList.testCanonicalFullCollectionExists", + "TestArrayUnsignedShortList.bulkTestSubList.testEmptyListCompatibility", + "TestArrayUnsignedShortList.bulkTestSubList.testFullListCompatibility", + "TestArrayUnsignedShortList.bulkTestSubList.testSerializeDeserializeThenCompare", + "TestArrayUnsignedShortList.bulkTestSubList.testSimpleSerialization" + }; + } + // tests // ------------------------------------------------------------------------