package eu.dnetlib.dlms.jdbc.server;

import java.sql.SQLException;

import eu.dnetlib.dlms.jdbc.ExecutorContext;
import eu.dnetlib.dlms.jdbc.ast.Assign;
import eu.dnetlib.dlms.jdbc.ast.DeclInit;
import eu.dnetlib.dlms.jdbc.ast.RunExpr;
import eu.dnetlib.dlms.jdbc.ast.Select;

/**
 * Interface for Statement executors.
 * 
 * @author alessia
 * 
 */
public interface IStatementExecutor {
	/** Enumaration for the attributes that can be selected with a Select statement. */
	public enum SelectableAttribute {
		/** Identifier of the object. */
		id,
		/** URL to get the object. */
		url,
		/** URL to the payload (only for atoms). */
		contentURL
	}

	/**
	 * Executes the Assign node in the given context.
	 * 
	 * @param assign
	 *            node to execute
	 * @param context
	 *            current context
	 * @return the result of the execution
	 * @throws SQLException
	 *             problems during execution
	 */
	Object execute(Assign assign, ExecutorContext context) throws SQLException;

	/**
	 * Executes the DeclInit node in the given context.
	 * 
	 * @param declInit
	 *            node to execute
	 * @param context
	 *            current context
	 * @return the result of the execution
	 * @throws SQLException
	 *             problems during execution
	 */
	Object execute(DeclInit declInit, ExecutorContext context) throws SQLException;

	/**
	 * Executes the Select node in the given context.
	 * 
	 * @param select
	 *            node to execute
	 * @param context
	 *            current context
	 * @return the result of the execution
	 * @throws SQLException
	 *             problems during execution
	 */
	Object execute(Select select, ExecutorContext context) throws SQLException;

	/**
	 * Executes the RunExpr node in the given context.
	 * 
	 * @param runExpr
	 *            node to execute
	 * @param context
	 *            current context
	 * @return the result of the execution
	 * @throws SQLException
	 *             problems during execution
	 */
	Object execute(RunExpr runExpr, ExecutorContext context) throws SQLException;
}
