Javadoc
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131718 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7cad661cf1
commit
b13cb3b3b4
|
@ -37,7 +37,7 @@ import org.apache.commons.collections.set.UnmodifiableSet;
|
||||||
* the number of occurrences of that element in the bag.
|
* the number of occurrences of that element in the bag.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0 (previously DefaultMapBag v2.0)
|
* @since Commons Collections 3.0 (previously DefaultMapBag v2.0)
|
||||||
* @version $Revision: 1.14 $ $Date: 2004/02/18 00:56:25 $
|
* @version $Revision: 1.15 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Chuck Burdick
|
* @author Chuck Burdick
|
||||||
* @author Michael A. Smith
|
* @author Michael A. Smith
|
||||||
|
@ -76,8 +76,9 @@ public abstract class AbstractMapBag implements Bag {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method for implementations to access the map that backs
|
* Utility method for implementations to access the map that backs
|
||||||
* this bag. Not intended for interactive use outside of
|
* this bag. Not intended for interactive use outside of subclasses.
|
||||||
* subclasses.
|
*
|
||||||
|
* @return the map being used by the Bag
|
||||||
*/
|
*/
|
||||||
protected Map getMap() {
|
protected Map getMap() {
|
||||||
return map;
|
return map;
|
||||||
|
@ -171,6 +172,9 @@ public abstract class AbstractMapBag implements Bag {
|
||||||
return new BagIterator(this);
|
return new BagIterator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inner class iterator for the Bag.
|
||||||
|
*/
|
||||||
static class BagIterator implements Iterator {
|
static class BagIterator implements Iterator {
|
||||||
private AbstractMapBag parent;
|
private AbstractMapBag parent;
|
||||||
private Iterator entryIterator;
|
private Iterator entryIterator;
|
||||||
|
@ -179,6 +183,11 @@ public abstract class AbstractMapBag implements Bag {
|
||||||
private final int mods;
|
private final int mods;
|
||||||
private boolean canRemove;
|
private boolean canRemove;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param parent the parent bag
|
||||||
|
*/
|
||||||
public BagIterator(AbstractMapBag parent) {
|
public BagIterator(AbstractMapBag parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.entryIterator = parent.map.entrySet().iterator();
|
this.entryIterator = parent.map.entrySet().iterator();
|
||||||
|
@ -391,8 +400,13 @@ public abstract class AbstractMapBag implements Bag {
|
||||||
* Mutable integer class for storing the data.
|
* Mutable integer class for storing the data.
|
||||||
*/
|
*/
|
||||||
protected static class MutableInteger {
|
protected static class MutableInteger {
|
||||||
|
/** The value of this mutable. */
|
||||||
protected int value;
|
protected int value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param value the initial value
|
||||||
|
*/
|
||||||
MutableInteger(int value) {
|
MutableInteger(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
@ -469,6 +483,8 @@ public abstract class AbstractMapBag implements Bag {
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Write the map out using a custom routine.
|
* Write the map out using a custom routine.
|
||||||
|
* @param out the output stream
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected void doWriteObject(ObjectOutputStream out) throws IOException {
|
protected void doWriteObject(ObjectOutputStream out) throws IOException {
|
||||||
out.writeInt(map.size());
|
out.writeInt(map.size());
|
||||||
|
@ -481,6 +497,10 @@ public abstract class AbstractMapBag implements Bag {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the map in using a custom routine.
|
* Read the map in using a custom routine.
|
||||||
|
* @param map the map to use
|
||||||
|
* @param in the input stream
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
protected void doReadObject(Map map, ObjectInputStream in) throws IOException, ClassNotFoundException {
|
protected void doReadObject(Map map, ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
@ -514,7 +534,7 @@ public abstract class AbstractMapBag implements Bag {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Iterator it = map.keySet().iterator(); it.hasNext();) {
|
for (Iterator it = map.keySet().iterator(); it.hasNext();) {
|
||||||
Object element = (Object) it.next();
|
Object element = it.next();
|
||||||
if (other.getCount(element) != getCount(element)) {
|
if (other.getCount(element) != getCount(element)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.collections.collection.PredicatedCollection;
|
||||||
* is thrown.
|
* is thrown.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2004/02/18 00:56:25 $
|
* @version $Revision: 1.5 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Paul Jack
|
* @author Paul Jack
|
||||||
|
@ -45,6 +45,7 @@ public class PredicatedBag
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param predicate the predicate to use for validation, must not be null
|
* @param predicate the predicate to use for validation, must not be null
|
||||||
|
* @return a new predicated Bag
|
||||||
* @throws IllegalArgumentException if bag or predicate is null
|
* @throws IllegalArgumentException if bag or predicate is null
|
||||||
* @throws IllegalArgumentException if the bag contains invalid elements
|
* @throws IllegalArgumentException if the bag contains invalid elements
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.collections.SortedBag;
|
||||||
* is thrown.
|
* is thrown.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2004/02/18 00:56:25 $
|
* @version $Revision: 1.5 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Paul Jack
|
* @author Paul Jack
|
||||||
|
@ -44,6 +44,7 @@ public class PredicatedSortedBag
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param predicate the predicate to use for validation, must not be null
|
* @param predicate the predicate to use for validation, must not be null
|
||||||
|
* @return a new predicated SortedBag
|
||||||
* @throws IllegalArgumentException if bag or predicate is null
|
* @throws IllegalArgumentException if bag or predicate is null
|
||||||
* @throws IllegalArgumentException if the bag contains invalid elements
|
* @throws IllegalArgumentException if the bag contains invalid elements
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.collections.set.SynchronizedSet;
|
||||||
* Iterators must be separately synchronized around the loop.
|
* Iterators must be separately synchronized around the loop.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.5 $ $Date: 2004/02/18 00:56:25 $
|
* @version $Revision: 1.6 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +40,7 @@ public class SynchronizedBag
|
||||||
* Factory method to create a synchronized bag.
|
* Factory method to create a synchronized bag.
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
|
* @return a new synchronized Bag
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
public static Bag decorate(Bag bag) {
|
public static Bag decorate(Bag bag) {
|
||||||
|
@ -68,6 +69,11 @@ public class SynchronizedBag
|
||||||
super(bag, lock);
|
super(bag, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the bag being decorated.
|
||||||
|
*
|
||||||
|
* @return the decorated bag
|
||||||
|
*/
|
||||||
protected Bag getBag() {
|
protected Bag getBag() {
|
||||||
return (Bag) collection;
|
return (Bag) collection;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +109,11 @@ public class SynchronizedBag
|
||||||
* Synchronized Set for the Bag class.
|
* Synchronized Set for the Bag class.
|
||||||
*/
|
*/
|
||||||
class SynchronizedBagSet extends SynchronizedSet {
|
class SynchronizedBagSet extends SynchronizedSet {
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param set the set to decorate
|
||||||
|
* @param lock the lock to use, shared with the bag
|
||||||
|
*/
|
||||||
SynchronizedBagSet(Set set, Object lock) {
|
SynchronizedBagSet(Set set, Object lock) {
|
||||||
super(set, lock);
|
super(set, lock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.collections.SortedBag;
|
||||||
* Iterators must be separately synchronized around the loop.
|
* Iterators must be separately synchronized around the loop.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.5 $ $Date: 2004/02/18 00:56:25 $
|
* @version $Revision: 1.6 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
*/
|
*/
|
||||||
|
@ -39,6 +39,7 @@ public class SynchronizedSortedBag
|
||||||
* Factory method to create a synchronized sorted bag.
|
* Factory method to create a synchronized sorted bag.
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
|
* @return a new synchronized SortedBag
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
public static SortedBag decorate(SortedBag bag) {
|
public static SortedBag decorate(SortedBag bag) {
|
||||||
|
@ -67,6 +68,11 @@ public class SynchronizedSortedBag
|
||||||
super(bag, lock);
|
super(bag, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the bag being decorated.
|
||||||
|
*
|
||||||
|
* @return the decorated bag
|
||||||
|
*/
|
||||||
protected SortedBag getSortedBag() {
|
protected SortedBag getSortedBag() {
|
||||||
return (SortedBag) collection;
|
return (SortedBag) collection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.apache.commons.collections.set.TransformedSet;
|
||||||
* use the Integer form to remove objects.
|
* use the Integer form to remove objects.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2004/02/18 00:56:25 $
|
* @version $Revision: 1.5 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +46,7 @@ public class TransformedBag
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
|
* @return a new transformed Bag
|
||||||
* @throws IllegalArgumentException if bag or transformer is null
|
* @throws IllegalArgumentException if bag or transformer is null
|
||||||
*/
|
*/
|
||||||
public static Bag decorate(Bag bag, Transformer transformer) {
|
public static Bag decorate(Bag bag, Transformer transformer) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.collections.Transformer;
|
||||||
* use the Integer form to remove objects.
|
* use the Integer form to remove objects.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.4 $ $Date: 2004/02/18 00:56:25 $
|
* @version $Revision: 1.5 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +44,7 @@ public class TransformedSortedBag
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
|
* @return a new transformed SortedBag
|
||||||
* @throws IllegalArgumentException if bag or transformer is null
|
* @throws IllegalArgumentException if bag or transformer is null
|
||||||
*/
|
*/
|
||||||
public static SortedBag decorate(SortedBag bag, Transformer transformer) {
|
public static SortedBag decorate(SortedBag bag, Transformer transformer) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.collections.functors.InstanceofPredicate;
|
||||||
* collection, an IllegalArgumentException is thrown.
|
* collection, an IllegalArgumentException is thrown.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.5 $ $Date: 2004/05/07 23:28:38 $
|
* @version $Revision: 1.6 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Matthew Hawthorne
|
* @author Matthew Hawthorne
|
||||||
|
@ -42,6 +42,7 @@ public class TypedBag {
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param type the type to allow into the bag, must not be null
|
* @param type the type to allow into the bag, must not be null
|
||||||
|
* @return a new typed Bag
|
||||||
* @throws IllegalArgumentException if bag or type is null
|
* @throws IllegalArgumentException if bag or type is null
|
||||||
* @throws IllegalArgumentException if the bag contains invalid elements
|
* @throws IllegalArgumentException if the bag contains invalid elements
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +54,7 @@ public class TypedBag {
|
||||||
* Restrictive constructor.
|
* Restrictive constructor.
|
||||||
*/
|
*/
|
||||||
protected TypedBag() {
|
protected TypedBag() {
|
||||||
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.collections.functors.InstanceofPredicate;
|
||||||
* collection, an IllegalArgumentException is thrown.
|
* collection, an IllegalArgumentException is thrown.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.5 $ $Date: 2004/05/07 23:28:38 $
|
* @version $Revision: 1.6 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Matthew Hawthorne
|
* @author Matthew Hawthorne
|
||||||
|
@ -42,6 +42,7 @@ public class TypedSortedBag {
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param type the type to allow into the bag, must not be null
|
* @param type the type to allow into the bag, must not be null
|
||||||
|
* @return a new transformed SortedBag
|
||||||
* @throws IllegalArgumentException if bag or type is null
|
* @throws IllegalArgumentException if bag or type is null
|
||||||
* @throws IllegalArgumentException if the bag contains invalid elements
|
* @throws IllegalArgumentException if the bag contains invalid elements
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +54,7 @@ public class TypedSortedBag {
|
||||||
* Restrictive constructor.
|
* Restrictive constructor.
|
||||||
*/
|
*/
|
||||||
protected TypedSortedBag() {
|
protected TypedSortedBag() {
|
||||||
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.collections.set.UnmodifiableSet;
|
||||||
* Decorates another <code>Bag</code> to ensure it can't be altered.
|
* Decorates another <code>Bag</code> to ensure it can't be altered.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.6 $ $Date: 2004/02/18 00:56:25 $
|
* @version $Revision: 1.7 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
*/
|
*/
|
||||||
|
@ -37,8 +37,11 @@ public final class UnmodifiableBag
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create an unmodifiable bag.
|
* Factory method to create an unmodifiable bag.
|
||||||
|
* <p>
|
||||||
|
* If the bag passed in is already unmodifiable, it is returned.
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
|
* @return an unmodifiable Bag
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
public static Bag decorate(Bag bag) {
|
public static Bag decorate(Bag bag) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.collections.set.UnmodifiableSet;
|
||||||
* Decorates another <code>SortedBag</code> to ensure it can't be altered.
|
* Decorates another <code>SortedBag</code> to ensure it can't be altered.
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision: 1.7 $ $Date: 2004/05/03 15:13:05 $
|
* @version $Revision: 1.8 $ $Date: 2004/05/15 12:27:04 $
|
||||||
*
|
*
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
*/
|
*/
|
||||||
|
@ -37,8 +37,11 @@ public final class UnmodifiableSortedBag
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create an unmodifiable bag.
|
* Factory method to create an unmodifiable bag.
|
||||||
|
* <p>
|
||||||
|
* If the bag passed in is already unmodifiable, it is returned.
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
|
* @return an unmodifiable SortedBag
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
public static SortedBag decorate(SortedBag bag) {
|
public static SortedBag decorate(SortedBag bag) {
|
||||||
|
|
Loading…
Reference in New Issue