commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/decorators PredicatedBag.java UnmodifiableBag.java SynchronizedSortedBag.java SynchronizedBag.java TypedSortedBag.java UnmodifiableSortedBag.java PredicatedSortedBag.java TypedBag.java AbstractSortedBagDecorator.java AbstractBagDecorator.java
Date Wed, 07 May 2003 13:19:18 GMT
scolebourne    2003/05/07 06:19:18

  Added:       collections/src/java/org/apache/commons/collections/decorators
                        PredicatedBag.java UnmodifiableBag.java
                        SynchronizedSortedBag.java SynchronizedBag.java
                        TypedSortedBag.java UnmodifiableSortedBag.java
                        PredicatedSortedBag.java TypedBag.java
                        AbstractSortedBagDecorator.java
                        AbstractBagDecorator.java
  Log:
  Add Bag collection decorators
  
  Revision  Changes    Path
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/PredicatedBag.java
  
  Index: PredicatedBag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/PredicatedBag.java,v 1.1 2003/05/07 13:19:17 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 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.decorators;
  
  import java.util.Set;
  
  import org.apache.commons.collections.Bag;
  import org.apache.commons.collections.Predicate;
  
  /**
   * <code>PredicatedBag</code> decorates another <code>Bag</code>
   * to validate additions match a specified predicate.
   * <p>
   * If an object cannot be addded to the list, an IllegalArgumentException
   * is thrown.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:17 $
   * 
   * @author Stephen Colebourne
   * @author Paul Jack
   */
  public class PredicatedBag extends PredicatedCollection implements Bag {
  
      /**
       * Factory method to create a predicated (validating) bag.
       * <p>
       * If there are any elements already in the bag being decorated, they
       * are validated.
       * 
       * @param bag  the bag to decorate, must not be null
       * @param predicate  the predicate to use for validation, must not be null
       * @throws IllegalArgumentException if bag or predicate is null
       * @throws IllegalArgumentException if the bag contains invalid elements
       */
      public static Bag decorate(Bag bag, Predicate predicate) {
          return new PredicatedBag(bag, predicate);
      }
  
      /**
       * Constructor that wraps (not copies).
       * <p>
       * If there are any elements already in the bag being decorated, they
       * are validated.
       * 
       * @param bag  the bag to decorate, must not be null
       * @param predicate  the predicate to use for validation, must not be null
       * @throws IllegalArgumentException if bag or predicate is null
       * @throws IllegalArgumentException if the bag contains invalid elements
       */
      protected PredicatedBag(Bag bag, Predicate predicate) {
          super(bag, predicate);
      }
  
      /**
       * Gets the decorated bag.
       * 
       * @return the decorated bag
       */
      protected Bag getBag() {
          return (Bag) getCollection();
      }
      
      //-----------------------------------------------------------------------
      public boolean add(Object object, int count) {
          validate(object);
          return getBag().add(object, count);
      }
  
      public boolean remove(Object object, int count) {
          return getBag().remove(object, count);
      }
  
      public Set uniqueSet() {
          return getBag().uniqueSet();
      }
  
      public int getCount(Object object) {
          return getBag().getCount(object);
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/UnmodifiableBag.java
  
  Index: UnmodifiableBag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/UnmodifiableBag.java,v 1.1 2003/05/07 13:19:17 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 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.decorators;
  
  import java.util.Set;
  
  import org.apache.commons.collections.Bag;
  
  /**
   * <code>UnmodifiableBag</code> decorates another <code>Bag</code>
   * to ensure it can't be altered.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:17 $
   * 
   * @author Stephen Colebourne
   */
  public class UnmodifiableBag extends UnmodifiableCollection implements Bag {
  
      /**
       * Factory method to create an unmodifiable bag.
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      public static Bag decorate(Bag bag) {
          return new UnmodifiableBag(bag);
      }
  
      /**
       * Constructor that wraps (not copies).
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      protected UnmodifiableBag(Bag bag) {
          super(bag);
      }
  
      /**
       * Gets the bag being decorated.
       * 
       * @return the decorated bag
       */
      protected Bag getBag() {
          return (Bag) getCollection();
      }
  
      //-----------------------------------------------------------------------
      public boolean add(Object o, int count) {
          throw new UnsupportedOperationException();
      }
  
      public boolean remove(Object o, int count) {
          throw new UnsupportedOperationException();
      }
  
      public Set uniqueSet() {
          Set set = getBag().uniqueSet();
          return new UnmodifiableSet(set);
      }
  
      public int getCount(Object o) {
          return getBag().getCount(o);
      }
      
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/SynchronizedSortedBag.java
  
  Index: SynchronizedSortedBag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/SynchronizedSortedBag.java,v 1.1 2003/05/07 13:19:17 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 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.decorators;
  
  import java.util.Comparator;
  
  import org.apache.commons.collections.Bag;
  import org.apache.commons.collections.SortedBag;
  
  /**
   * <code>SynchronizedSortedBag</code> decorates another <code>SortedBag</code>
   * to synchronize its behaviour for a multi-threaded environment.
   * <p>
   * Methods are synchronized, then forwarded to the decorated bag.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:17 $
   * 
   * @author Stephen Colebourne
   */
  public class SynchronizedSortedBag extends SynchronizedBag implements SortedBag {
  
      /**
       * Factory method to create a synchronized sorted bag.
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      public static SortedBag decorate(SortedBag bag) {
          return new SynchronizedSortedBag(bag);
      }
      
      /**
       * Constructor that wraps (not copies).
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      protected SynchronizedSortedBag(SortedBag bag) {
          super(bag);
      }
  
      /**
       * Constructor that wraps (not copies).
       * 
       * @param bag  the bag to decorate, must not be null
       * @param lock  the lock to use, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      protected SynchronizedSortedBag(Bag bag, Object lock) {
          super(bag, lock);
      }
  
      protected SortedBag getSortedBag() {
          return (SortedBag) collection;
      }
      
      //-----------------------------------------------------------------------
      public synchronized Object first() {
          synchronized (lock) {
              return getSortedBag().first();
          }
      }
  
      public synchronized Object last() {
          synchronized (lock) {
              return getSortedBag().last();
          }
      }
  
      public synchronized Comparator comparator() {
          synchronized (lock) {
              return getSortedBag().comparator();
          }
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/SynchronizedBag.java
  
  Index: SynchronizedBag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/SynchronizedBag.java,v 1.1 2003/05/07 13:19:17 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 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.decorators;
  
  import java.util.Set;
  
  import org.apache.commons.collections.Bag;
  
  /**
   * <code>SynchronizedBag</code> decorates another <code>Bag</code>
   * to synchronize its behaviour for a multi-threaded environment.
   * <p>
   * Methods are synchronized, then forwarded to the decorated bag.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:17 $
   * 
   * @author Stephen Colebourne
   */
  public class SynchronizedBag extends SynchronizedCollection implements Bag {
  
      /**
       * Factory method to create a synchronized bag.
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      public static Bag decorate(Bag bag) {
          return new SynchronizedBag(bag);
      }
      
      /**
       * Constructor that wraps (not copies).
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      protected SynchronizedBag(Bag bag) {
          super(bag);
      }
  
      /**
       * Constructor that wraps (not copies).
       * 
       * @param bag  the bag to decorate, must not be null
       * @param lock  the lock to use, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      protected SynchronizedBag(Bag bag, Object lock) {
          super(bag, lock);
      }
  
      protected Bag getBag() {
          return (Bag) collection;
      }
      
      //-----------------------------------------------------------------------
      public boolean add(Object object, int count) {
          synchronized (lock) {
              return getBag().add(object, count);
          }
      }
  
      public boolean remove(Object object, int count) {
          synchronized (lock) {
              return getBag().remove(object, count);
          }
      }
  
      public Set uniqueSet() {
          synchronized (lock) {
              Set set = getBag().uniqueSet();
              return new SynchronizedSet(set, lock);
          }
      }
  
      public int getCount(Object object) {
          synchronized (lock) {
              return getBag().getCount(object);
          }
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedSortedBag.java
  
  Index: TypedSortedBag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedSortedBag.java,v 1.1 2003/05/07 13:19:17 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 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.decorators;
  
  import org.apache.commons.collections.SortedBag;
  
  /**
   * <code>TypedSortedBag</code> decorates another <code>SortedBag</code>
   * to validate that elements added are of a specific type.
   * <p>
   * The validation of additions is performed via an instanceof test against 
   * a specified <code>Class</code>. If an object cannot be addded to the
   * collection, an IllegalArgumentException is thrown.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:17 $
   * 
   * @author Stephen Colebourne
   * @author Matthew Hawthorne
   */
  public class TypedSortedBag extends PredicatedSortedBag {
  
      /**
       * Factory method to create a typed sorted bag.
       * <p>
       * If there are any elements already in the bag being decorated, they
       * are validated.
       * 
       * @param bag  the bag to decorate, must not be null
       * @param type  the type to allow into the bag, must not be null
       * @throws IllegalArgumentException if bag or type is null
       * @throws IllegalArgumentException if the bag contains invalid elements
       */
      public static SortedBag decorate(SortedBag bag, Class type) {
          return new TypedSortedBag(bag, type);
      }
      
      /**
       * Constructor that wraps (not copies).
       * <p>
       * If there are any elements already in the bag being decorated, they
       * are validated.
       * 
       * @param bag  the bag to decorate, must not be null
       * @param type  the type to allow into the bag, must not be null
       * @throws IllegalArgumentException if bag or type is null
       * @throws IllegalArgumentException if the bag contains invalid elements
       */
      protected TypedSortedBag(SortedBag bag, Class type) {
          super(bag, TypedCollection.getPredicate(type));
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/UnmodifiableSortedBag.java
  
  Index: UnmodifiableSortedBag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/UnmodifiableSortedBag.java,v 1.1 2003/05/07 13:19:17 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 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.decorators;
  
  import java.util.Comparator;
  
  import org.apache.commons.collections.SortedBag;
  
  /**
   * <code>UnmodifiableSortedBag</code> decorates another <code>SortedBag</code>
   * to ensure it can't be altered.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:17 $
   * 
   * @author Stephen Colebourne
   */
  public class UnmodifiableSortedBag extends UnmodifiableBag implements SortedBag {
  
      /**
       * Factory method to create an unmodifiable bag.
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      public static SortedBag decorate(SortedBag bag) {
          return new UnmodifiableSortedBag(bag);
      }
  
      /**
       * Constructor that wraps (not copies).
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if bag is null
       */
      protected UnmodifiableSortedBag(SortedBag bag) {
          super(bag);
      }
  
      /**
       * Gets the bag being decorated.
       * 
       * @return the decorated bag
       */
      protected SortedBag getSortedBag() {
          return (SortedBag) getCollection();
      }
  
      //-----------------------------------------------------------------------
      public Object first() {
          return getSortedBag().first();
      }
  
      public Object last() {
          return getSortedBag().last();
      }
  
      public Comparator comparator() {
          return getSortedBag().comparator();
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/PredicatedSortedBag.java
  
  Index: PredicatedSortedBag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/PredicatedSortedBag.java,v 1.1 2003/05/07 13:19:18 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 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.decorators;
  
  import java.util.Comparator;
  
  import org.apache.commons.collections.Predicate;
  import org.apache.commons.collections.SortedBag;
  
  /**
   * <code>PredicatedSortedBag</code> decorates another <code>SortedBag</code>
   * to validate additions match a specified predicate.
   * <p>
   * If an object cannot be addded to the list, an IllegalArgumentException
   * is thrown.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:18 $
   * 
   * @author Stephen Colebourne
   * @author Paul Jack
   */
  public class PredicatedSortedBag extends PredicatedBag implements SortedBag {
  
      /**
       * Factory method to create a predicated (validating) bag.
       * <p>
       * If there are any elements already in the bag being decorated, they
       * are validated.
       * 
       * @param bag  the bag to decorate, must not be null
       * @param predicate  the predicate to use for validation, must not be null
       * @throws IllegalArgumentException if bag or predicate is null
       * @throws IllegalArgumentException if the bag contains invalid elements
       */
      public static SortedBag decorate(SortedBag bag, Predicate predicate) {
          return new PredicatedSortedBag(bag, predicate);
      }
  
      /**
       * Constructor that wraps (not copies).
       * <p>
       * If there are any elements already in the bag being decorated, they
       * are validated.
       * 
       * @param bag  the bag to decorate, must not be null
       * @param predicate  the predicate to use for validation, must not be null
       * @throws IllegalArgumentException if bag or predicate is null
       * @throws IllegalArgumentException if the bag contains invalid elements
       */
      protected PredicatedSortedBag(SortedBag bag, Predicate predicate) {
          super(bag, predicate);
      }
  
      /**
       * Gets the decorated sorted bag.
       * 
       * @return the decorated bag
       */
      protected SortedBag getSortedBag() {
          return (SortedBag) getCollection();
      }
      
      //-----------------------------------------------------------------------
      public Object first() {
          return getSortedBag().first();
      }
  
      public Object last() {
          return getSortedBag().last();
      }
  
      public Comparator comparator() {
          return getSortedBag().comparator();
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedBag.java
  
  Index: TypedBag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedBag.java,v 1.1 2003/05/07 13:19:18 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 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.decorators;
  
  import org.apache.commons.collections.Bag;
  
  /**
   * <code>TypedBag</code> decorates another <code>Bag</code>
   * to validate that elements added are of a specific type.
   * <p>
   * The validation of additions is performed via an instanceof test against 
   * a specified <code>Class</code>. If an object cannot be addded to the
   * collection, an IllegalArgumentException is thrown.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:18 $
   * 
   * @author Stephen Colebourne
   * @author Matthew Hawthorne
   */
  public class TypedBag extends PredicatedBag {
  
      /**
       * Factory method to create a typed bag.
       * <p>
       * If there are any elements already in the bag being decorated, they
       * are validated.
       * 
       * @param bag  the bag to decorate, must not be null
       * @param type  the type to allow into the bag, must not be null
       * @throws IllegalArgumentException if bag or type is null
       * @throws IllegalArgumentException if the bag contains invalid elements
       */
      public static Bag decorate(Bag bag, Class type) {
          return new TypedBag(bag, type);
      }
      
      /**
       * Constructor that wraps (not copies).
       * <p>
       * If there are any elements already in the bag being decorated, they
       * are validated.
       * 
       * @param bag  the bag to decorate, must not be null
       * @param type  the type to allow into the bag, must not be null
       * @throws IllegalArgumentException if bag or type is null
       * @throws IllegalArgumentException if the bag contains invalid elements
       */
      protected TypedBag(Bag bag, Class type) {
          super(bag, TypedCollection.getPredicate(type));
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/AbstractSortedBagDecorator.java
  
  Index: AbstractSortedBagDecorator.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/AbstractSortedBagDecorator.java,v 1.1 2003/05/07 13:19:18 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 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.decorators;
  
  import java.util.Comparator;
  
  import org.apache.commons.collections.SortedBag;
  
  /**
   * <code>AbstractSortedBagDecorator</code> decorates another <code>SortedBag</code>.
   * <p>
   * Methods are forwarded directly to the decorated bag.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:18 $
   * 
   * @author Stephen Colebourne
   */
  public abstract class AbstractSortedBagDecorator extends AbstractBagDecorator implements SortedBag {
  
      /**
       * Constructor that wraps (not copies).
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if list is null
       */
      protected AbstractSortedBagDecorator(SortedBag bag) {
          super(bag);
      }
  
      /**
       * Gets the bag being decorated.
       * 
       * @return the decorated bag
       */
      protected SortedBag getSortedBag() {
          return (SortedBag) getCollection();
      }
  
      //-----------------------------------------------------------------------
      public Object first() {
          return getSortedBag().first();
      }
  
      public Object last() {
          return getSortedBag().last();
      }
  
      public Comparator comparator() {
          return getSortedBag().comparator();
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/AbstractBagDecorator.java
  
  Index: AbstractBagDecorator.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/AbstractBagDecorator.java,v 1.1 2003/05/07 13:19:18 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 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.decorators;
  
  import java.util.Set;
  
  import org.apache.commons.collections.Bag;
  
  /**
   * <code>AbstractBagDecorator</code> decorates another <code>Bag</code>.
   * <p>
   * Methods are forwarded directly to the decorated bag.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/05/07 13:19:18 $
   * 
   * @author Stephen Colebourne
   */
  public abstract class AbstractBagDecorator extends AbstractCollectionDecorator implements Bag {
  
      /**
       * Constructor that wraps (not copies).
       * 
       * @param bag  the bag to decorate, must not be null
       * @throws IllegalArgumentException if list is null
       */
      protected AbstractBagDecorator(Bag bag) {
          super(bag);
      }
  
      /**
       * Gets the bag being decorated.
       * 
       * @return the decorated bag
       */
      protected Bag getBag() {
          return (Bag) getCollection();
      }
  
      //-----------------------------------------------------------------------
      public int getCount(Object object) {
          return getBag().getCount(object);
      }
  
      public boolean add(Object object, int count) {
          return getBag().add(object, count);
      }
  
      public boolean remove(Object object, int count) {
          return getBag().remove(object, count);
      }
  
      public Set uniqueSet() {
          return getBag().uniqueSet();
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message