Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 18264 invoked from network); 2 Jun 2004 21:57:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Jun 2004 21:57:09 -0000 Received: (qmail 27345 invoked by uid 500); 2 Jun 2004 21:56:49 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 27250 invoked by uid 500); 2 Jun 2004 21:56:47 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 27128 invoked by uid 500); 2 Jun 2004 21:56:45 -0000 Received: (qmail 26946 invoked by uid 99); 2 Jun 2004 21:56:39 -0000 Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Wed, 02 Jun 2004 14:56:39 -0700 Received: (qmail 17068 invoked by uid 1529); 2 Jun 2004 21:56:20 -0000 Date: 2 Jun 2004 21:56:20 -0000 Message-ID: <20040602215620.17067.qmail@minotaur.apache.org> From: scolebourne@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/bag TransformedBag.java UnmodifiableSortedBag.java PredicatedBag.java PredicatedSortedBag.java UnmodifiableBag.java TransformedSortedBag.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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. + *

+ * 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 SortedBag to ensure it can't be altered. + *

+ * 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 @@ *

* One usage would be to ensure that no null entries are added to the bag. *

Bag bag = PredicatedBag.decorate(new HashBag(), NotNullPredicate.INSTANCE);
+ *

+ * 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 @@ *

* One usage would be to ensure that no null entries are added to the bag. *

SortedBag bag = PredicatedSortedBag.decorate(new TreeBag(), NotNullPredicate.INSTANCE);
+ *

+ * 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 Bag to ensure it can't be altered. + *

+ * 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. + *

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