package eu.dnetlib.dlms.jdbc.ast;

import java.sql.SQLException;

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

/**
 * References to already used variables.
 * 
 * @author alessia
 * 
 */
public class Ref extends Expression {
	/** Variable name. */
	private String ref;

	/**
	 * {@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 ref
	 *            variable name
	 */
	public Ref(final String ref) {
		this.setRef(ref);
	}

	public void setRef(final String ref) {
		this.ref = ref;
	}

	public String getRef() {
		return this.ref;
	}

	@Override
	public String toString() {
		return "Ref [ref=" + this.ref + "]";
	}

}
