/* Class to define and hold a Table.
 * A table consists of column information and 
 * a set of rows.
 */

import java.util.*;

class  Table
{
	Column col;
	ArrayList rowSet = new ArrayList();



	/* setting column information by supplying all the column parameters */
	public void putCol(int n, String[] s, int[] t)
	{
		this.col=new Column(n,s,t);
	}

	/* adding a row to the set by supplying all the row parameters */
	public void putRow(Object[] v, int st, int et)
	{
		Row r = new Row(v, st, et);
		this.rowSet.add(r);
	}



	/* Method related to col variable */

	public int getNoCols()
	{
		return this.col.getColNumber();
	}

	public Column getCol()
	{
		return this.col;
	}

	public void setCol(Column c)
	{
		this.col=c;
	}



	/* Method related to rowSet variable */

	public int getNoRowSet()
	{
		return this.rowSet.size();
	}
	
  // PJM: changed to return Row type rather than Object, and to return null
  // if out of range
  public Row getRow(int pos) {
    if (pos<0 || pos>=rowSet.size())
      return null;

    return (Row)rowSet.get(pos);
  }

	public void addRow(Row r)
	{
		this.rowSet.add(r);
	}

	public void placeRow(int pos, Row r)
	{
		this.rowSet.add(pos, r);
	}

	public Object removeRow(int pos)
	{
		return this.rowSet.remove(pos);
	}
	
	public ArrayList getRowSet()
	{
		return this.rowSet;
	}

	public void setRowSet(ArrayList set)
	{
		 this.rowSet=set;
	}

}
