toward better serialization contract support in sublists

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130981 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rodney Waldhoff 2003-02-28 00:17:56 +00:00
parent 9697e648ba
commit 02687ec175
11 changed files with 548 additions and 206 deletions

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractRandomAccessIntList.java,v 1.11 2003/02/26 19:17:22 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractRandomAccessIntList.java,v 1.12 2003/02/28 00:17:52 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -57,7 +57,6 @@
package org.apache.commons.collections.primitives;
import java.io.Serializable;
import java.util.ConcurrentModificationException;
import java.util.NoSuchElementException;
@ -75,11 +74,11 @@ import java.util.NoSuchElementException;
* to provide a more efficient implementation.
*
* @since Commons Collections 2.2
* @version $Revision: 1.11 $ $Date: 2003/02/26 19:17:22 $
* @version $Revision: 1.12 $ $Date: 2003/02/28 00:17:52 $
*
* @author Rodney Waldhoff
*/
public abstract class AbstractRandomAccessIntList extends AbstractIntCollection implements IntList, Serializable {
public abstract class AbstractRandomAccessIntList extends AbstractIntCollection implements IntList {
// constructors
//-------------------------------------------------------------------------
@ -251,7 +250,7 @@ public abstract class AbstractRandomAccessIntList extends AbstractIntCollection
// inner classes
//-------------------------------------------------------------------------
private static class ComodChecker implements Serializable {
private static class ComodChecker {
ComodChecker(AbstractRandomAccessIntList source) {
_source = source;
resyncModCount();
@ -368,7 +367,7 @@ public abstract class AbstractRandomAccessIntList extends AbstractIntCollection
private int _lastReturnedIndex = -1;
}
protected static class RandomAccessIntSubList extends AbstractRandomAccessIntList implements IntList, Serializable {
protected static class RandomAccessIntSubList extends AbstractRandomAccessIntList implements IntList {
RandomAccessIntSubList(AbstractRandomAccessIntList list, int fromIndex, int toIndex) {
if(fromIndex < 0 || toIndex > list.size() || fromIndex > toIndex) {
throw new IndexOutOfBoundsException();

View File

@ -0,0 +1,151 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/AbstractCollectionIntCollection.java,v 1.1 2003/02/28 00:17:53 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
* <http://www.apache.org/>.
*
*/
package org.apache.commons.collections.primitives.adapters;
import java.util.Collection;
import org.apache.commons.collections.primitives.IntCollection;
import org.apache.commons.collections.primitives.IntIterator;
/**
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/02/28 00:17:53 $
* @author Rodney Waldhoff
*/
abstract class AbstractCollectionIntCollection implements IntCollection {
protected AbstractCollectionIntCollection() {
}
public boolean add(int element) {
return getCollection().add(new Integer(element));
}
public boolean addAll(IntCollection c) {
return getCollection().addAll(IntCollectionCollection.wrap(c));
}
public void clear() {
getCollection().clear();
}
public boolean contains(int element) {
return getCollection().contains(new Integer(element));
}
public boolean containsAll(IntCollection c) {
return getCollection().containsAll(IntCollectionCollection.wrap(c));
}
public String toString() {
return getCollection().toString();
}
public boolean isEmpty() {
return getCollection().isEmpty();
}
/**
* {@link IteratorIntIterator#wrap wraps} the
* {@link java.util.Iterator Iterator}
* returned by my underlying
* {@link Collection Collection},
* if any.
*/
public IntIterator iterator() {
return IteratorIntIterator.wrap(getCollection().iterator());
}
public boolean removeElement(int element) {
return getCollection().remove(new Integer(element));
}
public boolean removeAll(IntCollection c) {
return getCollection().removeAll(IntCollectionCollection.wrap(c));
}
public boolean retainAll(IntCollection c) {
return getCollection().retainAll(IntCollectionCollection.wrap(c));
}
public int size() {
return getCollection().size();
}
public int[] toArray() {
Object[] src = getCollection().toArray();
int[] dest = new int[src.length];
for(int i=0;i<src.length;i++) {
dest[i] = ((Number)(src[i])).intValue();
}
return dest;
}
public int[] toArray(int[] dest) {
Object[] src = getCollection().toArray();
if(dest.length < src.length) {
dest = new int[src.length];
}
for(int i=0;i<src.length;i++) {
dest[i] = ((Number)(src[i])).intValue();
}
return dest;
}
protected abstract Collection getCollection();
}

View File

@ -0,0 +1,161 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/adapters/Attic/AbstractListIntList.java,v 1.1 2003/02/28 00:17:53 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
* <http://www.apache.org/>.
*
*/
package org.apache.commons.collections.primitives.adapters;
import java.util.Collection;
import java.util.List;
import org.apache.commons.collections.primitives.IntCollection;
import org.apache.commons.collections.primitives.IntIterator;
import org.apache.commons.collections.primitives.IntList;
import org.apache.commons.collections.primitives.IntListIterator;
/**
*
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/02/28 00:17:53 $
* @author Rodney Waldhoff
*/
abstract class AbstractListIntList extends AbstractCollectionIntCollection implements IntList {
public void add(int index, int element) {
getList().add(index,new Integer(element));
}
public boolean addAll(int index, IntCollection collection) {
return getList().addAll(index,IntCollectionCollection.wrap(collection));
}
public int get(int index) {
return ((Number)getList().get(index)).intValue();
}
public int indexOf(int element) {
return getList().indexOf(new Integer(element));
}
public int lastIndexOf(int element) {
return getList().lastIndexOf(new Integer(element));
}
/**
* {@link ListIteratorIntListIterator#wrap wraps} the
* {@link IntList IntList}
* returned by my underlying
* {@link IntListIterator IntListIterator},
* if any.
*/
public IntListIterator listIterator() {
return ListIteratorIntListIterator.wrap(getList().listIterator());
}
/**
* {@link ListIteratorIntListIterator#wrap wraps} the
* {@link IntList IntList}
* returned by my underlying
* {@link IntListIterator IntListIterator},
* if any.
*/
public IntListIterator listIterator(int index) {
return ListIteratorIntListIterator.wrap(getList().listIterator(index));
}
public int removeElementAt(int index) {
return ((Number)getList().remove(index)).intValue();
}
public int set(int index, int element) {
return ((Number)getList().set(index,new Integer(element))).intValue();
}
public IntList subList(int fromIndex, int toIndex) {
return ListIntList.wrap(getList().subList(fromIndex,toIndex));
}
public boolean equals(Object obj) {
if(obj instanceof IntList) {
IntList that = (IntList)obj;
if(this == that) {
return true;
} else if(this.size() != that.size()) {
return false;
} else {
IntIterator thisiter = iterator();
IntIterator thatiter = that.iterator();
while(thisiter.hasNext()) {
if(thisiter.next() != thatiter.next()) {
return false;
}
}
return true;
}
} else {
return false;
}
}
public int hashCode() {
return getList().hashCode();
}
final protected Collection getCollection() {
return getList();
}
abstract protected List getList();
}

View File

@ -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.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/CollectionIntCollection.java,v 1.5 2003/02/28 00:17:53 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -61,7 +61,6 @@ import java.io.Serializable;
import java.util.Collection;
import org.apache.commons.collections.primitives.IntCollection;
import org.apache.commons.collections.primitives.IntIterator;
/**
* Adapts a {@link java.lang.Number Number}-valued
@ -73,10 +72,10 @@ import org.apache.commons.collections.primitives.IntIterator;
* 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 00:17:53 $
* @author Rodney Waldhoff
*/
public class CollectionIntCollection implements IntCollection, Serializable {
public class CollectionIntCollection extends AbstractCollectionIntCollection implements Serializable {
/**
* Create an {@link IntCollection IntCollection} wrapping
* the specified {@link Collection Collection}. When
@ -89,7 +88,13 @@ public class CollectionIntCollection implements IntCollection, Serializable {
* <code>null</code>.
*/
public static IntCollection wrap(Collection collection) {
return null == collection ? null : new CollectionIntCollection(collection);
if(null == collection) {
return null;
} else if(collection instanceof Serializable) {
return new CollectionIntCollection(collection);
} else {
return new NonSerializableCollectionIntCollection(collection);
}
}
/**
@ -106,101 +111,10 @@ public class CollectionIntCollection implements IntCollection, Serializable {
public CollectionIntCollection(Collection collection) {
_collection = collection;
}
public boolean add(int element) {
return _collection.add(new Integer(element));
}
public boolean addAll(IntCollection c) {
return _collection.addAll(IntCollectionCollection.wrap(c));
}
public void clear() {
_collection.clear();
protected Collection getCollection() {
return _collection;
}
public boolean contains(int element) {
return _collection.contains(new Integer(element));
}
public boolean containsAll(IntCollection c) {
return _collection.containsAll(IntCollectionCollection.wrap(c));
}
/**
* If <i>that</i> is an {@link IntCollection IntCollection},
* it is {@link IntCollectionCollection#wrap wrapped} and
* compared to my underlying {@link Collection Collection}, otherwise
* this method simply delegates to my underlying
* {@link Collection Collection}.
*/
public boolean equals(Object that) {
if(that instanceof IntCollection) {
return _collection.equals(IntCollectionCollection.wrap((IntCollection)that));
} else {
return _collection.equals(that);
}
}
public int hashCode() {
return _collection.hashCode();
}
public String toString() {
return _collection.toString();
}
public boolean isEmpty() {
return _collection.isEmpty();
}
/**
* {@link IteratorIntIterator#wrap wraps} the
* {@link java.util.Iterator Iterator}
* returned by my underlying
* {@link Collection Collection},
* if any.
*/
public IntIterator iterator() {
return IteratorIntIterator.wrap(_collection.iterator());
}
public boolean removeElement(int element) {
return _collection.remove(new Integer(element));
}
public boolean removeAll(IntCollection c) {
return _collection.removeAll(IntCollectionCollection.wrap(c));
}
public boolean retainAll(IntCollection c) {
return _collection.retainAll(IntCollectionCollection.wrap(c));
}
public int size() {
return _collection.size();
}
public int[] toArray() {
Object[] src = _collection.toArray();
int[] dest = new int[src.length];
for(int i=0;i<src.length;i++) {
dest[i] = ((Number)(src[i])).intValue();
}
return dest;
}
public int[] toArray(int[] dest) {
Object[] src = _collection.toArray();
if(dest.length < src.length) {
dest = new int[src.length];
}
for(int i=0;i<src.length;i++) {
dest[i] = ((Number)(src[i])).intValue();
}
return dest;
}
private Collection _collection = null;
private Collection _collection = null;
}

View File

@ -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/ListIntList.java,v 1.5 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/ListIntList.java,v 1.6 2003/02/28 00:17:53 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -60,10 +60,7 @@ package org.apache.commons.collections.primitives.adapters;
import java.io.Serializable;
import java.util.List;
import org.apache.commons.collections.primitives.IntCollection;
import org.apache.commons.collections.primitives.IntIterator;
import org.apache.commons.collections.primitives.IntList;
import org.apache.commons.collections.primitives.IntListIterator;
/**
* Adapts a {@link Number}-valued {@link List List}
@ -74,10 +71,10 @@ import org.apache.commons.collections.primitives.IntListIterator;
* implementation in the "obvious" way.
*
* @since Commons Collections 2.2
* @version $Revision: 1.5 $ $Date: 2003/02/26 19:17:23 $
* @version $Revision: 1.6 $ $Date: 2003/02/28 00:17:53 $
* @author Rodney Waldhoff
*/
public class ListIntList extends CollectionIntCollection implements IntList, Serializable {
public class ListIntList extends AbstractListIntList implements Serializable {
/**
* Create an {@link IntList IntList} wrapping
@ -92,7 +89,13 @@ public class ListIntList extends CollectionIntCollection implements IntList, Ser
* <code>null</code>.
*/
public static IntList wrap(List list) {
return null == list ? null : new ListIntList(list);
if(null == list) {
return null;
} else if(list instanceof Serializable) {
return new ListIntList(list);
} else {
return new NonSerializableListIntList(list);
}
}
/**
@ -107,86 +110,13 @@ public class ListIntList extends CollectionIntCollection implements IntList, Ser
* @see #wrap
*/
public ListIntList(List list) {
super(list);
_list = list;
_list = list;
}
public void add(int index, int element) {
_list.add(index,new Integer(element));
}
public boolean addAll(int index, IntCollection collection) {
return _list.addAll(index,IntCollectionCollection.wrap(collection));
}
public int get(int index) {
return ((Number)_list.get(index)).intValue();
}
public int indexOf(int element) {
return _list.indexOf(new Integer(element));
}
public int lastIndexOf(int element) {
return _list.lastIndexOf(new Integer(element));
}
/**
* {@link ListIteratorIntListIterator#wrap wraps} the
* {@link IntList IntList}
* returned by my underlying
* {@link IntListIterator IntListIterator},
* if any.
*/
public IntListIterator listIterator() {
return ListIteratorIntListIterator.wrap(_list.listIterator());
}
/**
* {@link ListIteratorIntListIterator#wrap wraps} the
* {@link IntList IntList}
* returned by my underlying
* {@link IntListIterator IntListIterator},
* if any.
*/
public IntListIterator listIterator(int index) {
return ListIteratorIntListIterator.wrap(_list.listIterator(index));
}
public int removeElementAt(int index) {
return ((Number)_list.remove(index)).intValue();
}
public int set(int index, int element) {
return ((Number)_list.set(index,new Integer(element))).intValue();
}
public IntList subList(int fromIndex, int toIndex) {
return ListIntList.wrap(_list.subList(fromIndex,toIndex));
}
public boolean equals(Object obj) {
if(obj instanceof IntList) {
IntList that = (IntList)obj;
if(this == that) {
return true;
} else if(this.size() != that.size()) {
return false;
} else {
IntIterator thisiter = iterator();
IntIterator thatiter = that.iterator();
while(thisiter.hasNext()) {
if(thisiter.next() != thatiter.next()) {
return false;
}
}
return true;
}
} else {
return false;
}
protected List getList() {
return _list;
}
private List _list = null;
}

View File

@ -0,0 +1,78 @@
/*
* $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 $
* ====================================================================
* 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
* <http://www.apache.org/>.
*
*/
package org.apache.commons.collections.primitives.adapters;
import java.util.Collection;
/**
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/02/28 00:17:53 $
* @author Rodney Waldhoff
*/
class NonSerializableCollectionIntCollection extends AbstractCollectionIntCollection {
public NonSerializableCollectionIntCollection(Collection collection) {
_collection = collection;
}
protected Collection getCollection() {
return _collection;
}
private Collection _collection = null;
}

View File

@ -0,0 +1,80 @@
/*
* $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 $
* ====================================================================
* 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
* <http://www.apache.org/>.
*
*/
package org.apache.commons.collections.primitives.adapters;
import java.util.List;
/**
*
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/02/28 00:17:53 $
* @author Rodney Waldhoff
*/
class NonSerializableListIntList extends AbstractListIntList {
protected NonSerializableListIntList(List list) {
_list = list;
}
protected List getList() {
return _list;
}
private List _list = null;
}

View File

@ -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.8 2003/02/26 19:17:23 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.9 2003/02/28 00:17:53 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.8 $ $Date: 2003/02/26 19:17:23 $
* @version $Revision: 1.9 $ $Date: 2003/02/28 00:17:53 $
* @author Rodney Waldhoff
*/
public class TestArrayIntList extends TestIntList {
@ -76,7 +76,7 @@ public class TestArrayIntList extends TestIntList {
}
public static Test suite() {
//TestSuite suite = BulkTest.makeSuite(TestArrayIntList.class);
// BulkTests won't work, sublists are not serializable
TestSuite suite = new TestSuite(TestArrayIntList.class);
return suite;
}

View File

@ -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.8 2003/02/26 19:17:23 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.9 2003/02/28 00:17:53 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.8 $ $Date: 2003/02/26 19:17:23 $
* @version $Revision: 1.9 $ $Date: 2003/02/28 00:17:53 $
* @author Rodney Waldhoff
*/
public class TestArrayUnsignedShortList extends TestIntList {
@ -76,8 +76,7 @@ public class TestArrayUnsignedShortList extends TestIntList {
}
public static Test suite() {
//TestSuite suite = BulkTest.makeSuite(TestArrayUnsignedShortList.class);
//return suite;
// BulkTests won't work, sublists are not serializable
return new TestSuite(TestArrayUnsignedShortList.class);
}

View File

@ -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/TestIntList.java,v 1.5 2003/02/26 19:17:23 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestIntList.java,v 1.6 2003/02/28 00:17:53 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -66,7 +66,7 @@ import org.apache.commons.collections.primitives.adapters.IntListList;
import org.apache.commons.collections.primitives.adapters.ListIntList;
/**
* @version $Revision: 1.5 $ $Date: 2003/02/26 19:17:23 $
* @version $Revision: 1.6 $ $Date: 2003/02/28 00:17:53 $
* @author Rodney Waldhoff
*/
public abstract class TestIntList extends TestList {
@ -173,6 +173,12 @@ public abstract class TestIntList extends TestList {
two.add(1); two.add(2); two.add(3); two.add(5); two.add(8);
assertEquals("Larger non empty lists are equal",one,two);
assertEquals("Equals is symmetric on larger non empty list",two,one);
one.add(9);
two.add(10);
assertTrue(!one.equals(two));
assertTrue(!two.equals(one));
}
public void testIntSubListEquals() {
@ -290,5 +296,18 @@ public abstract class TestIntList extends TestList {
assertEquals(deser,list);
}
public void testIntListSerializeDeserializeThenCompare() throws Exception {
IntList list = makeFullIntList();
if(list instanceof Serializable) {
byte[] ser = writeExternalFormToBytes((Serializable)list);
IntList deser = (IntList)(readExternalFormFromBytes(ser));
assertEquals("obj != deserialize(serialize(obj))",list,deser);
}
}
public void testSubListsAreNotSerializable() throws Exception {
IntList list = makeFullIntList().subList(2,3);
assertTrue( ! (list instanceof Serializable) );
}
}

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestListIntList.java,v 1.1 2003/02/26 19:17:24 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/adapters/Attic/TestListIntList.java,v 1.2 2003/02/28 00:17:56 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
@ -62,11 +62,12 @@ import java.util.ArrayList;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.collections.BulkTest;
import org.apache.commons.collections.primitives.IntList;
import org.apache.commons.collections.primitives.TestIntList;
/**
* @version $Revision: 1.1 $ $Date: 2003/02/26 19:17:24 $
* @version $Revision: 1.2 $ $Date: 2003/02/28 00:17:56 $
* @author Rodney Waldhoff
*/
public class TestListIntList extends TestIntList {
@ -79,16 +80,13 @@ public class TestListIntList extends TestIntList {
}
public static Test suite() {
//TestSuite suite = BulkTest.makeSuite(TestListIntList.class);
// java.util.SubList is not serializable
TestSuite suite = new TestSuite(TestListIntList.class);
TestSuite suite = BulkTest.makeSuite(TestListIntList.class);
return suite;
}
// collections testing framework
// ------------------------------------------------------------------------
/**
* @see org.apache.commons.collections.primitives.TestIntList#makeEmptyIntList()
*/
@ -96,6 +94,20 @@ public class TestListIntList extends TestIntList {
return new ListIntList(new ArrayList());
}
public String[] ignoredSimpleTests() {
// sublists are not serializable
return new String[] {
"TestListIntList.bulkTestSubList.testFullListSerialization",
"TestListIntList.bulkTestSubList.testEmptyListSerialization",
"TestListIntList.bulkTestSubList.testCanonicalEmptyCollectionExists",
"TestListIntList.bulkTestSubList.testCanonicalFullCollectionExists",
"TestListIntList.bulkTestSubList.testEmptyListCompatibility",
"TestListIntList.bulkTestSubList.testFullListCompatibility",
"TestListIntList.bulkTestSubList.testSerializeDeserializeThenCompare",
"TestListIntList.bulkTestSubList.testSimpleSerialization"
};
}
// tests
// ------------------------------------------------------------------------
@ -123,5 +135,4 @@ public class TestListIntList extends TestIntList {
// need to add a serialized form to cvs
}
}