1 /* Copyright (c) 2003 The Nutch Organization. All rights reserved. */ 2 /* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */ 3 4 package net.nutch.io; 5 6 import java.io.DataOutput; 7 import java.io.DataInput; 8 import java.io.IOException; 9 10 /** A simple, efficient, serialization protocol, based on {@link DataInput} and 11 * {@link DataOutput}. 12 * 13 * <p>Implementations typically implement a static <code>read(DataInput)</code> 14 * method which constructs a new instance, calls {@link 15 * #readFields(DataInput)}, and returns the instance. 16 * 17 * @author Doug Cutting 18 */ 19 public interface Writable { 20 /** Writes the fields of this object to <code>out</code>. */ 21 void write(DataOutput out) throws IOException; 22 23 /** Reads the fields of this object from <code>in</code>. For efficiency, 24 * implementations should attempt to re-use storage in the existing object 25 * where possible. 26 */ 27 void readFields(DataInput in) throws IOException; 28 } 29