1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.collections15.collection;
17
18 import java.io.IOException;
19 import java.io.ObjectInputStream;
20 import java.io.ObjectOutputStream;
21 import java.io.Serializable;
22 import java.util.Collection;
23
24 /***
25 * Serializable subclass of AbstractCollectionDecorator.
26 *
27 * @author Stephen Colebourne
28 * @since Commons Collections 3.1
29 */
30 public abstract class AbstractSerializableCollectionDecorator<E>
31 extends AbstractCollectionDecorator<E>
32 implements Serializable {
33
34 /*** Serialization version */
35 private static final long serialVersionUID = 3257565113925187897L;
36
37 /***
38 * Constructor.
39 */
40 protected AbstractSerializableCollectionDecorator(Collection<E> coll) {
41 super(coll);
42 }
43
44
45 /***
46 * Write the collection out using a custom routine.
47 *
48 * @param out the output stream
49 * @throws IOException
50 */
51 private void writeObject(ObjectOutputStream out) throws IOException {
52 out.defaultWriteObject();
53 out.writeObject(collection);
54 }
55
56 /***
57 * Read the collection in using a custom routine.
58 *
59 * @param in the input stream
60 * @throws IOException
61 * @throws ClassNotFoundException
62 */
63 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
64 in.defaultReadObject();
65 collection = (Collection<E>) in.readObject();
66 }
67
68 }