KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > collection > AbstractSerializableCollectionDecorator


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
19 import java.io.ObjectInputStream JavaDoc;
20 import java.io.ObjectOutputStream JavaDoc;
21 import java.io.Serializable JavaDoc;
22 import java.util.Collection JavaDoc;
23
24 /**
25  * Serializable subclass of AbstractCollectionDecorator.
26  *
27  * @author Stephen Colebourne
28  * @since Commons Collections 3.1
29  */

30 public abstract class AbstractSerializableCollectionDecorator
31         extends AbstractCollectionDecorator
32         implements Serializable JavaDoc {
33
34     /** Serialization version */
35     private static final long serialVersionUID = 6249888059822088500L;
36
37     /**
38      * Constructor.
39      */

40     protected AbstractSerializableCollectionDecorator(Collection JavaDoc 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 JavaDoc out) throws IOException JavaDoc {
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 JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
64         in.defaultReadObject();
65         collection = (Collection JavaDoc) in.readObject();
66     }
67
68 }
69
Popular Tags