package eu.dnetlib.dlms.jdbc.ast;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import eu.dnetlib.dlms.jdbc.ExecutorContext;
import eu.dnetlib.dlms.jdbc.server.IExpressionExecutor;

/**
 * Expression for the instantiation of a new object. E.g. <code> new set()</code>
 * 
 * @author alessia
 * 
 */
public class Inst extends Expression {
	/** Name of the set in which the object is created. */
	private String setName;
	/** Creation Parameters. */
	private List<Expression> pars;

	/**
	 * {@inheritDoc}
	 * 
	 * @throws SQLException
	 * 
	 * @see eu.dnetlib.dlms.jdbc.ast.Expression#evaluate(eu.dnetlib.dlms.jdbc.server.IExpressionExecutor)
	 */
	@Override
	public Object evaluate(final IExpressionExecutor executor, final ExecutorContext context) throws SQLException {
		return executor.evaluate(this, context);
	}

	/**
	 * Constructor.
	 * 
	 * @param set
	 *            name of the set in which the object is created
	 * @param pars
	 *            creation parameters
	 */
	public Inst(final String set, final List<Expression> pars) {
		this.setSetName(set);
		this.setPars(pars);
	}

	public void setPars(final List<Expression> pars) {
		this.pars = pars;
	}

	public List<Expression> getPars() {
		return this.pars;
	}

	public void setSetName(final String setName) {
		this.setName = setName;
	}

	public String getSetName() {
		return this.setName;
	}

	/** No args constructor. */
	public Inst() {
		this.pars = new ArrayList<Expression>(0);
	}

	@Override
	public String toString() {
		return "Inst [pars=" + this.pars + ", setName=" + this.setName + "]";
	}

}
