/* The class contains a 'print' method that displays the contents of a table.
 * The method accepts a table as an argument and prints out the column 
 * information and each row held in the table.
 */

class  PrintTable
{
	public static void print(Table tab)
	{
		Column col = tab.getCol();

		/* print the number of columns */
		System.out.println("Number of Columns=" + col.getColNumber());
		/* print the number of columns */
		System.out.println("Number of Rows=" + tab.getNoRowSet());

		/* print each column name */
		for (int i=0; i<col.getColNumber(); i++)
		{
			System.out.print("<" + col.getPosName(i) + "> ");
		}
		System.out.println();

		/* print each column type */
		for (int i=0; i<col.getColNumber(); i++)
		{
			System.out.print("<" + col.getPosType(i) + "> ");
		}
		System.out.println();

		/* print each row in the table with its time values */
		for (int i=0; i<tab.getNoRowSet(); i++)
		{
			Row r = (Row) tab.getRow(i); /* fetch next row from the set */
			Object[] values = r.getRowValues();

			/* print each column object in the row */
			for (int j=0; j<values.length; j++)
			{
				System.out.print(values[j] + " ");
			}
			/* print the start and end time asscoiated with the row */
			System.out.println(" [" + r.getRow_st() + ", " + r.getRow_et() + "]");
		}
	}
}
