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.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 extends
31: AbstractCollectionDecorator implements Serializable {
32:
33: /** Serialization version */
34: private static final long serialVersionUID = 6249888059822088500L;
35:
36: /**
37: * Constructor.
38: */
39: protected AbstractSerializableCollectionDecorator(Collection coll) {
40: super (coll);
41: }
42:
43: //-----------------------------------------------------------------------
44: /**
45: * Write the collection out using a custom routine.
46: *
47: * @param out the output stream
48: * @throws IOException
49: */
50: private void writeObject(ObjectOutputStream out) throws IOException {
51: out.defaultWriteObject();
52: out.writeObject(collection);
53: }
54:
55: /**
56: * Read the collection in using a custom routine.
57: *
58: * @param in the input stream
59: * @throws IOException
60: * @throws ClassNotFoundException
61: */
62: private void readObject(ObjectInputStream in) throws IOException,
63: ClassNotFoundException {
64: in.defaultReadObject();
65: collection = (Collection) in.readObject();
66: }
67:
68: }
|