package eu.dnetlib.dlms.jdbc.server;

import eu.dnetlib.dlms.lowlevel.objects.DorotyObjectEnum;

/**
 * Description of a parameter in a PreparedStatement.
 * 
 * @author lexis
 */
public class ParamInfo {

	/** Value of the parameter. */
	private Object value;
	/** The type of the value. One of the value in the enum DorotyObjectEnum. */
	private DorotyObjectEnum type;
	/** Index 1-based of the parameter in the PreparedStatement. */
	private int index;

	/**
	 * Name of the parameter in the NamedParameterStatement. In PreparedStatement, name will be the string rpresentation
	 * of the index field.
	 */
	private String name;

	/**
	 * No args constructor.
	 */
	public ParamInfo() {
	}

	/**
	 * Constructor.
	 * 
	 * @param val
	 *            Object that is the value of the parameter
	 */
	public ParamInfo(final Object val) {
		this.value = val;
	}

	/**
	 * Constructor.
	 * 
	 * @param val
	 *            Object that is the value of the parameter
	 * @param type
	 *            Types value that indicates the type of this instance's value.
	 */
	public ParamInfo(final Object val, final DorotyObjectEnum type) {
		this.value = val;
		this.type = type;
	}

	public void setValue(final Object value) {
		this.value = value;
	}

	public Object getValue() {
		return this.value;
	}

	public void setType(final DorotyObjectEnum type) {
		this.type = type;
	}

	public DorotyObjectEnum getType() {
		return this.type;
	}

	/**
	 * Gets the DorotyCode of this ParamInfo type.
	 * 
	 * @return an integer that is a type code as defined in DorotyObejctEnum.DorotyCode
	 */
	public int getTypeCode() {
		return this.type.getTypeCode();
	}

	/**
	 * Gets the name of the Java class represented in the system by this' type.
	 * 
	 * @return a String that is the name of the Java class represented in the Doroty system by the value of this.type.
	 */
	public String getJavaClassName() {
		return this.type.getJavaClass().getName();
	}

	public void setIndex(final int index) {
		this.index = index;
	}

	public int getIndex() {
		return this.index;
	}

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

	public String getName() {
		return this.name;
	}

}
