Fix formatting

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131828 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2004-12-19 16:56:31 +00:00
parent 6a8e5d5380
commit 2e2ac4ba93
6 changed files with 253 additions and 286 deletions

View File

@ -38,7 +38,7 @@ import org.apache.commons.collections.collection.UnmodifiableCollection;
* Provides utility methods and decorators for {@link Collection} instances. * Provides utility methods and decorators for {@link Collection} instances.
* *
* @since Commons Collections 1.0 * @since Commons Collections 1.0
* @version $Revision: 1.63 $ $Date: 2004/12/11 06:30:38 $ * @version $Revision: 1.64 $ $Date: 2004/12/19 16:56:30 $
* *
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @author Paul Jack * @author Paul Jack
@ -1065,6 +1065,7 @@ public class CollectionUtils {
copy.addAll(collection); copy.addAll(collection);
return UnmodifiableCollection.decorate(copy); return UnmodifiableCollection.decorate(copy);
} }
/** /**
* Returns a predicated (validating) collection backed by the given collection. * Returns a predicated (validating) collection backed by the given collection.
* <p> * <p>
@ -1125,7 +1126,7 @@ public class CollectionUtils {
* that occur at least once in <code>retain</code>. * that occur at least once in <code>retain</code>.
* @throws NullPointerException if either parameter is null * @throws NullPointerException if either parameter is null
*/ */
public static Collection retainAll(final Collection collection, final Collection retain) { public static Collection retainAll(Collection collection, Collection retain) {
return ListUtils.retainAll(collection, retain); return ListUtils.retainAll(collection, retain);
} }
@ -1144,9 +1145,8 @@ public class CollectionUtils {
* any elements that also occur in <code>remove</code>. * any elements that also occur in <code>remove</code>.
* @throws NullPointerException if either parameter is null * @throws NullPointerException if either parameter is null
*/ */
public static Collection removeAll(final Collection collection, final Collection remove) { public static Collection removeAll(Collection collection, Collection remove) {
return ListUtils.retainAll(collection, remove); return ListUtils.retainAll(collection, remove);
} }
} }

View File

