class RenameField
{
	public static Table change(Table R, String[] oldName, String[] newName) 
	{
		if (oldName.length!=newName.length)
		{
			//System.out.println("Error: The number of column names to change are not consistent");
			System.out.println("ERROR: Set Size Inconsistent:");
			System.out.print("The set size of old field names < ");
			for (int i=0; i<oldName.length; i++)
			{
				System.out.print(oldName[i] + " ");
			}
			System.out.println("> is '" + oldName.length + "'");
			System.out.print("The set size of new field names < ");
			for (int i=0; i<newName.length; i++)
			{
				System.out.print(newName[i] + " ");
			}
			System.out.println("> is '" + newName.length + "'");
			System.out.println("The two set sizes MUST BE THE SAME\n");
			System.out.println("*** RENAMING OF FIELDS IGNORED ***");
			System.out.println("*** EXECUTION OF QUERY RESUMED ***\n");
		}
		else
		{
			Column c = R.getCol();

			/* go through all the old column names and replace with the new names */
			for (int i=0; i<oldName.length; i++)
			{
				int pos=c.getColPos(oldName[i]); /* get position of column name to change */

				if (pos==99)
				{
					System.out.print("Error: Cannot find the field name '"+oldName[i]+"'");
					System.out.println(" to replace with new name '"+newName[i]+"'");
				}
				else /* column name found */
					c.colNames[pos]=newName[i]; /* replace with new column name */
			}
		}

		return R;
	}
}
