You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2004/06/02 23:56:20 UTC

cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/bag TransformedBag.java UnmodifiableSortedBag.java PredicatedBag.java PredicatedSortedBag.java UnmodifiableBag.java TransformedSortedBag.java

scolebourne    2004/06/02 14:56:20

  Modified:    collections/src/java/org/apache/commons/collections/bag
                        TransformedBag.java UnmodifiableSortedBag.java
                        PredicatedBag.java PredicatedSortedBag.java
                        UnmodifiableBag.java TransformedSortedBag.java
  Log:
  Make decorator classes serializable, bug 18815
  
  Revision  Changes    Path
  1.6       +3 -1      jakarta-commons/collections/src/java/org/apache/commons/collections/bag/TransformedBag.java
  
  Index: TransformedBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bag/TransformedBag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TransformedBag.java	15 May 2004 12:27:04 -0000	1.5
  +++ TransformedBag.java	2 Jun 2004 21:56:19 -0000	1.6
  @@ -29,6 +29,8 @@
    * Thus objects must be removed or searched for using their transformed form.
    * For example, if the transformation converts Strings to Integers, you must
    * use the Integer form to remove objects.
  + * <p>
  + * This class is Serializable from Commons Collections 3.1.
    *
    * @since Commons Collections 3.0
    * @version $Revision$ $Date$
  
  
  
  1.9       +35 -2     jakarta-commons/collections/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java
  
  Index: UnmodifiableSortedBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- UnmodifiableSortedBag.java	15 May 2004 12:27:04 -0000	1.8
  +++ UnmodifiableSortedBag.java	2 Jun 2004 21:56:19 -0000	1.9
  @@ -15,6 +15,10 @@
    */
   package org.apache.commons.collections.bag;
   
  +import java.io.IOException;
  +import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
  +import java.io.Serializable;
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.Set;
  @@ -26,6 +30,8 @@
   
   /**
    * Decorates another <code>SortedBag</code> to ensure it can't be altered.
  + * <p>
  + * This class is Serializable from Commons Collections 3.1.
    *
    * @since Commons Collections 3.0
    * @version $Revision$ $Date$
  @@ -33,7 +39,10 @@
    * @author Stephen Colebourne
    */
   public final class UnmodifiableSortedBag
  -        extends AbstractSortedBagDecorator implements Unmodifiable {
  +        extends AbstractSortedBagDecorator implements Unmodifiable, Serializable {
  +
  +    /** Serialization version */
  +    private static final long serialVersionUID = -3190437252665717841L;
   
       /**
        * Factory method to create an unmodifiable bag.
  @@ -60,6 +69,30 @@
        */
       private UnmodifiableSortedBag(SortedBag bag) {
           super(bag);
  +    }
  +
  +    //-----------------------------------------------------------------------
  +    /**
  +     * Write the collection out using a custom routine.
  +     * 
  +     * @param out  the output stream
  +     * @throws IOException
  +     */
  +    private void writeObject(ObjectOutputStream out) throws IOException {
  +        out.defaultWriteObject();
  +        out.writeObject(collection);
  +    }
  +
  +    /**
  +     * Read the collection in using a custom routine.
  +     * 
  +     * @param in  the input stream
  +     * @throws IOException
  +     * @throws ClassNotFoundException
  +     */
  +    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  +        in.defaultReadObject();
  +        collection = (Collection) in.readObject();
       }
   
       //-----------------------------------------------------------------------
  
  
  
  1.7       +3 -1      jakarta-commons/collections/src/java/org/apache/commons/collections/bag/PredicatedBag.java
  
  Index: PredicatedBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bag/PredicatedBag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PredicatedBag.java	21 May 2004 21:38:40 -0000	1.6
  +++ PredicatedBag.java	2 Jun 2004 21:56:19 -0000	1.7
  @@ -31,6 +31,8 @@
    * <p>
    * One usage would be to ensure that no null entries are added to the bag.
    * <pre>Bag bag = PredicatedBag.decorate(new HashBag(), NotNullPredicate.INSTANCE);</pre>
  + * <p>
  + * This class is Serializable from Commons Collections 3.1.
    *
    * @since Commons Collections 3.0
    * @version $Revision$ $Date$
  
  
  
  1.7       +3 -1      jakarta-commons/collections/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java
  
  Index: PredicatedSortedBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PredicatedSortedBag.java	21 May 2004 21:38:40 -0000	1.6
  +++ PredicatedSortedBag.java	2 Jun 2004 21:56:19 -0000	1.7
  @@ -30,6 +30,8 @@
    * <p>
    * One usage would be to ensure that no null entries are added to the bag.
    * <pre>SortedBag bag = PredicatedSortedBag.decorate(new TreeBag(), NotNullPredicate.INSTANCE);</pre>
  + * <p>
  + * This class is Serializable from Commons Collections 3.1.
    *
    * @since Commons Collections 3.0
    * @version $Revision$ $Date$
  
  
  
  1.8       +35 -2     jakarta-commons/collections/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java
  
  Index: UnmodifiableBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- UnmodifiableBag.java	15 May 2004 12:27:04 -0000	1.7
  +++ UnmodifiableBag.java	2 Jun 2004 21:56:19 -0000	1.8
  @@ -15,6 +15,10 @@
    */
   package org.apache.commons.collections.bag;
   
  +import java.io.IOException;
  +import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
  +import java.io.Serializable;
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.Set;
  @@ -26,6 +30,8 @@
   
   /**
    * Decorates another <code>Bag</code> to ensure it can't be altered.
  + * <p>
  + * This class is Serializable from Commons Collections 3.1.
    *
    * @since Commons Collections 3.0
    * @version $Revision$ $Date$
  @@ -33,7 +39,10 @@
    * @author Stephen Colebourne
    */
   public final class UnmodifiableBag
  -        extends AbstractBagDecorator implements Unmodifiable {
  +        extends AbstractBagDecorator implements Unmodifiable, Serializable {
  +
  +    /** Serialization version */
  +    private static final long serialVersionUID = -1873799975157099624L;
   
       /**
        * Factory method to create an unmodifiable bag.
  @@ -60,6 +69,30 @@
        */
       private UnmodifiableBag(Bag bag) {
           super(bag);
  +    }
  +
  +    //-----------------------------------------------------------------------
  +    /**
  +     * Write the collection out using a custom routine.
  +     * 
  +     * @param out  the output stream
  +     * @throws IOException
  +     */
  +    private void writeObject(ObjectOutputStream out) throws IOException {
  +        out.defaultWriteObject();
  +        out.writeObject(collection);
  +    }
  +
  +    /**
  +     * Read the collection in using a custom routine.
  +     * 
  +     * @param in  the input stream
  +     * @throws IOException
  +     * @throws ClassNotFoundException
  +     */
  +    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  +        in.defaultReadObject();
  +        collection = (Collection) in.readObject();
       }
   
       //-----------------------------------------------------------------------
  
  
  
  1.6       +3 -1      jakarta-commons/collections/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java
  
  Index: TransformedSortedBag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TransformedSortedBag.java	15 May 2004 12:27:04 -0000	1.5
  +++ TransformedSortedBag.java	2 Jun 2004 21:56:19 -0000	1.6
  @@ -27,6 +27,8 @@
    * Thus objects must be removed or searched for using their transformed form.
    * For example, if the transformation converts Strings to Integers, you must
    * use the Integer form to remove objects.
  + * <p>
  + * This class is Serializable from Commons Collections 3.1.
    *
    * @since Commons Collections 3.0
    * @version $Revision$ $Date$
  
  
  

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