package aalg.mailer;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * IPersistable represents some object that can be written to the stream and
 * read back.
 * @author Ing. Petr Ležák
 */
public interface IPersistable {
	/**
	 * Writes object to the stream.
	 * @param stream target stream
	 * @throws IOException
	 */
	public void write (final OutputStream stream) throws IOException;

	/**
	 * Reads object from the stream.
	 * The method is required to read same amount of data that was written by
	 * method write and restore state of the object. 
	 * @param stream stream with data
	 * @throws IOException
	 */
	public void read (final InputStream stream) throws IOException;
}
