01: /*
02: * Copyright 2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.collections.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 AbstractListDecorator.
27: *
28: * @author Stephen Colebourne
29: * @since Commons Collections 3.1
30: */
31: public abstract class AbstractSerializableListDecorator extends
32: AbstractListDecorator implements Serializable {
33:
34: /** Serialization version */
35: private static final long serialVersionUID = 2684959196747496299L;
36:
37: /**
38: * Constructor.
39: */
40: protected AbstractSerializableListDecorator(List list) {
41: super (list);
42: }
43:
44: //-----------------------------------------------------------------------
45: /**
46: * Write the list 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 list 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,
64: ClassNotFoundException {
65: in.defaultReadObject();
66: collection = (Collection) in.readObject();
67: }
68:
69: }
|