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. import java.io.IOException;
  18. import java.io.ObjectInputStream;
  19. import java.io.ObjectOutputStream;
  20. import java.io.Serializable;
  21. import java.util.Collection;
  22. /**
  23. * Serializable subclass of AbstractCollectionDecorator.
  24. *
  25. * @author Stephen Colebourne
  26. * @since Commons Collections 3.1
  27. */
  28. public abstract class AbstractSerializableCollectionDecorator
  29. extends AbstractCollectionDecorator
  30. implements Serializable {
  31. /** Serialization version */
  32. private static final long serialVersionUID = 6249888059822088500L;
  33. /**
  34. * Constructor.
  35. */
  36. protected AbstractSerializableCollectionDecorator(Collection coll) {
  37. super(coll);
  38. }
  39. //-----------------------------------------------------------------------
  40. /**
  41. * Write the collection out using a custom routine.
  42. *
  43. * @param out the output stream
  44. * @throws IOException
  45. */
  46. private void writeObject(ObjectOutputStream out) throws IOException {
  47. out.defaultWriteObject();
  48. out.writeObject(collection);
  49. }
  50. /**
  51. * Read the collection in using a custom routine.
  52. *
  53. * @param in the input stream
  54. * @throws IOException
  55. * @throws ClassNotFoundException
  56. */
  57. private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  58. in.defaultReadObject();
  59. collection = (Collection) in.readObject();
  60. }
  61. }