Use correct internal method, from Andrew Freeman
Update licence and javadoc git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130975 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dbee289a00
commit
a1dc756f64
|
@ -1,13 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BagUtils.java,v 1.7 2002/10/13 00:38:36 scolebourne Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BagUtils.java,v 1.8 2003/02/20 23:14:03 scolebourne Exp $
|
||||||
* $Revision: 1.7 $
|
|
||||||
* $Date: 2002/10/13 00:38:36 $
|
|
||||||
*
|
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
|
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -23,11 +20,11 @@
|
||||||
* distribution.
|
* distribution.
|
||||||
*
|
*
|
||||||
* 3. The end-user documentation included with the redistribution, if
|
* 3. The end-user documentation included with the redistribution, if
|
||||||
* any, must include the following acknowlegement:
|
* any, must include the following acknowledgment:
|
||||||
* "This product includes software developed by the
|
* "This product includes software developed by the
|
||||||
* Apache Software Foundation (http://www.apache.org/)."
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
* Alternately, this acknowlegement may appear in the software itself,
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
* if and wherever such third-party acknowlegements normally appear.
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
*
|
*
|
||||||
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
|
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
|
||||||
* Foundation" must not be used to endorse or promote products derived
|
* Foundation" must not be used to endorse or promote products derived
|
||||||
|
@ -36,7 +33,7 @@
|
||||||
*
|
*
|
||||||
* 5. Products derived from this software may not be called "Apache"
|
* 5. Products derived from this software may not be called "Apache"
|
||||||
* nor may "Apache" appear in their names without prior written
|
* nor may "Apache" appear in their names without prior written
|
||||||
* permission of the Apache Group.
|
* permission of the Apache Software Foundation.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
@ -62,24 +59,30 @@ package org.apache.commons.collections;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides utility methods and decorators for {@link Bag}
|
* Provides utility methods and decorators for {@link Bag}
|
||||||
* and {@link SortedBag} instances.<P>
|
* and {@link SortedBag} instances.
|
||||||
|
*
|
||||||
|
* @since Commons Collections 2.1
|
||||||
|
* @version $Revision: 1.8 $ $Date: 2003/02/20 23:14:03 $
|
||||||
*
|
*
|
||||||
* @author Paul Jack
|
* @author Paul Jack
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @version $Id: BagUtils.java,v 1.7 2002/10/13 00:38:36 scolebourne Exp $
|
* @author Andrew Freeman
|
||||||
* @since 2.1
|
|
||||||
*/
|
*/
|
||||||
public class BagUtils {
|
public class BagUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevents instantiation.
|
* Instantiation of BagUtils is not intended or required.
|
||||||
|
* However, some tools require an instance to operate.
|
||||||
*/
|
*/
|
||||||
private BagUtils() {
|
public BagUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of a Bag that validates elements before they are added.
|
||||||
|
*/
|
||||||
static class PredicatedBag
|
static class PredicatedBag
|
||||||
extends CollectionUtils.PredicatedCollection
|
extends CollectionUtils.PredicatedCollection
|
||||||
implements Bag {
|
implements Bag {
|
||||||
|
@ -111,36 +114,9 @@ public class BagUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static class UnmodifiableBag
|
/**
|
||||||
extends CollectionUtils.UnmodifiableCollection
|
* Implementation of a Bag that is synchronized.
|
||||||
implements Bag {
|
*/
|
||||||
|
|
||||||
public UnmodifiableBag(Bag bag) {
|
|
||||||
super(bag);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Bag getBag() {
|
|
||||||
return (Bag)collection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean add(Object o, int count) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean remove(Object o, int count) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set uniqueSet() {
|
|
||||||
return ((Bag)collection).uniqueSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCount(Object o) {
|
|
||||||
return ((Bag)collection).getCount(o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static class SynchronizedBag
|
static class SynchronizedBag
|
||||||
extends CollectionUtils.SynchronizedCollection
|
extends CollectionUtils.SynchronizedCollection
|
||||||
implements Bag {
|
implements Bag {
|
||||||
|
@ -168,10 +144,45 @@ public class BagUtils {
|
||||||
private Bag getBag() {
|
private Bag getBag() {
|
||||||
return (Bag) collection;
|
return (Bag) collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of a Bag that is unmodifiable.
|
||||||
|
*/
|
||||||
|
static class UnmodifiableBag
|
||||||
|
extends CollectionUtils.UnmodifiableCollection
|
||||||
|
implements Bag {
|
||||||
|
|
||||||
|
public UnmodifiableBag(Bag bag) {
|
||||||
|
super(bag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean add(Object o, int count) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean remove(Object o, int count) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set uniqueSet() {
|
||||||
|
return getBag().uniqueSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount(Object o) {
|
||||||
|
return getBag().getCount(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bag getBag() {
|
||||||
|
return (Bag) collection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of a SortedBag that validates elements before they are added.
|
||||||
|
*/
|
||||||
static class PredicatedSortedBag
|
static class PredicatedSortedBag
|
||||||
extends PredicatedBag
|
extends PredicatedBag
|
||||||
implements SortedBag {
|
implements SortedBag {
|
||||||
|
@ -198,6 +209,9 @@ public class BagUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of a SortedBag that is synchronized.
|
||||||
|
*/
|
||||||
static class SynchronizedSortedBag
|
static class SynchronizedSortedBag
|
||||||
extends SynchronizedBag
|
extends SynchronizedBag
|
||||||
implements SortedBag {
|
implements SortedBag {
|
||||||
|
@ -221,10 +235,12 @@ public class BagUtils {
|
||||||
private SortedBag getSortedBag() {
|
private SortedBag getSortedBag() {
|
||||||
return (SortedBag) collection;
|
return (SortedBag) collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of a SortedBag that is unmodifiable.
|
||||||
|
*/
|
||||||
static class UnmodifiableSortedBag
|
static class UnmodifiableSortedBag
|
||||||
extends UnmodifiableBag
|
extends UnmodifiableBag
|
||||||
implements SortedBag {
|
implements SortedBag {
|
||||||
|
@ -248,7 +264,6 @@ public class BagUtils {
|
||||||
private SortedBag getSortedBag() {
|
private SortedBag getSortedBag() {
|
||||||
return (SortedBag) collection;
|
return (SortedBag) collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue