package com.bretth.codec;

import com.bretth.codec.CodecException;


/**
 * Provides definition of all classes providing consumer
 * functionality.  A Consumer is a class that can receive
 * incoming data.
 * 
 * @author Brett Henderson
 */
public interface Consumer {
	
	/**
	 * Restores the internal state of a Consumer to initial settings.
	 */
	public void reset() throws CodecException;
	
	
	/**
	 * Flushes data from internal buffers to the output destination.
	 * This doesn't finalize codecs or flush data that cannot be
	 * processed yet.
	 */
	public void flush() throws CodecException;
	
	
	/**
	 * Finalises the codec and writes all available output to the
	 * output destination.  All process methods defined by extending
	 * interfaces should provide an optional finalize flag that allows
	 * a call to this method to be eliminated.  This simplifies cases
	 * where all data is provided in a single call.
	 */
	public void finalize() throws CodecException;
	
	
	/**
	 * Processes the specified data.
	 * Finalises the Consumer so that all data is processed.
	 */
	public void process(Object data) throws CodecException;
	
	
	/**
	 * Processes the specified data.
	 */
	public void process(Object data, boolean finalize) throws CodecException;
}

