1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.collections15.list;
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 import java.util.List;
24
25 /***
26 * Serializable subclass of <code>AbstractListDecorator</code>.
27 *
28 * @author Stephen Colebourne
29 * @author Mauro Franceschini
30 *
31 * @since Commons Collections 3.1
32 */
33 public abstract class AbstractSerializableListDecorator<E>
34 extends AbstractListDecorator<E>
35 implements Serializable {
36
37
38
39
40 /*** Serialization version */
41 private static final long serialVersionUID = 2684959196747496299L;
42
43
44
45
46 /***
47 * Constructor.
48 */
49 protected AbstractSerializableListDecorator(final List<E> list) {
50 super(list);
51 }
52
53
54
55
56 /***
57 * Write the list out using a custom routine.
58 *
59 * @param out the output stream
60 * @throws IOException
61 */
62 private void writeObject(ObjectOutputStream out) throws IOException {
63 out.defaultWriteObject();
64 out.writeObject(collection);
65 }
66
67 /***
68 * Read the list in using a custom routine.
69 *
70 * @param in the input stream
71 * @throws IOException
72 * @throws ClassNotFoundException
73 */
74 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
75 in.defaultReadObject();
76 collection = (Collection<E>)in.readObject();
77 }
78
79 }