@ -33,7 +33,7 @@ import org.apache.commons.collections.list.UnmodifiableList;
* Provides utility methods and decorators for {@link List} instances. * Provides utility methods and decorators for {@link List} instances.
* *
* @since Commons Collections 1.0 * @since Commons Collections 1.0
* @version $Revision: 1.29 $ $Date: 2004/12/11 06:22:58 $ * @version $Revision: 1.30 $ $Date: 2004/12/19 16:56:30 $
* *
* @author Federico Barbieri * @author Federico Barbieri
* @author Peter Donald * @author Peter Donald
@ -382,20 +382,15 @@ public class ListUtils {
* that occur at least once in <code>retain</code>. * that occur at least once in <code>retain</code>.
* @throws NullPointerException if either parameter is null * @throws NullPointerException if either parameter is null
*/ */
public static List retainAll(final Collection collection, final Collection retain) { public static List retainAll(Collection collection, Collection retain) {
final List list = new ArrayList(Math.min(collection.size(), retain.size())); List list = new ArrayList(Math.min(collection.size(), retain.size()));
Object item = null; for (Iterator iter = collection.iterator(); iter.hasNext();) {
for (final Iterator iter = collection.iterator(); iter.hasNext();) Object obj = iter.next();
{ if (retain.contains(obj)) {
item = iter.next(); list.add(obj);
if (retain.contains(item))
{
list.add(item);
} }
} }
return list; return list;
} }
@ -414,19 +409,14 @@ public class ListUtils {
* any elements that also occur in <code>remove</code>. * any elements that also occur in <code>remove</code>.
* @throws NullPointerException if either parameter is null * @throws NullPointerException if either parameter is null
*/ */
public static List removeAll(final Collection collection, final Collection remove) { public static List removeAll(Collection collection, Collection remove) {
final List list = new ArrayList(); List list = new ArrayList();
for (Iterator iter = collection.iterator(); iter.hasNext();) {
Object o = null; Object obj = iter.next();
for (final Iterator iter = collection.iterator(); iter.hasNext();) if (remove.contains(obj) == false) {
{ list.add(obj);
o = iter.next();
if (remove.contains(o) == false)
{
list.add(o);
} }
} }
return list; return list;
} }

View File

@ -67,7 +67,7 @@ import org.apache.commons.collections.map.UnmodifiableSortedMap;
* </ul> * </ul>
* *
* @since Commons Collections 1.0 * @since Commons Collections 1.0
* @version $Revision: 1.50 $ $Date: 2004/12/11 06:26:13 $ * @version $Revision: 1.51 $ $Date: 2004/12/19 16:56:30 $
* *
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a> * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @author <a href="mailto:nissim@nksystems.com">Nissim Karpenstein</a> * @author <a href="mailto:nissim@nksystems.com">Nissim Karpenstein</a>
@ -1228,10 +1228,10 @@ public class MapUtils {
* @return an unmodifiable map backed by the given map * @return an unmodifiable map backed by the given map
* @throws IllegalArgumentException if the map is null * @throws IllegalArgumentException if the map is null
*/ */
public static Map unmodifiableMapCopy(final Map map) { public static Map unmodifiableMapCopy(Map map) {
if (map == null) throw new IllegalArgumentException("null not permitted."); if (map == null) throw new IllegalArgumentException("null not permitted.");
final Map copy = new HashMap(map.size(), 1.0f); Map copy = new HashMap(map.size(), 1.0f);
copy.putAll(map); copy.putAll(map);
return MapUtils.unmodifiableMap(copy); return MapUtils.unmodifiableMap(copy);
} }

View File

@ -17,7 +17,6 @@ package org.apache.commons.collections;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -52,7 +51,7 @@ import org.apache.commons.collections.collection.UnmodifiableCollection;
* @author Steven Melzer * @author Steven Melzer
* @author Neil O'Toole * @author Neil O'Toole
* *
* @version $Revision: 1.42 $ $Date: 2004/12/11 06:30:38 $ * @version $Revision: 1.43 $ $Date: 2004/12/19 16:56:31 $
*/ */
public class TestCollectionUtils extends TestCase { public class TestCollectionUtils extends TestCase {
@ -1207,21 +1206,17 @@ public class TestCollectionUtils extends TestCase {
collection.clear(); collection.clear();
assertTrue(copy.isEmpty() == false); assertTrue(copy.isEmpty() == false);
try try {
{
copy.clear(); copy.clear();
fail("should be unmodifiable."); fail("should be unmodifiable.");
} } catch (UnsupportedOperationException uoe) {
catch (UnsupportedOperationException uoe) } // this is what we want
{} // this is what we want
try try {
{
copy = CollectionUtils.unmodifiableCollectionCopy(null); copy = CollectionUtils.unmodifiableCollectionCopy(null);
fail("should throw IllegalArgumentException"); fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException iae) {
} }
catch(IllegalArgumentException iae)
{}
} }
} }

View File

@ -27,7 +27,7 @@ import org.apache.commons.collections.list.PredicatedList;
/** /**
* Tests for ListUtils. * Tests for ListUtils.
* *
* @version $Revision: 1.20 $ $Date: 2004/12/11 06:24:10 $ * @version $Revision: 1.21 $ $Date: 2004/12/19 16:56:31 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
* @author Neil O'Toole * @author Neil O'Toole
@ -146,23 +146,17 @@ public class TestListUtils extends BulkTest {
list.clear(); list.clear();
assertTrue(copy.isEmpty() == false); assertTrue(copy.isEmpty() == false);
try try {
{
copy.clear(); copy.clear();
fail("should be unmodifiable."); fail("should be unmodifiable.");
} } catch (UnsupportedOperationException uoe) {
catch (UnsupportedOperationException uoe)
{
// this is what we want // this is what we want
} }
try try {
{
list = ListUtils.unmodifiableListCopy(null); list = ListUtils.unmodifiableListCopy(null);
fail("expecting IllegalArgumentException"); fail("expecting IllegalArgumentException");
} } catch (IllegalArgumentException iae) {
catch (IllegalArgumentException iae)
{
// this is what we want // this is what we want
} }
} }
@ -180,13 +174,10 @@ public class TestListUtils extends BulkTest {
fullList.retainAll(sub); fullList.retainAll(sub);
assertTrue(retained.equals(fullList)); assertTrue(retained.equals(fullList));
try try {
{
List list = ListUtils.retainAll(null, null); List list = ListUtils.retainAll(null, null);
fail("expecting NullPointerException"); fail("expecting NullPointerException");
} } catch(NullPointerException npe){} // this is what we want
catch(NullPointerException npe)
{} // this is what we want
} }
public void testRemoveAll() { public void testRemoveAll() {
@ -200,13 +191,10 @@ public class TestListUtils extends BulkTest {
fullList.removeAll(sub); fullList.removeAll(sub);
assertTrue(remainder.equals(fullList)); assertTrue(remainder.equals(fullList));
try try {
{
List list = ListUtils.removeAll(null, null); List list = ListUtils.removeAll(null, null);
fail("expecting NullPointerException"); fail("expecting NullPointerException");
} } catch(NullPointerException npe) {} // this is what we want
catch(NullPointerException npe)
{} // this is what we want
} }
} }

View File

@ -37,7 +37,7 @@ import org.apache.commons.collections.map.TestPredicatedMap;
/** /**
* Tests for MapUtils. * Tests for MapUtils.
* *
* @version $Revision: 1.25 $ $Date: 2004/12/11 06:26:13 $ * @version $Revision: 1.26 $ $Date: 2004/12/19 16:56:31 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
* @author Arun Mammen Thomas * @author Arun Mammen Thomas
@ -781,23 +781,17 @@ public class TestMapUtils extends BulkTest {
map.clear(); map.clear();
assertFalse(map.equals(copy)); assertFalse(map.equals(copy));
try try {
{
copy.clear(); copy.clear();
fail("should be unmodifiable."); fail("should be unmodifiable.");
} } catch (UnsupportedOperationException uoe) {
catch (UnsupportedOperationException uoe)
{
// this is what we want // this is what we want
} }
try try {
{
map = MapUtils.unmodifiableMapCopy(null); map = MapUtils.unmodifiableMapCopy(null);
fail("expecting IllegalArgumentException"); fail("expecting IllegalArgumentException");
} } catch (IllegalArgumentException iae) {
catch (IllegalArgumentException iae)
{
// this is what we want // this is what we want
} }