001 /** 002 * =================================================== 003 * JCommon-Serializer : a free serialization framework 004 * =================================================== 005 * 006 * Project Info: http://www.jfree.org/jfreereport/jcommon-serializer/ 007 * Project Lead: Thomas Morgner; 008 * 009 * (C) Copyright 2006, by Object Refinery Limited and Pentaho Corporation. 010 * 011 * This library is free software; you can redistribute it and/or modify it under the terms 012 * of the GNU Lesser General Public License as published by the Free Software Foundation; 013 * either version 2.1 of the License, or (at your option) any later version. 014 * 015 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 016 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 017 * See the GNU Lesser General Public License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public License along with this 020 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 021 * Boston, MA 02111-1307, USA. 022 * 023 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 024 * in the United States and other countries.] 025 * 026 * ------------ 027 * SerializeMethod.java 028 * ------------ 029 * (C) Copyright 2006, by Object Refinery Limited and Pentaho Corporation. 030 * 031 * Original Author: Thomas Morgner; 032 * Contributor(s): -; 033 * 034 * $Id: SerializeMethod.java 3044 2007-07-28 17:52:44Z tmorgner $ 035 * 036 * Changes 037 * ------- 038 * 039 * 040 */ 041 042 package org.jfree.serializer; 043 044 import java.io.IOException; 045 import java.io.ObjectInputStream; 046 import java.io.ObjectOutputStream; 047 048 /** 049 * The SerializeMethod is used to define a serialization strategy for a certain object 050 * type. 051 * 052 * @author Thomas Morgner 053 */ 054 public interface SerializeMethod 055 { 056 /** 057 * Writes a serializable object description to the given object output stream. 058 * 059 * @param o the to be serialized object. 060 * @param out the outputstream that should receive the object. 061 * @throws IOException if an I/O error occured. 062 */ 063 public void writeObject (Object o, ObjectOutputStream out) 064 throws IOException; 065 066 /** 067 * Reads the object from the object input stream. 068 * 069 * @param in the object input stream from where to read the serialized data. 070 * @return the generated object. 071 * 072 * @throws IOException if reading the stream failed. 073 * @throws ClassNotFoundException if serialized object class cannot be found. 074 */ 075 public Object readObject (ObjectInputStream in) 076 throws IOException, ClassNotFoundException; 077 078 /** 079 * The class of the object, which this object can serialize. 080 * 081 * @return the class of the object type, which this method handles. 082 */ 083 public Class getObjectClass (); 084 }