You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rw...@apache.org on 2003/01/09 14:40:11 UTC
cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/primitives TestArrayIntList.java TestArrayUnsignedShortList.java
rwaldhoff 2003/01/09 05:40:11
Modified: collections/src/java/org/apache/commons/collections/primitives
AbstractRandomAccessIntList.java IntList.java
package.html
collections/src/test/org/apache/commons/collections/primitives
TestArrayIntList.java
TestArrayUnsignedShortList.java
Added: collections/src/java/org/apache/commons/collections/primitives/adapters
CollectionIntCollection.java
IntCollectionCollection.java
IntIteratorIterator.java IntListIterator.java
IntListIteratorListIterator.java IntListList.java
IteratorIntIterator.java ListIntList.java
ListIteratorIntListIterator.java package.html
Removed: collections/src/java/org/apache/commons/collections/primitives
CollectionIntCollection.java
IntCollectionCollection.java
IntIteratorIterator.java IntListIterator.java
IntListIteratorListIterator.java IntListList.java
IteratorIntIterator.java ListIntList.java
ListIteratorIntListIterator.java
Log:
move primitive/object adapters down to adapter sub-package
Revision Changes Path
1.5 +5 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/AbstractRandomAccessIntList.java
Index: AbstractRandomAccessIntList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/AbstractRandomAccessIntList.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractRandomAccessIntList.java 7 Jan 2003 13:24:52 -0000 1.4
+++ AbstractRandomAccessIntList.java 9 Jan 2003 13:40:10 -0000 1.5
@@ -62,8 +62,9 @@
package org.apache.commons.collections.primitives;
import java.util.ConcurrentModificationException;
-import java.util.List;
import java.util.NoSuchElementException;
+
+import org.apache.commons.collections.primitives.adapters.IntListIterator;
public abstract class AbstractRandomAccessIntList extends AbstractIntCollection implements IntList {
1.4 +6 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/IntList.java
Index: IntList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/IntList.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IntList.java 6 Jan 2003 03:59:12 -0000 1.3
+++ IntList.java 9 Jan 2003 13:40:10 -0000 1.4
@@ -61,6 +61,8 @@
package org.apache.commons.collections.primitives;
+import org.apache.commons.collections.primitives.adapters.IntListIterator;
+
/**
* An ordered collection (a {@link java.util.List}) of int values.
*
1.4 +2 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/package.html
Index: package.html
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/package.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- package.html 5 Jan 2003 13:33:05 -0000 1.3
+++ package.html 9 Jan 2003 13:40:11 -0000 1.4
@@ -20,9 +20,7 @@
implementations of these.
</p>
<p>
- Adapters are provided for converting between the
- primitive and object based versions of the collections
- framework.
+ Also see {@link org.apache.commons.collections.primitives.adapters}.
</p>
</body>
</html>
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/CollectionIntCollection.java
Index: CollectionIntCollection.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/CollectionIntCollection.java,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $
* $Revision: 1.1 $
* $Date: 2003/01/09 13:40:11 $
*
* ====================================================================
*
* 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements 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 Group.
*
* 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;
/**
* Adapts a {@link java.lang.Number Number} valued
* {@link java.util.Collection Collection} to the
* {@link IntCollection} interface.
*
* @version $Revision: 1.1 $ $Date: 2003/01/09 13:40:11 $
* @author Rodney Waldhoff
*/
public class CollectionIntCollection implements IntCollection {
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();
}
public boolean contains(int element) {
return _collection.contains(new Integer(element));
}
public boolean containsAll(IntCollection c) {
return _collection.containsAll(IntCollectionCollection.wrap(c));
}
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();
}
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;
}
public static IntCollection wrap(Collection collection) {
return null == collection ? null : new CollectionIntCollection(collection);
}
private Collection _collection = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntCollectionCollection.java
Index: IntCollectionCollection.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntCollectionCollection.java,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $
* $Revision: 1.1 $
* $Date: 2003/01/09 13:40:11 $
*
* ====================================================================
*
* 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements 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 Group.
*
* 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.lang.reflect.Array;
import java.util.Collection;
import java.util.Iterator;
import org.apache.commons.collections.primitives.IntCollection;
/**
* Adapts an {@link IntCollection} to the
* {@link java.util.Collection Collection} interface.
*
* @version $Revision: 1.1 $ $Date: 2003/01/09 13:40:11 $
* @author Rodney Waldhoff
*/
public class IntCollectionCollection implements Collection {
public IntCollectionCollection(IntCollection collection) {
_collection = collection;
}
public boolean add(Object element) {
return _collection.add(((Number)element).intValue());
}
public boolean addAll(Collection c) {
return _collection.addAll(CollectionIntCollection.wrap(c));
}
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));
}
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();
}
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;i++) {
A[i] = new Integer(a[i]);
}
return A;
}
public Object[] toArray(Object[] A) {
int[] a = _collection.toArray();
if(A.length < a.length) {
A = (Object[])(Array.newInstance(A.getClass().getComponentType(), a.length));
}
for(int i=0;i<a.length;i++) {
A[i] = new Integer(a[i]);
}
if(A.length > a.length) {
A[a.length] = null;
}
return A;
}
public static Collection wrap(IntCollection collection) {
return null == collection ? null : new IntCollectionCollection(collection);
}
private IntCollection _collection = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntIteratorIterator.java
Index: IntIteratorIterator.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntIteratorIterator.java,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $
* $Revision: 1.1 $
* $Date: 2003/01/09 13:40:11 $
*
* ====================================================================
*
* 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements 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 Group.
*
* 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.Iterator;
import org.apache.commons.collections.primitives.IntIterator;
/**
* Adapts an {@link IntIterator} to the
* {@link java.util.Iterator Iterator} interface.
*
* @version $Revision: 1.1 $ $Date: 2003/01/09 13:40:11 $
* @author Rodney Waldhoff
*/
public class IntIteratorIterator implements Iterator {
public IntIteratorIterator(IntIterator iterator) {
_iterator = iterator;
}
public boolean hasNext() {
return _iterator.hasNext();
}
public Object next() {
return new Integer(_iterator.next());
}
public void remove() {
_iterator.remove();
}
public static Iterator wrap(IntIterator iterator) {
return null == iterator ? null : new IntIteratorIterator(iterator);
}
private IntIterator _iterator = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntListIterator.java
Index: IntListIterator.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntListIterator.java,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $
* $Revision: 1.1 $
* $Date: 2003/01/09 13:40:11 $
*
* ====================================================================
*
* 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements 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 Group.
*
* 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 org.apache.commons.collections.primitives.IntIterator;
/**
* A {@link java.util.ListIterator list iterator} over int values.
*
* @version $Revision: 1.1 $ $Date: 2003/01/09 13:40:11 $
* @author Rodney Waldhoff
*/
public interface IntListIterator extends IntIterator {
void add(int element);
boolean hasNext();
boolean hasPrevious();
int next();
int nextIndex();
int previous();
int previousIndex();
void remove();
void set(int element);
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntListIteratorListIterator.java
Index: IntListIteratorListIterator.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntListIteratorListIterator.java,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $
* $Revision: 1.1 $
* $Date: 2003/01/09 13:40:11 $
*
* ====================================================================
*
* 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements 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 Group.
*
* 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.ListIterator;
/**
* Adapts an {@link IntListIterator} to the
* {@link java.util.ListIterator ListIterator} interface.
*
* @version $Revision: 1.1 $ $Date: 2003/01/09 13:40:11 $
* @author Rodney Waldhoff
*/
public class IntListIteratorListIterator implements ListIterator {
public IntListIteratorListIterator(IntListIterator iterator) {
_iterator = iterator;
}
public int nextIndex() {
return _iterator.nextIndex();
}
public int previousIndex() {
return _iterator.previousIndex();
}
public boolean hasNext() {
return _iterator.hasNext();
}
public boolean hasPrevious() {
return _iterator.hasPrevious();
}
public Object next() {
return new Integer(_iterator.next());
}
public Object previous() {
return new Integer(_iterator.previous());
}
public void add(Object obj) {
_iterator.add(((Number)obj).intValue());
}
public void set(Object obj) {
_iterator.set(((Number)obj).intValue());
}
public void remove() {
_iterator.remove();
}
public static ListIterator wrap(IntListIterator iterator) {
return null == iterator ? null : new IntListIteratorListIterator(iterator);
}
private IntListIterator _iterator = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntListList.java
Index: IntListList.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IntListList.java,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $
* $Revision: 1.1 $
* $Date: 2003/01/09 13:40:11 $
*
* ====================================================================
*
* 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements 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 Group.
*
* 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 java.util.ListIterator;
import org.apache.commons.collections.primitives.IntList;
/**
* Adapts an {@link IntList} to the
* {@link java.util.List List} interface.
*
* @version $Revision: 1.1 $ $Date: 2003/01/09 13:40:11 $
* @author Rodney Waldhoff
*/
public class IntListList extends IntCollectionCollection implements List {
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());
}
public ListIterator listIterator() {
return IntListIteratorListIterator.wrap(_list.listIterator());
}
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 that) {
if(that instanceof List) {
try {
return _list.equals(ListIntList.wrap((List)that));
} catch(NullPointerException e) {
return false;
} catch(ClassCastException e) {
return false;
}
} else {
return super.equals(that);
}
}
public static List wrap(IntList list) {
return null == list ? null : new IntListList(list);
}
private IntList _list = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IteratorIntIterator.java
Index: IteratorIntIterator.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/IteratorIntIterator.java,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $
* $Revision: 1.1 $
* $Date: 2003/01/09 13:40:11 $
*
* ====================================================================
*
* 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements 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 Group.
*
* 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.Iterator;
import org.apache.commons.collections.primitives.IntIterator;
/**
* Adapts a {@link java.lang.Number Number}-valued
* {@link java.util.Iterator Iterator}
* to the {@link IntIterator} interface.
*
* @version $Revision: 1.1 $ $Date: 2003/01/09 13:40:11 $
* @author Rodney Waldhoff
*
*/
public class IteratorIntIterator implements IntIterator {
public IteratorIntIterator(Iterator iterator) {
_iterator = iterator;
}
public boolean hasNext() {
return _iterator.hasNext();
}
public int next() {
return ((Number)(_iterator.next())).intValue();
}
public void remove() {
_iterator.remove();
}
public static IntIterator wrap(Iterator iterator) {
return null == iterator ? null : new IteratorIntIterator(iterator);
}
private Iterator _iterator = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/ListIntList.java
Index: ListIntList.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/ListIntList.java,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $
* $Revision: 1.1 $
* $Date: 2003/01/09 13:40:11 $
*
* ====================================================================
*
* 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements 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 Group.
*
* 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;
import org.apache.commons.collections.primitives.IntCollection;
import org.apache.commons.collections.primitives.IntList;
/**
* Adapts a {@link Number}-valued {@link java.util.List List}
* to the {@link IntList} interface.
*
* @version $Revision: 1.1 $ $Date: 2003/01/09 13:40:11 $
* @author Rodney Waldhoff
*/
public class ListIntList extends CollectionIntCollection implements IntList {
public ListIntList(List list) {
super(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));
}
public IntListIterator listIterator() {
return ListIteratorIntListIterator.wrap(_list.listIterator());
}
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 that) {
if(that instanceof IntList) {
return _list.equals(IntListList.wrap((IntList)that));
} else {
return super.equals(that);
}
}
public static IntList wrap(List list) {
return null == list ? null : new ListIntList(list);
}
private List _list = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/ListIteratorIntListIterator.java
Index: ListIteratorIntListIterator.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/ListIteratorIntListIterator.java,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $
* $Revision: 1.1 $
* $Date: 2003/01/09 13:40:11 $
*
* ====================================================================
*
* 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements 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 Group.
*
* 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.ListIterator;
/**
* Adapts a {@link Number}-valued {@link java.util.ListIterator}
* to the {@link IntListIterator} interface.
*
* @version $Revision: 1.1 $ $Date: 2003/01/09 13:40:11 $
* @author Rodney Waldhoff
*/
public class ListIteratorIntListIterator implements IntListIterator {
public ListIteratorIntListIterator(ListIterator iterator) {
_iterator = iterator;
}
public int nextIndex() {
return _iterator.nextIndex();
}
public int previousIndex() {
return _iterator.previousIndex();
}
public boolean hasNext() {
return _iterator.hasNext();
}
public boolean hasPrevious() {
return _iterator.hasPrevious();
}
public int next() {
return ((Number)_iterator.next()).intValue();
}
public int previous() {
return ((Number)_iterator.previous()).intValue();
}
public void add(int element) {
_iterator.add(new Integer(element));
}
public void set(int element) {
_iterator.set(new Integer(element));
}
public void remove() {
_iterator.remove();
}
public static IntListIterator wrap(ListIterator iterator) {
return null == iterator ? null : new ListIteratorIntListIterator(iterator);
}
private ListIterator _iterator = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/adapters/package.html
Index: package.html
===================================================================
<!-- $Id: package.html,v 1.1 2003/01/09 13:40:11 rwaldhoff Exp $ -->
<html>
<head>
<title>Package Documentation for org.apache.commons.collections.primitives.adapters</title>
</head>
<body>
<p>
Adapters for converting between the
{@link org.apache.commons.primitives primitive} and
{@link java.util object} based versions of the collections
framework.
</p>
</body>
</html>
1.4 +6 -4 jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/TestArrayIntList.java
Index: TestArrayIntList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/TestArrayIntList.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestArrayIntList.java 7 Jan 2003 13:24:52 -0000 1.3
+++ TestArrayIntList.java 9 Jan 2003 13:40:11 -0000 1.4
@@ -69,6 +69,8 @@
import org.apache.commons.collections.BulkTest;
import org.apache.commons.collections.TestList;
+import org.apache.commons.collections.primitives.adapters.IntListList;
+import org.apache.commons.collections.primitives.adapters.ListIntList;
/**
* @version $Revision$ $Date$
1.2 +4 -3 jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/TestArrayUnsignedShortList.java
Index: TestArrayUnsignedShortList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/TestArrayUnsignedShortList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestArrayUnsignedShortList.java 7 Jan 2003 18:04:52 -0000 1.1
+++ TestArrayUnsignedShortList.java 9 Jan 2003 13:40:11 -0000 1.2
@@ -68,6 +68,7 @@
import org.apache.commons.collections.BulkTest;
import org.apache.commons.collections.TestList;
+import org.apache.commons.collections.primitives.adapters.IntListList;
/**
* @version $Revision$ $Date$
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>