/***********************************************************************************************************************
 *
 * Copyright (C) 2010 by the Stratosphere project (http://stratosphere.eu)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 **********************************************************************************************************************/

package eu.stratosphere.nephele.io;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * This interface must be implemented by every class whose objects have to be serialized to their binary representation
 * and vice-versa. In particular, records have to implement this interface in order to specify how their data can be
 * transfered
 * to a binary representation.
 * When implementing this Interface make sure that the implementing class has a default (zero-argument) constructor!
 * 
 * @author warneke
 */
public interface IOReadableWritable {

	/**
	 * Writes the object's internal data to the given data output stream.
	 * 
	 * @param out
	 *        the output stream to receive the data.
	 * @throws IOException
	 *         thrown if any error occurs while writing to the output stream
	 */
	void write(DataOutput out) throws IOException;

	/**
	 * Reads the object's internal data from the given data input stream.
	 * 
	 * @param in
	 *        the input stream to read the data from
	 * @throws IOException
	 *         thrown if any error occurs while reading from the input stream
	 */
	void read(DataInput in) throws IOException;

}
