Update and make consistent the Unmodifiable decorators
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131396 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
39a29b486d
commit
1064cdbedb
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/bag/AbstractMapBag.java,v 1.3 2003/12/03 01:02:32 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/bag/AbstractMapBag.java,v 1.4 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -62,13 +62,13 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.Bag;
|
||||
import org.apache.commons.collections.set.UnmodifiableSet;
|
||||
|
||||
/**
|
||||
* Abstract implementation of the {@link Bag} interface to simplify the creation
|
||||
|
@ -79,7 +79,7 @@ import org.apache.commons.collections.Bag;
|
|||
* the number of occurrences of that element in the bag.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.3 $ $Date: 2003/12/03 01:02:32 $
|
||||
* @version $Revision: 1.4 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Chuck Burdick
|
||||
* @author Michael A. Smith
|
||||
|
@ -544,7 +544,7 @@ public abstract class AbstractMapBag implements Bag {
|
|||
*/
|
||||
public Set uniqueSet() {
|
||||
if (uniqueSet == null) {
|
||||
uniqueSet = Collections.unmodifiableSet(map.keySet());
|
||||
uniqueSet = UnmodifiableSet.decorate(map.keySet());
|
||||
}
|
||||
return uniqueSet;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java,v 1.1 2003/11/16 00:05:43 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -57,22 +57,24 @@
|
|||
*/
|
||||
package org.apache.commons.collections.bag;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.Bag;
|
||||
import org.apache.commons.collections.Unmodifiable;
|
||||
import org.apache.commons.collections.collection.UnmodifiableCollection;
|
||||
import org.apache.commons.collections.iterators.UnmodifiableIterator;
|
||||
import org.apache.commons.collections.set.UnmodifiableSet;
|
||||
|
||||
/**
|
||||
* Decorates another <code>Bag</code> to ensure it can't be altered.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:43 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class UnmodifiableBag extends UnmodifiableCollection implements Bag {
|
||||
public class UnmodifiableBag extends AbstractBagDecorator implements Unmodifiable {
|
||||
|
||||
/**
|
||||
* Factory method to create an unmodifiable bag.
|
||||
|
@ -98,21 +100,41 @@ public class UnmodifiableBag extends UnmodifiableCollection implements Bag {
|
|||
super(bag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bag being decorated.
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
protected Bag getBag() {
|
||||
return (Bag) getCollection();
|
||||
//-----------------------------------------------------------------------
|
||||
public Iterator iterator() {
|
||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public boolean add(Object o, int count) {
|
||||
public boolean add(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean remove(Object o, int count) {
|
||||
public boolean addAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean retainAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public boolean add(Object object, int count) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean remove(Object object, int count) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -121,8 +143,4 @@ public class UnmodifiableBag extends UnmodifiableCollection implements Bag {
|
|||
return UnmodifiableSet.decorate(set);
|
||||
}
|
||||
|
||||
public int getCount(Object o) {
|
||||
return getBag().getCount(o);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java,v 1.1 2003/11/16 00:05:43 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -57,20 +57,22 @@
|
|||
*/
|
||||
package org.apache.commons.collections.bag;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.collections.SortedBag;
|
||||
import org.apache.commons.collections.Unmodifiable;
|
||||
import org.apache.commons.collections.iterators.UnmodifiableIterator;
|
||||
|
||||
/**
|
||||
* Decorates another <code>SortedBag</code> to ensure it can't be altered.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:43 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class UnmodifiableSortedBag extends UnmodifiableBag implements SortedBag {
|
||||
public class UnmodifiableSortedBag extends AbstractSortedBagDecorator implements Unmodifiable {
|
||||
|
||||
/**
|
||||
* Factory method to create an unmodifiable bag.
|
||||
|
@ -96,26 +98,33 @@ public class UnmodifiableSortedBag extends UnmodifiableBag implements SortedBag
|
|||
super(bag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bag being decorated.
|
||||
*
|
||||
* @return the decorated bag
|
||||
*/
|
||||
protected SortedBag getSortedBag() {
|
||||
return (SortedBag) getCollection();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public Object first() {
|
||||
return getSortedBag().first();
|
||||
public Iterator iterator() {
|
||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
||||
}
|
||||
|
||||
public Object last() {
|
||||
return getSortedBag().last();
|
||||
public boolean add(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Comparator comparator() {
|
||||
return getSortedBag().comparator();
|
||||
public boolean addAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean retainAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java,v 1.1 2003/11/16 00:05:44 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -57,19 +57,22 @@
|
|||
*/
|
||||
package org.apache.commons.collections.buffer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.collections.Buffer;
|
||||
import org.apache.commons.collections.Unmodifiable;
|
||||
import org.apache.commons.collections.collection.UnmodifiableCollection;
|
||||
import org.apache.commons.collections.iterators.UnmodifiableIterator;
|
||||
|
||||
/**
|
||||
* Decorates another <code>Buffer</code> to ensure it can't be altered.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:44 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class UnmodifiableBuffer extends UnmodifiableCollection implements Buffer {
|
||||
public class UnmodifiableBuffer extends AbstractBufferDecorator implements Unmodifiable {
|
||||
|
||||
/**
|
||||
* Factory method to create an unmodifiable buffer.
|
||||
|
@ -95,20 +98,36 @@ public class UnmodifiableBuffer extends UnmodifiableCollection implements Buffer
|
|||
super(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the buffer being decorated.
|
||||
*
|
||||
* @return the decorated buffer
|
||||
*/
|
||||
protected Buffer getBuffer() {
|
||||
return (Buffer) getCollection();
|
||||
//-----------------------------------------------------------------------
|
||||
public Iterator iterator() {
|
||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
||||
}
|
||||
|
||||
public boolean add(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean addAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean retainAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public Object get() {
|
||||
return getBuffer().get();
|
||||
}
|
||||
|
||||
public Object remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/buffer/Attic/UnmodifiablePriorityQueue.java,v 1.1 2003/11/16 00:05:44 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/buffer/Attic/UnmodifiablePriorityQueue.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -60,17 +60,18 @@ package org.apache.commons.collections.buffer;
|
|||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.apache.commons.collections.PriorityQueue;
|
||||
import org.apache.commons.collections.Unmodifiable;
|
||||
|
||||
/**
|
||||
* <code>UnmodifiablePriorityQueue</code> decorates another <code>PriorityQueue</code>
|
||||
* to ensure it can't be altered.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:44 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class UnmodifiablePriorityQueue implements PriorityQueue {
|
||||
public class UnmodifiablePriorityQueue implements PriorityQueue, Unmodifiable {
|
||||
|
||||
/** The priority queue to decorate */
|
||||
protected final PriorityQueue priorityQueue;
|
||||
|
@ -82,9 +83,13 @@ public class UnmodifiablePriorityQueue implements PriorityQueue {
|
|||
* @throws IllegalArgumentException if priority queue is null
|
||||
*/
|
||||
public static PriorityQueue decorate(PriorityQueue priorityQueue) {
|
||||
if (priorityQueue instanceof Unmodifiable) {
|
||||
return priorityQueue;
|
||||
}
|
||||
return new UnmodifiablePriorityQueue(priorityQueue);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Constructs a new synchronized priority queue.
|
||||
*
|
||||
|
@ -97,6 +102,7 @@ public class UnmodifiablePriorityQueue implements PriorityQueue {
|
|||
this.priorityQueue = priorityQueue;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Clear all elements from queue - Unsupported as unmodifiable.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java,v 1.1 2003/11/16 00:05:47 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -60,14 +60,14 @@ package org.apache.commons.collections.collection;
|
|||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.collections.IteratorUtils;
|
||||
import org.apache.commons.collections.Unmodifiable;
|
||||
import org.apache.commons.collections.iterators.UnmodifiableIterator;
|
||||
|
||||
/**
|
||||
* Decorates another <code>Collection</code> to ensure it can't be altered.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:47 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
|
@ -98,59 +98,30 @@ public class UnmodifiableCollection extends AbstractCollectionDecorator implemen
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Override as method unsupported.
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
public Iterator iterator() {
|
||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
||||
}
|
||||
|
||||
public boolean add(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override as method unsupported.
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
public boolean addAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override as method unsupported.
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to return an unmodifiable iterator.
|
||||
*
|
||||
* @return unmodifiable iterator
|
||||
*/
|
||||
public Iterator iterator() {
|
||||
return IteratorUtils.unmodifiableIterator(getCollection().iterator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Override as method unsupported.
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override as method unsupported.
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
public boolean removeAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override as method unsupported.
|
||||
* @throws UnsupportedOperationException
|
||||
*/
|
||||
public boolean retainAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/list/UnmodifiableList.java,v 1.1 2003/11/16 00:05:47 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/list/UnmodifiableList.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -58,22 +58,23 @@
|
|||
package org.apache.commons.collections.list;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.apache.commons.collections.IteratorUtils;
|
||||
import org.apache.commons.collections.Unmodifiable;
|
||||
import org.apache.commons.collections.collection.UnmodifiableCollection;
|
||||
import org.apache.commons.collections.iterators.UnmodifiableIterator;
|
||||
import org.apache.commons.collections.iterators.UnmodifiableListIterator;
|
||||
|
||||
/**
|
||||
* Decorates another <code>List</code> to ensure it can't be altered.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:47 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class UnmodifiableList extends UnmodifiableCollection implements List {
|
||||
public class UnmodifiableList extends AbstractListDecorator implements Unmodifiable {
|
||||
|
||||
/**
|
||||
* Factory method to create an unmodifiable list.
|
||||
|
@ -109,14 +110,35 @@ public class UnmodifiableList extends UnmodifiableCollection implements List {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public void add(int index, Object object) {
|
||||
public Iterator iterator() {
|
||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
||||
}
|
||||
|
||||
public boolean add(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean addAll(int index, Collection coll) {
|
||||
public boolean addAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean retainAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public Object get(int index) {
|
||||
return getList().get(index);
|
||||
}
|
||||
|
@ -130,11 +152,19 @@ public class UnmodifiableList extends UnmodifiableCollection implements List {
|
|||
}
|
||||
|
||||
public ListIterator listIterator() {
|
||||
return IteratorUtils.unmodifiableListIterator(getList().listIterator());
|
||||
return UnmodifiableListIterator.decorate(getList().listIterator());
|
||||
}
|
||||
|
||||
public ListIterator listIterator(int index) {
|
||||
return IteratorUtils.unmodifiableListIterator(getList().listIterator(index));
|
||||
return UnmodifiableListIterator.decorate(getList().listIterator(index));
|
||||
}
|
||||
|
||||
public void add(int index, Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean addAll(int index, Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Object remove(int index) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/set/UnmodifiableSet.java,v 1.1 2003/11/16 00:05:45 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/set/UnmodifiableSet.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -57,20 +57,22 @@
|
|||
*/
|
||||
package org.apache.commons.collections.set;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.Unmodifiable;
|
||||
import org.apache.commons.collections.collection.UnmodifiableCollection;
|
||||
import org.apache.commons.collections.iterators.UnmodifiableIterator;
|
||||
|
||||
/**
|
||||
* Decorates another <code>Set</code> to ensure it can't be altered.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:45 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class UnmodifiableSet extends UnmodifiableCollection implements Set {
|
||||
public class UnmodifiableSet extends AbstractSetDecorator implements Unmodifiable {
|
||||
|
||||
/**
|
||||
* Factory method to create an unmodifiable set.
|
||||
|
@ -96,13 +98,33 @@ public class UnmodifiableSet extends UnmodifiableCollection implements Set {
|
|||
super(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set being decorated.
|
||||
*
|
||||
* @return the decorated set
|
||||
*/
|
||||
protected Set getSet() {
|
||||
return (Set) getCollection();
|
||||
//-----------------------------------------------------------------------
|
||||
public Iterator iterator() {
|
||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
||||
}
|
||||
|
||||
public boolean add(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean addAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean retainAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java,v 1.1 2003/11/16 00:05:45 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -57,20 +57,22 @@
|
|||
*/
|
||||
package org.apache.commons.collections.set;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.apache.commons.collections.Unmodifiable;
|
||||
import org.apache.commons.collections.iterators.UnmodifiableIterator;
|
||||
|
||||
/**
|
||||
* Decorates another <code>SortedSet</code> to ensure it can't be altered.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:45 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class UnmodifiableSortedSet extends UnmodifiableSet implements SortedSet {
|
||||
public class UnmodifiableSortedSet extends AbstractSortedSetDecorator implements Unmodifiable {
|
||||
|
||||
/**
|
||||
* Factory method to create an unmodifiable set.
|
||||
|
@ -96,13 +98,33 @@ public class UnmodifiableSortedSet extends UnmodifiableSet implements SortedSet
|
|||
super(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set being decorated.
|
||||
*
|
||||
* @return the decorated set
|
||||
*/
|
||||
protected SortedSet getSortedSet() {
|
||||
return (SortedSet) getCollection();
|
||||
//-----------------------------------------------------------------------
|
||||
public Iterator iterator() {
|
||||
return UnmodifiableIterator.decorate(getCollection().iterator());
|
||||
}
|
||||
|
||||
public boolean add(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean addAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean remove(Object object) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean retainAll(Collection coll) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -121,16 +143,4 @@ public class UnmodifiableSortedSet extends UnmodifiableSet implements SortedSet
|
|||
return new UnmodifiableSortedSet(sub);
|
||||
}
|
||||
|
||||
public Object first() {
|
||||
return getSortedSet().first();
|
||||
}
|
||||
|
||||
public Object last() {
|
||||
return getSortedSet().last();
|
||||
}
|
||||
|
||||
public Comparator comparator() {
|
||||
return getSortedSet().comparator();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/collection/TestAll.java,v 1.1 2003/11/16 00:05:47 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/collection/TestAll.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -65,7 +65,7 @@ import junit.framework.TestSuite;
|
|||
* Entry point for tests.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:47 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
|
@ -86,6 +86,7 @@ public class TestAll extends TestCase {
|
|||
suite.addTest(TestCompositeCollection.suite());
|
||||
suite.addTest(TestPredicatedCollection.suite());
|
||||
suite.addTest(TestTransformedCollection.suite());
|
||||
suite.addTest(TestUnmodifiableCollection.suite());
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/collection/TestUnmodifiableCollection.java,v 1.1 2003/12/03 11:19:10 scolebourne 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 acknowledgement:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgement may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgements 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.collection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractTestCollection} for exercising the
|
||||
* {@link UnmodifiableCollection} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Phil Steitz
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
public class TestUnmodifiableCollection extends AbstractTestCollection {
|
||||
|
||||
public TestUnmodifiableCollection(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(TestUnmodifiableCollection.class);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String[] testCaseName = { TestUnmodifiableCollection.class.getName()};
|
||||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public Collection makeCollection() {
|
||||
return UnmodifiableCollection.decorate(new ArrayList());
|
||||
}
|
||||
|
||||
public Collection makeFullCollection() {
|
||||
List list = new ArrayList();
|
||||
list.addAll(Arrays.asList(getFullElements()));
|
||||
return UnmodifiableCollection.decorate(list);
|
||||
}
|
||||
|
||||
public Collection makeConfirmedCollection() {
|
||||
ArrayList list = new ArrayList();
|
||||
return list;
|
||||
}
|
||||
|
||||
public Collection makeConfirmedFullCollection() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.addAll(Arrays.asList(getFullElements()));
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean isAddSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isRemoveSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java,v 1.3 2003/11/18 22:37:14 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java,v 1.4 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -65,18 +65,16 @@ import java.util.List;
|
|||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.collections.map.TestPredicatedSortedMap;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractTestList} for exercising the
|
||||
* {@link UnmodifiableList} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.3 $ $Date: 2003/11/18 22:37:14 $
|
||||
* @version $Revision: 1.4 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Phil Steitz
|
||||
*/
|
||||
public class TestUnmodifiableList extends AbstractTestList{
|
||||
public class TestUnmodifiableList extends AbstractTestList {
|
||||
|
||||
public TestUnmodifiableList(String testName) {
|
||||
super(testName);
|
||||
|
@ -87,11 +85,11 @@ public class TestUnmodifiableList extends AbstractTestList{
|
|||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String[] testCaseName = { TestPredicatedSortedMap.class.getName()};
|
||||
String[] testCaseName = { TestUnmodifiableList.class.getName()};
|
||||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public List makeEmptyList() {
|
||||
return UnmodifiableList.decorate(new ArrayList());
|
||||
}
|
||||
|
@ -112,8 +110,9 @@ public class TestUnmodifiableList extends AbstractTestList{
|
|||
|
||||
public boolean isRemoveSupported() {
|
||||
return false;
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
protected UnmodifiableList list = null;
|
||||
protected ArrayList array = null;
|
||||
|
||||
|
@ -209,4 +208,4 @@ public class TestUnmodifiableList extends AbstractTestList{
|
|||
// expected
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/set/AbstractTestSortedSet.java,v 1.2 2003/11/18 22:37:17 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/set/AbstractTestSortedSet.java,v 1.3 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -74,7 +74,7 @@ import org.apache.commons.collections.BulkTest;
|
|||
* elements may be added; see {@link AbstractTestCollection} for more details.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.2 $ $Date: 2003/11/18 22:37:17 $
|
||||
* @version $Revision: 1.3 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
* @author Dieter Wimberger
|
||||
|
@ -281,17 +281,24 @@ public abstract class AbstractTestSortedSet extends AbstractTestSet {
|
|||
//System.out.println(new TreeSet(Arrays.asList(m_FullElements)));
|
||||
//System.out.println(new TreeSet(Arrays.asList(m_OtherElements)));
|
||||
|
||||
} //TestSortedSetSubSet
|
||||
}
|
||||
|
||||
public boolean isNullSupported() {
|
||||
return AbstractTestSortedSet.this.isNullSupported();
|
||||
} //useNullValue
|
||||
|
||||
public Object[] getFullElements() {
|
||||
//System.out.println("getFullElements()");
|
||||
return m_FullElements;
|
||||
}
|
||||
public boolean isAddSupported() {
|
||||
return AbstractTestSortedSet.this.isAddSupported();
|
||||
}
|
||||
public boolean isRemoveSupported() {
|
||||
return AbstractTestSortedSet.this.isRemoveSupported();
|
||||
}
|
||||
public boolean isFailFastSupported() {
|
||||
return AbstractTestSortedSet.this.isFailFastSupported();
|
||||
}
|
||||
|
||||
public Object[] getFullElements() {
|
||||
return m_FullElements;
|
||||
}
|
||||
public Object[] getOtherElements() {
|
||||
return m_OtherElements;
|
||||
}
|
||||
|
@ -308,44 +315,26 @@ public abstract class AbstractTestSortedSet extends AbstractTestSet {
|
|||
default :
|
||||
return null;
|
||||
}
|
||||
} //getSubSet
|
||||
}
|
||||
|
||||
public Set makeEmptySet() {
|
||||
SortedSet s = (SortedSet) AbstractTestSortedSet.this.makeFullSet();
|
||||
s = getSubSet(s);
|
||||
s.clear();
|
||||
return s;
|
||||
} //makeEmptySet
|
||||
SortedSet s = (SortedSet) AbstractTestSortedSet.this.makeEmptySet();
|
||||
return getSubSet(s);
|
||||
}
|
||||
|
||||
public Set makeFullSet() {
|
||||
SortedSet s = (SortedSet) AbstractTestSortedSet.this.makeFullCollection();
|
||||
return getSubSet(s);
|
||||
} //makeFullSet
|
||||
|
||||
public void resetFull() {
|
||||
AbstractTestSortedSet.this.resetFull();
|
||||
TestSortedSetSubSet.this.confirmed = getSubSet((SortedSet) AbstractTestSortedSet.this.confirmed);
|
||||
TestSortedSetSubSet.this.collection = getSubSet((SortedSet) AbstractTestSortedSet.this.collection);
|
||||
}
|
||||
|
||||
public void resetEmpty() {
|
||||
TestSortedSetSubSet.this.resetFull();
|
||||
TestSortedSetSubSet.this.confirmed.clear();
|
||||
TestSortedSetSubSet.this.collection.clear();
|
||||
}
|
||||
|
||||
public BulkTest bulkTestSortedSetSubSet() {
|
||||
//Override returning null to prevent endless
|
||||
//loop of bulk tests
|
||||
return null;
|
||||
} //bulkTestSortedSetSubSet
|
||||
|
||||
public BulkTest bulkTestSortedSetHeadSet() {
|
||||
return null;
|
||||
return null; // prevent infinite recursion
|
||||
}
|
||||
public BulkTest bulkTestSortedSetHeadSet() {
|
||||
return null; // prevent infinite recursion
|
||||
}
|
||||
|
||||
public BulkTest bulkTestSortedSetTailSet() {
|
||||
return null;
|
||||
return null; // prevent infinite recursion
|
||||
}
|
||||
|
||||
static final int TYPE_SUBSET = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/set/TestAll.java,v 1.1 2003/11/16 00:05:46 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/set/TestAll.java,v 1.2 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -65,7 +65,7 @@ import junit.framework.TestSuite;
|
|||
* Entry point for tests.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/11/16 00:05:46 $
|
||||
* @version $Revision: 1.2 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Stephen Colebourne
|
||||
*/
|
||||
|
@ -89,6 +89,7 @@ public class TestAll extends TestCase {
|
|||
suite.addTest(TestTransformedSet.suite());
|
||||
suite.addTest(TestTransformedSortedSet.suite());
|
||||
suite.addTest(TestTypedSortedSet.suite());
|
||||
suite.addTest(TestUnmodifiableSet.suite());
|
||||
suite.addTest(TestUnmodifiableSortedSet.suite());
|
||||
|
||||
return suite;
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java,v 1.1 2003/12/03 11:19:10 scolebourne 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 acknowledgement:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgement may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgements 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.set;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractTestSet} for exercising the
|
||||
* {@link UnmodifiableSet} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.1 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Phil Steitz
|
||||
*/
|
||||
public class TestUnmodifiableSet extends AbstractTestSet{
|
||||
|
||||
public TestUnmodifiableSet(String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return BulkTest.makeSuite(TestUnmodifiableSet.class);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
String[] testCaseName = { TestUnmodifiableSet.class.getName()};
|
||||
junit.textui.TestRunner.main(testCaseName);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public Set makeEmptySet() {
|
||||
return UnmodifiableSet.decorate(new HashSet());
|
||||
}
|
||||
|
||||
public Set makeFullSet() {
|
||||
HashSet set = new HashSet();
|
||||
set.addAll(Arrays.asList(getFullElements()));
|
||||
return UnmodifiableSet.decorate(set);
|
||||
}
|
||||
|
||||
public boolean isAddSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isRemoveSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java,v 1.3 2003/11/18 22:37:17 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java,v 1.4 2003/12/03 11:19:10 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -64,14 +64,15 @@ import java.util.Set;
|
|||
import java.util.TreeSet;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractTestSortedSet} for exercising the
|
||||
* {@link UnmodifiableSortedSet} implementation.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.3 $ $Date: 2003/11/18 22:37:17 $
|
||||
* @version $Revision: 1.4 $ $Date: 2003/12/03 11:19:10 $
|
||||
*
|
||||
* @author Phil Steitz
|
||||
*/
|
||||
|
@ -82,8 +83,7 @@ public class TestUnmodifiableSortedSet extends AbstractTestSortedSet{
|
|||
}
|
||||
|
||||
public static Test suite() {
|
||||
// Can't run bulk tests in AbstractTestSet -- subset tests modify set
|
||||
return new TestSuite(TestUnmodifiableSortedSet.class);
|
||||
return BulkTest.makeSuite(TestUnmodifiableSortedSet.class);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
|
Loading…
Reference in New Issue