KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > set > AbstractSerializableSetDecorator


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.set;
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 import java.util.Set JavaDoc;
24
25 /**
26  * Serializable subclass of AbstractSetDecorator.
27  *
28  * @author Stephen Colebourne
29  * @since Commons Collections 3.1
30  */

31 public abstract class AbstractSerializableSetDecorator
32         extends AbstractSetDecorator
33         implements Serializable JavaDoc {
34
35     /** Serialization version */
36     private static final long serialVersionUID = 1229469966212206107L;
37
38     /**
39      * Constructor.
40      */

41     protected AbstractSerializableSetDecorator(Set JavaDoc set) {
42         super(set);
43     }
44
45     //-----------------------------------------------------------------------
46
/**
47      * Write the set out using a custom routine.
48      *
49      * @param out the output stream
50      * @throws IOException
51      */

52     private void writeObject(ObjectOutputStream JavaDoc out) throws IOException JavaDoc {
53         out.defaultWriteObject();
54         out.writeObject(collection);
55     }
56
57     /**
58      * Read the set in using a custom routine.
59      *
60      * @param in the input stream
61      * @throws IOException
62      * @throws ClassNotFoundException
63      */

64     private void readObject(ObjectInputStream JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
65         in.defaultReadObject();
66         collection = (Collection JavaDoc) in.readObject();
67     }
68
69 }
70
Popular Tags