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