/* Class to define and hold Column information of a Table. 
 * Column information includes the number of columns, 
 * each column name and its coressponding type.
 */

class  Column
{
	int colNumber;
	String[] colNames;
	int[] colTypes;

	
	public Column(int n, String[] s, int[] t)
	{
		this.colNumber = n;
		this.colNames = s;
		this.colTypes = t;
	}

	/* Methods to return class variables */
	
	public int getColNumber()
	{
		return this.colNumber;
	}

	public String[] getColNames()
	{
		return this.colNames;
	}

	public int[] getColTypes()
	{
		return this.colTypes;
	}

	/* Methods to set each variable individually */

	public void setColNumber(int n)
	{
		this.colNumber = n;
	}

	public void setColNames(String[] s)
	{
		this.colNames = s;
	}

	public void setColTypes(int[] t)
	{
		this.colTypes = t;
	}


	/* Returns the name of the column based on position */
	public String getPosName(int pos)
	{
		return this.colNames[pos];
	}

	/* Returns the type of the column based on position */
	public int getPosType(int pos)
	{
		return this.colTypes[pos];
	}

	/* Returns the column position of the column attribute name */ 
	public int getColPos(String name)
	{
		int pos=99;
		//String[] colNames = getColNames();

		//for (int i=0; i<colNames.length; i++)
		//{
		//	if(name.equals(colNames[i]))
		//	{
		//		pos=i;
		//	}
		//}

		int index=0;

		/* finds the first matching name */
		while(index<colNames.length && pos==99)
		{
			if ( name.equals(colNames[index]) )
			{
				pos=index;
			}
			index++;
		}

		return pos;
	}


	/* Returns the type of the column given column attribute name */
	public int getNameType(String name)
	{
		int pos = getColPos(name);
		int type = getPosType(pos);

		return type;
	}

}
