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:57:03 UTC
cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/buffer UnmodifiableBuffer.java TransformedBuffer.java PredicatedBuffer.java
scolebourne 2004/06/02 14:57:03
Modified: collections/src/java/org/apache/commons/collections/buffer
UnmodifiableBuffer.java TransformedBuffer.java
PredicatedBuffer.java
Log:
Make decorator classes serializable, bug 18815
Revision Changes Path
1.7 +37 -2 jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java
Index: UnmodifiableBuffer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- UnmodifiableBuffer.java 15 May 2004 12:33:23 -0000 1.6
+++ UnmodifiableBuffer.java 2 Jun 2004 21:57:03 -0000 1.7
@@ -15,6 +15,10 @@
*/
package org.apache.commons.collections.buffer;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
@@ -24,13 +28,20 @@
/**
* Decorates another <code>Buffer</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 UnmodifiableBuffer extends AbstractBufferDecorator implements Unmodifiable {
+public final class UnmodifiableBuffer
+ extends AbstractBufferDecorator
+ implements Unmodifiable, Serializable {
+
+ /** Serialization version */
+ private static final long serialVersionUID = 1832948656215393357L;
/**
* Factory method to create an unmodifiable buffer.
@@ -57,6 +68,30 @@
*/
private UnmodifiableBuffer(Buffer buffer) {
super(buffer);
+ }
+
+ //-----------------------------------------------------------------------
+ /**
+ * 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/buffer/TransformedBuffer.java
Index: TransformedBuffer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/TransformedBuffer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TransformedBuffer.java 15 May 2004 12:33:23 -0000 1.4
+++ TransformedBuffer.java 2 Jun 2004 21:57:03 -0000 1.5
@@ -26,6 +26,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.6 +3 -1 jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java
Index: PredicatedBuffer.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PredicatedBuffer.java 21 May 2004 21:38:48 -0000 1.5
+++ PredicatedBuffer.java 2 Jun 2004 21:57:03 -0000 1.6
@@ -29,6 +29,8 @@
* <p>
* One usage would be to ensure that no null entries are added to the buffer.
* <pre>Buffer buffer = PredicatedBuffer.decorate(new UnboundedFifoBuffer(), 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org