001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.collections.list;
018
019 import java.io.IOException;
020 import java.io.ObjectInputStream;
021 import java.io.ObjectOutputStream;
022 import java.io.Serializable;
023 import java.util.Collection;
024 import java.util.List;
025
026 /**
027 * Serializable subclass of AbstractListDecorator.
028 *
029 * @author Stephen Colebourne
030 * @since Commons Collections 3.1
031 */
032 public abstract class AbstractSerializableListDecorator
033 extends AbstractListDecorator
034 implements Serializable {
035
036 /** Serialization version */
037 private static final long serialVersionUID = 2684959196747496299L;
038
039 /**
040 * Constructor.
041 */
042 protected AbstractSerializableListDecorator(List list) {
043 super(list);
044 }
045
046 //-----------------------------------------------------------------------
047 /**
048 * Write the list out using a custom routine.
049 *
050 * @param out the output stream
051 * @throws IOException
052 */
053 private void writeObject(ObjectOutputStream out) throws IOException {
054 out.defaultWriteObject();
055 out.writeObject(collection);
056 }
057
058 /**
059 * Read the list in using a custom routine.
060 *
061 * @param in the input stream
062 * @throws IOException
063 * @throws ClassNotFoundException
064 */
065 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
066 in.defaultReadObject();
067 collection = (Collection) in.readObject();
068 }
069
070 }