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/05/20 02:44:11 UTC
cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators ProxyIntIterator.java NonSerializableUnmodifiableIntList.java UnmodifiableIntList.java UnmodifiableIntIterator.java ProxyIntListIterator.java BaseUnmodifiableIntList.java UnmodifiableIntListIterator.java
rwaldhoff 2003/05/19 17:44:11
Modified: collections/src/test/org/apache/commons/collections/primitives/decorators
TestAll.java
Added: collections/src/test/org/apache/commons/collections/primitives/decorators
BaseUnmodifiableIntListTest.java
TestUnmodifiableIntList.java
collections/src/java/org/apache/commons/collections/primitives/decorators
ProxyIntIterator.java
NonSerializableUnmodifiableIntList.java
UnmodifiableIntList.java
UnmodifiableIntIterator.java
ProxyIntListIterator.java
BaseUnmodifiableIntList.java
UnmodifiableIntListIterator.java
Log:
add unmodifiableintlist and tests
Revision Changes Path
1.3 +3 -2 jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/TestAll.java
Index: TestAll.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/TestAll.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestAll.java 6 May 2003 00:04:30 -0000 1.2
+++ TestAll.java 20 May 2003 00:44:11 -0000 1.3
@@ -80,6 +80,7 @@
suite.addTest(TestBaseProxyIntCollection.suite());
suite.addTest(TestBaseProxyIntList.suite());
+ suite.addTest(TestUnmodifiableIntList.suite());
return suite;
}
1.1 jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableIntListTest.java
Index: BaseUnmodifiableIntListTest.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableIntListTest.java,v 1.1 2003/05/20 00:44:11 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.decorators;
import junit.framework.TestCase;
import org.apache.commons.collections.primitives.ArrayIntList;
import org.apache.commons.collections.primitives.IntIterator;
import org.apache.commons.collections.primitives.IntList;
import org.apache.commons.collections.primitives.IntListIterator;
/**
* @version $Revision: 1.1 $ $Date: 2003/05/20 00:44:11 $
* @author Rodney Waldhoff
*/
public abstract class BaseUnmodifiableIntListTest extends TestCase {
// conventional
// ------------------------------------------------------------------------
public BaseUnmodifiableIntListTest(String testName) {
super(testName);
}
// framework
// ------------------------------------------------------------------------
protected abstract IntList makeUnmodifiableIntList();
protected IntList makeIntList() {
IntList list = new ArrayIntList();
for(int i=0;i<10;i++) {
list.add(i);
}
return list;
}
// tests
// ------------------------------------------------------------------------
public final void testNotModifiable() throws Exception {
assertListNotModifiable(makeUnmodifiableIntList());
}
public final void testSublistNotModifiable() throws Exception {
IntList list = makeUnmodifiableIntList();
assertListNotModifiable(list.subList(0,list.size()-2));
}
public final void testIteratorNotModifiable() throws Exception {
IntList list = makeUnmodifiableIntList();
assertIteratorNotModifiable(list.iterator());
assertIteratorNotModifiable(list.subList(0,list.size()-2).iterator());
}
public final void testListIteratorNotModifiable() throws Exception {
IntList list = makeUnmodifiableIntList();
assertListIteratorNotModifiable(list.listIterator());
assertListIteratorNotModifiable(list.subList(0,list.size()-2).listIterator());
assertListIteratorNotModifiable(list.listIterator(1));
assertListIteratorNotModifiable(list.subList(0,list.size()-2).listIterator(1));
}
// util
// ------------------------------------------------------------------------
private void assertListIteratorNotModifiable(IntListIterator iter) throws Exception {
assertIteratorNotModifiable(iter);
assertTrue(iter.hasPrevious());
try {
iter.set(2);
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
iter.add(2);
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
}
private void assertIteratorNotModifiable(IntIterator iter) throws Exception {
assertTrue(iter.hasNext());
iter.next();
try {
iter.remove();
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
}
private void assertListNotModifiable(IntList list) throws Exception {
try {
list.add(1);
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
list.add(1,2);
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
list.addAll(makeIntList());
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
list.addAll(1,makeIntList());
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
list.removeElementAt(1);
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
list.removeElement(1);
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
list.removeAll(makeIntList());
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
list.retainAll(makeIntList());
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
list.clear();
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
try {
list.set(1,2);
fail("Expected UnsupportedOperationException");
} catch(UnsupportedOperationException e) {
// expected
}
}
}
1.1 jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/TestUnmodifiableIntList.java
Index: TestUnmodifiableIntList.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/primitives/decorators/TestUnmodifiableIntList.java,v 1.1 2003/05/20 00:44:11 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.decorators;
import java.io.Serializable;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.collections.primitives.IntList;
/**
* @version $Revision: 1.1 $ $Date: 2003/05/20 00:44:11 $
* @author Rodney Waldhoff
*/
public class TestUnmodifiableIntList extends BaseUnmodifiableIntListTest {
// conventional
// ------------------------------------------------------------------------
public TestUnmodifiableIntList(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestUnmodifiableIntList.class);
}
// framework
// ------------------------------------------------------------------------
protected IntList makeUnmodifiableIntList() {
return UnmodifiableIntList.wrap(makeIntList());
}
// tests
// ------------------------------------------------------------------------
public void testWrapNull() {
assertNull(UnmodifiableIntList.wrap(null));
}
public void testWrapUnmodifiableIntList() {
IntList list = makeUnmodifiableIntList();
assertSame(list,UnmodifiableIntList.wrap(list));
}
public void testWrapSerializableIntList() {
IntList list = makeIntList();
assertTrue(list instanceof Serializable);
assertTrue(UnmodifiableIntList.wrap(list) instanceof Serializable);
}
public void testWrapNonSerializableIntList() {
IntList list = makeIntList();
IntList ns = list.subList(0,list.size());
assertTrue(!(ns instanceof Serializable));
assertTrue(!(UnmodifiableIntList.wrap(ns) instanceof Serializable));
}
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/ProxyIntIterator.java
Index: ProxyIntIterator.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/ProxyIntIterator.java,v 1.1 2003/05/20 00:44:11 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.decorators;
import org.apache.commons.collections.primitives.IntIterator;
/**
*
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/05/20 00:44:11 $
*
* @author Rodney Waldhoff
*/
abstract class ProxyIntIterator implements IntIterator {
ProxyIntIterator() {
}
public boolean hasNext() {
return getIterator().hasNext();
}
public int next() {
return getIterator().next();
}
public void remove() {
getIterator().remove();
}
protected abstract IntIterator getIterator();
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/NonSerializableUnmodifiableIntList.java
Index: NonSerializableUnmodifiableIntList.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/NonSerializableUnmodifiableIntList.java,v 1.1 2003/05/20 00:44:11 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.decorators;
import org.apache.commons.collections.primitives.IntList;
/**
*
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/05/20 00:44:11 $
*
* @author Rodney Waldhoff
*/
final class NonSerializableUnmodifiableIntList extends BaseUnmodifiableIntList {
NonSerializableUnmodifiableIntList(IntList list) {
this.proxied = list;
}
protected IntList getProxiedList() {
return proxied;
}
private IntList proxied = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/UnmodifiableIntList.java
Index: UnmodifiableIntList.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/UnmodifiableIntList.java,v 1.1 2003/05/20 00:44:11 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.decorators;
import java.io.Serializable;
import org.apache.commons.collections.primitives.IntList;
/**
*
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/05/20 00:44:11 $
*
* @author Rodney Waldhoff
*/
public final class UnmodifiableIntList extends BaseUnmodifiableIntList implements Serializable {
UnmodifiableIntList(IntList list) {
this.proxied = list;
}
public static final IntList wrap(IntList list) {
if(null == list) {
return null;
} else if(list instanceof UnmodifiableIntList) {
return list;
} else if(list instanceof Serializable) {
return new UnmodifiableIntList(list);
} else {
return new NonSerializableUnmodifiableIntList(list);
}
}
protected IntList getProxiedList() {
return proxied;
}
private IntList proxied = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/UnmodifiableIntIterator.java
Index: UnmodifiableIntIterator.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/UnmodifiableIntIterator.java,v 1.1 2003/05/20 00:44:11 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.decorators;
import org.apache.commons.collections.primitives.IntIterator;
/**
*
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/05/20 00:44:11 $
*
* @author Rodney Waldhoff
*/
public final class UnmodifiableIntIterator extends ProxyIntIterator {
UnmodifiableIntIterator(IntIterator iterator) {
this.proxied = iterator;
}
public void remove() {
throw new UnsupportedOperationException("This IntIterator is not modifiable.");
}
protected IntIterator getIterator() {
return proxied;
}
public static final IntIterator wrap(IntIterator iterator) {
if(null == iterator) {
return null;
} else if(iterator instanceof UnmodifiableIntIterator) {
return iterator;
} else {
return new UnmodifiableIntIterator(iterator);
}
}
private IntIterator proxied = null;
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/ProxyIntListIterator.java
Index: ProxyIntListIterator.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/ProxyIntListIterator.java,v 1.1 2003/05/20 00:44:11 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.decorators;
import org.apache.commons.collections.primitives.IntIterator;
import org.apache.commons.collections.primitives.IntListIterator;
/**
*
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/05/20 00:44:11 $
*
* @author Rodney Waldhoff
*/
abstract class ProxyIntListIterator extends ProxyIntIterator implements IntListIterator {
ProxyIntListIterator() {
}
public void add(int element) {
getListIterator().add(element);
}
public boolean hasPrevious() {
return getListIterator().hasPrevious();
}
public int nextIndex() {
return getListIterator().nextIndex();
}
public int previous() {
return getListIterator().previous();
}
public int previousIndex() {
return getListIterator().previousIndex();
}
public void set(int element) {
getListIterator().set(element);
}
protected final IntIterator getIterator() {
return getListIterator();
}
protected abstract IntListIterator getListIterator();
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableIntList.java
Index: BaseUnmodifiableIntList.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/BaseUnmodifiableIntList.java,v 1.1 2003/05/20 00:44:11 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.decorators;
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/05/20 00:44:11 $
*
* @author Rodney Waldhoff
*/
abstract class BaseUnmodifiableIntList extends BaseProxyIntList {
public final void add(int index, int element) {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final boolean addAll(int index, IntCollection collection) {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final int removeElementAt(int index) {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final int set(int index, int element) {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final boolean add(int element) {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final boolean addAll(IntCollection c) {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final void clear() {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final boolean removeAll(IntCollection c) {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final boolean removeElement(int element) {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final boolean retainAll(IntCollection c) {
throw new UnsupportedOperationException("This IntList is not modifiable.");
}
public final IntList subList(int fromIndex, int toIndex) {
return UnmodifiableIntList.wrap(getProxiedList().subList(fromIndex,toIndex));
}
public final IntIterator iterator() {
return UnmodifiableIntIterator.wrap(getProxiedList().iterator());
}
public IntListIterator listIterator() {
return UnmodifiableIntListIterator.wrap(getProxiedList().listIterator());
}
public IntListIterator listIterator(int index) {
return UnmodifiableIntListIterator.wrap(getProxiedList().listIterator(index));
}
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/UnmodifiableIntListIterator.java
Index: UnmodifiableIntListIterator.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/decorators/UnmodifiableIntListIterator.java,v 1.1 2003/05/20 00:44:11 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.decorators;
import org.apache.commons.collections.primitives.IntListIterator;
/**
*
* @since Commons Collections 2.2
* @version $Revision: 1.1 $ $Date: 2003/05/20 00:44:11 $
*
* @author Rodney Waldhoff
*/
public final class UnmodifiableIntListIterator extends ProxyIntListIterator {
UnmodifiableIntListIterator(IntListIterator iterator) {
this.proxied = iterator;
}
public void remove() {
throw new UnsupportedOperationException("This IntListIterator is not modifiable.");
}
public void add(int value) {
throw new UnsupportedOperationException("This IntListIterator is not modifiable.");
}
public void set(int value) {
throw new UnsupportedOperationException("This IntListIterator is not modifiable.");
}
protected IntListIterator getListIterator() {
return proxied;
}
public static final IntListIterator wrap(IntListIterator iterator) {
if(null == iterator) {
return null;
} else if(iterator instanceof UnmodifiableIntListIterator) {
return iterator;
} else {
return new UnmodifiableIntListIterator(iterator);
}
}
private IntListIterator proxied = null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org