scolebourne 2004/06/02 15:02:34 Modified: collections/src/java/org/apache/commons/collections/set TransformedSet.java PredicatedSortedSet.java UnmodifiableSet.java TransformedSortedSet.java ListOrderedSet.java UnmodifiableSortedSet.java PredicatedSet.java Log: Make decorator classes serializable, bug 18815 Revision Changes Path 1.4 +3 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/set/TransformedSet.java Index: TransformedSet.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/set/TransformedSet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TransformedSet.java 18 Feb 2004 01:14:27 -0000 1.3 +++ TransformedSet.java 2 Jun 2004 22:02:34 -0000 1.4 @@ -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$ 1.5 +3 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java Index: PredicatedSortedSet.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PredicatedSortedSet.java 21 May 2004 21:38:42 -0000 1.4 +++ PredicatedSortedSet.java 2 Jun 2004 22:02:34 -0000 1.5 @@ -30,6 +30,8 @@ * <p> * One usage would be to ensure that no null entries are added to the set. * <pre>SortedSet set = PredicatedSortedSet.decorate(new TreeSet(), NotNullPredicate.INSTANCE);</pre> + * <p> + * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 * @version $Revision$ $Date$ 1.6 +6 -2 jakarta-commons/collections/src/java/org/apache/commons/collections/set/UnmodifiableSet.java Index: UnmodifiableSet.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/set/UnmodifiableSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- UnmodifiableSet.java 18 Feb 2004 01:14:27 -0000 1.5 +++ UnmodifiableSet.java 2 Jun 2004 22:02:34 -0000 1.6 @@ -24,13 +24,17 @@ /** * Decorates another <code>Set</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$ * * @author Stephen Colebourne */ -public final class UnmodifiableSet extends AbstractSetDecorator implements Unmodifiable { +public final class UnmodifiableSet + extends AbstractSerializableSetDecorator + implements Unmodifiable { /** * Factory method to create an unmodifiable set. 1.4 +3 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/set/TransformedSortedSet.java Index: TransformedSortedSet.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/set/TransformedSortedSet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- TransformedSortedSet.java 18 Feb 2004 01:14:27 -0000 1.3 +++ TransformedSortedSet.java 2 Jun 2004 22:02:34 -0000 1.4 @@ -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$ 1.7 +4 -2 jakarta-commons/collections/src/java/org/apache/commons/collections/set/ListOrderedSet.java Index: ListOrderedSet.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/set/ListOrderedSet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ListOrderedSet.java 18 Feb 2004 01:14:27 -0000 1.6 +++ ListOrderedSet.java 2 Jun 2004 22:02:34 -0000 1.7 @@ -40,6 +40,8 @@ * <p> * This class cannot implement the <code>List</code> interface directly as * various interface methods (notably equals/hashCode) are incompatable with a set. + * <p> + * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 * @version $Revision$ $Date$ @@ -47,7 +49,7 @@ * @author Stephen Colebourne * @author Henning P. Schmiedehausen */ -public class ListOrderedSet extends AbstractSetDecorator implements Set { +public class ListOrderedSet extends AbstractSerializableSetDecorator implements Set { /** Internal list to hold the sequence of objects */ protected final List setOrder; 1.6 +37 -2 jakarta-commons/collections/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java Index: UnmodifiableSortedSet.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- UnmodifiableSortedSet.java 18 Feb 2004 01:14:27 -0000 1.5 +++ UnmodifiableSortedSet.java 2 Jun 2004 22:02:34 -0000 1.6 @@ -15,6 +15,10 @@ */ package org.apache.commons.collections.set; +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.SortedSet; @@ -24,13 +28,20 @@ /** * Decorates another <code>SortedSet</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$ * * @author Stephen Colebourne */ -public final class UnmodifiableSortedSet extends AbstractSortedSetDecorator implements Unmodifiable { +public final class UnmodifiableSortedSet + extends AbstractSortedSetDecorator + implements Unmodifiable, Serializable { + + /** Serialization version */ + private static final long serialVersionUID = -725356885467962424L; /** * Factory method to create an unmodifiable set. @@ -43,6 +54,30 @@ return set; } return new UnmodifiableSortedSet(set); + } + + //----------------------------------------------------------------------- + /** + * 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.5 +3 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/set/PredicatedSet.java Index: PredicatedSet.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/set/PredicatedSet.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- PredicatedSet.java 21 May 2004 21:38:42 -0000 1.4 +++ PredicatedSet.java 2 Jun 2004 22:02:34 -0000 1.5 @@ -30,6 +30,8 @@ * <p> * One usage would be to ensure that no null entries are added to the set. * <pre>Set set = PredicatedSet.decorate(new HashSet(), NotNullPredicate.INSTANCE);</pre> + * <p> + * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 * @version $Revision$ $Date$
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]