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 TypedBuffer.java TypedList.java TypedSortedBag.java TypedBag.java TypedSortedSet.java TypedSet.java TypedCollection.java
Date Fri, 09 May 2003 16:41:58 GMT
scolebourne    2003/05/09 09:41:57

  Modified:    collections/src/java/org/apache/commons/collections/decorators
                        TypedList.java TypedSortedBag.java TypedBag.java
                        TypedSortedSet.java TypedSet.java
                        TypedCollection.java
  Added:       collections/src/java/org/apache/commons/collections/decorators
                        TypedBuffer.java
  Log:
  Change typed collections to not implement the interface. 
  Instead they are just placeholders.
  This makes the decorate method more usable in IDEs.
  
  Revision  Changes    Path
  1.3       +6 -15     jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedList.java
  
  Index: TypedList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedList.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypedList.java	7 May 2003 11:20:21 -0000	1.2
  +++ TypedList.java	9 May 2003 16:41:56 -0000	1.3
  @@ -73,7 +73,7 @@
    * @author Stephen Colebourne
    * @author Matthew Hawthorne
    */
  -public class TypedList extends PredicatedList {
  +public class TypedList {
   
       /**
        * Factory method to create a typed list.
  @@ -87,22 +87,13 @@
        * @throws IllegalArgumentException if the list contains invalid elements
        */
       public static List decorate(List list, Class type) {
  -        return new TypedList(list, type);
  +        return new PredicatedList(list, TypedCollection.getPredicate(type));
       }
       
       /**
  -     * Constructor that wraps (not copies).
  -     * <p>
  -     * If there are any elements already in the list being decorated, they
  -     * are validated.
  -     * 
  -     * @param list  the list to decorate, must not be null
  -     * @param type  the type to allow into the collection, must not be null
  -     * @throws IllegalArgumentException if list or type is null
  -     * @throws IllegalArgumentException if the list contains invalid elements
  +     * Restrictive constructor.
        */
  -    protected TypedList(List list, Class type) {
  -        super(list, TypedCollection.getPredicate(type));
  +    protected TypedList() {
       }
   
   }
  
  
  
  1.2       +6 -15     jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedSortedBag.java
  
  Index: TypedSortedBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedSortedBag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypedSortedBag.java	7 May 2003 13:19:17 -0000	1.1
  +++ TypedSortedBag.java	9 May 2003 16:41:57 -0000	1.2
  @@ -73,7 +73,7 @@
    * @author Stephen Colebourne
    * @author Matthew Hawthorne
    */
  -public class TypedSortedBag extends PredicatedSortedBag {
  +public class TypedSortedBag {
   
       /**
        * Factory method to create a typed sorted bag.
  @@ -87,22 +87,13 @@
        * @throws IllegalArgumentException if the bag contains invalid elements
        */
       public static SortedBag decorate(SortedBag bag, Class type) {
  -        return new TypedSortedBag(bag, type);
  +        return new PredicatedSortedBag(bag, TypedCollection.getPredicate(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
  +     * Restrictive constructor.
        */
  -    protected TypedSortedBag(SortedBag bag, Class type) {
  -        super(bag, TypedCollection.getPredicate(type));
  +    protected TypedSortedBag() {
       }
   
   }
  
  
  
  1.2       +6 -15     jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedBag.java
  
  Index: TypedBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedBag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypedBag.java	7 May 2003 13:19:18 -0000	1.1
  +++ TypedBag.java	9 May 2003 16:41:57 -0000	1.2
  @@ -73,7 +73,7 @@
    * @author Stephen Colebourne
    * @author Matthew Hawthorne
    */
  -public class TypedBag extends PredicatedBag {
  +public class TypedBag {
   
       /**
        * Factory method to create a typed bag.
  @@ -87,22 +87,13 @@
        * @throws IllegalArgumentException if the bag contains invalid elements
        */
       public static Bag decorate(Bag bag, Class type) {
  -        return new TypedBag(bag, type);
  +        return new PredicatedBag(bag, TypedCollection.getPredicate(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
  +     * Restrictive constructor.
        */
  -    protected TypedBag(Bag bag, Class type) {
  -        super(bag, TypedCollection.getPredicate(type));
  +    protected TypedBag() {
       }
   
   }
  
  
  
  1.2       +6 -15     jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedSortedSet.java
  
  Index: TypedSortedSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedSortedSet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypedSortedSet.java	7 May 2003 11:19:46 -0000	1.1
  +++ TypedSortedSet.java	9 May 2003 16:41:57 -0000	1.2
  @@ -73,7 +73,7 @@
    * @author Stephen Colebourne
    * @author Matthew Hawthorne
    */
  -public class TypedSortedSet extends PredicatedSortedSet {
  +public class TypedSortedSet {
   
       /**
        * Factory method to create a typed sorted set.
  @@ -87,22 +87,13 @@
        * @throws IllegalArgumentException if the set contains invalid elements
        */
       public static SortedSet decorate(SortedSet set, Class type) {
  -        return new TypedSortedSet(set, type);
  +        return new PredicatedSortedSet(set, TypedCollection.getPredicate(type));
       }
       
       /**
  -     * Constructor that wraps (not copies).
  -     * <p>
  -     * If there are any elements already in the collection being decorated, they
  -     * are validated.
  -     * 
  -     * @param set  the set to decorate, must not be null
  -     * @param type  the type to allow into the collection, must not be null
  -     * @throws IllegalArgumentException if set or type is null
  -     * @throws IllegalArgumentException if the set contains invalid elements
  +     * Restrictive constructor.
        */
  -    protected TypedSortedSet(SortedSet set, Class type) {
  -        super(set, TypedCollection.getPredicate(type));
  +    protected TypedSortedSet() {
       }
   
   }
  
  
  
  1.2       +6 -15     jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedSet.java
  
  Index: TypedSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedSet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypedSet.java	7 May 2003 11:19:46 -0000	1.1
  +++ TypedSet.java	9 May 2003 16:41:57 -0000	1.2
  @@ -73,7 +73,7 @@
    * @author Stephen Colebourne
    * @author Matthew Hawthorne
    */
  -public class TypedSet extends PredicatedSet {
  +public class TypedSet {
   
       /**
        * Factory method to create a typed set.
  @@ -87,22 +87,13 @@
        * @throws IllegalArgumentException if the set contains invalid elements
        */
       public static Set decorate(Set set, Class type) {
  -        return new TypedSet(set, type);
  +        return new PredicatedSet(set, TypedCollection.getPredicate(type));
       }
       
       /**
  -     * Constructor that wraps (not copies).
  -     * <p>
  -     * If there are any elements already in the collection being decorated, they
  -     * are validated.
  -     * 
  -     * @param set  the set to decorate, must not be null
  -     * @param type  the type to allow into the collection, must not be null
  -     * @throws IllegalArgumentException if set or type is null
  -     * @throws IllegalArgumentException if the set contains invalid elements
  +     * Restrictive constructor.
        */
  -    protected TypedSet(Set set, Class type) {
  -        super(set, TypedCollection.getPredicate(type));
  +    protected TypedSet() {
       }
   
   }
  
  
  
  1.3       +7 -16     jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedCollection.java
  
  Index: TypedCollection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedCollection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypedCollection.java	5 May 2003 23:25:22 -0000	1.2
  +++ TypedCollection.java	9 May 2003 16:41:57 -0000	1.3
  @@ -75,7 +75,7 @@
    * @author Stephen Colebourne
    * @author Matthew Hawthorne
    */
  -public class TypedCollection extends PredicatedCollection {
  +public class TypedCollection {
   
       /**
        * Factory method to create a typed collection.
  @@ -89,22 +89,13 @@
        * @throws IllegalArgumentException if the collection contains invalid elements
        */
       public static Collection decorate(Collection coll, Class type) {
  -        return new TypedCollection(coll, type);
  +        return new PredicatedCollection(coll, TypedCollection.getPredicate(type));
       }
       
       /**
  -     * Constructor that wraps (not copies).
  -     * <p>
  -     * If there are any elements already in the collection being decorated, they
  -     * are validated.
  -     * 
  -     * @param coll  the collection to decorate, must not be null
  -     * @param type  the type to allow into the collection, must not be null
  -     * @throws IllegalArgumentException if collection or type is null
  -     * @throws IllegalArgumentException if the collection contains invalid elements
  +     * Restrictive constructor.
        */
  -    protected TypedCollection(Collection coll, Class type) {
  -        super(coll, getPredicate(type));
  +    protected TypedCollection() {
       }
   
       /**
  @@ -113,7 +104,7 @@
        * @param type  the type, must not be null
        * @throws IllegalArgumentException if type is null
        */
  -    static Predicate getPredicate(Class type) {
  +    protected static Predicate getPredicate(Class type) {
           return new InstanceofPredicate(type);
       }
   
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedBuffer.java
  
  Index: TypedBuffer.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedBuffer.java,v
1.1 2003/05/09 16:41:57 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.Buffer;
  
  /**
   * <code>TypedBuffer</code> decorates another <code>Buffer</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/09 16:41:57 $
   * 
   * @author Stephen Colebourne
   * @author Matthew Hawthorne
   */
  public class TypedBuffer {
  
      /**
       * Factory method to create a typed list.
       * <p>
       * If there are any elements already in the buffer being decorated, they
       * are validated.
       * 
       * @param buffer  the buffer to decorate, must not be null
       * @param type  the type to allow into the buffer, must not be null
       * @throws IllegalArgumentException if buffer or type is null
       * @throws IllegalArgumentException if the buffer contains invalid elements
       */
      public static Buffer decorate(Buffer buffer, Class type) {
          return new PredicatedBuffer(buffer, TypedCollection.getPredicate(type));
      }
      
      /**
       * Restrictive constructor.
       */
      protected TypedBuffer() {
      }
  
  }
  
  
  

---------------------------------------------------------------------
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