package prolog.model;

import java.io.*;
import java.util.*;

/**
 * <p>The statementmap stores statements under their name.
 * It is a collection with statements but for faster access from
 * the interpreter, they are stored in a map to prevent iterations.</p>
 */
public interface IStatementMap
{
	/**
	 * clears the statement map
	 */
	public void clear();

	/**
	 * returns a iterator over all stored statements
	 */
	public Iterator getStatements();

	/**
	 * returns the statement for the given name
	 * @param key is the name
	 * @return a statement if one was found ;-)
	 */
	public IStatement getStatement( int key );

	/**
	 * adds a statement to the statementmap
	 */
	public void addStatement( IStatement statement );

	/**
	 * returns a statement matching the given fact, if one was found.
	 */
	public IStatement getMatchingStatement( IFact fact );

	/**
	 * generates a xml representation with decoded symbols
	 * @param out
	 * @param table
	 * @throws IOException
	 */
	public void genXml( Writer out, ISymbolTable table )
		throws IOException;

	/**
	 * returns a string representation with decoded symbols
	 * @param table
	 * @return
	 */
	public String toString( ISymbolTable table );
}
