/* Class to define and hold a single Row in a Table.
 * A Row consists of the objects associated with each column,
 * and the temporal (time) components, a start and end time.
 */

class  Row
{
	Object[] values;
	int st;
	int et;

	public Row(Object[] v, int s, int e)
	{
		this.values=v;
		this.st=s;
		this.et=e;
	}


	/* Method to return row values */
	
	public Object[] getRowValues()
	{
		return this.values;
	}



	/* Methods related to the time component */
	
	public int getRow_st()
	{
		return this.st;
	}

  // PJM added to make setting times easier
  public void setRow_st(int s) {
    st=s;
  }

  public void setRow_et(int e) {
    et=e;
  }

  public String toString() {
    StringBuffer sb=new StringBuffer();

    sb.append('<');

    for (int i=0;i<values.length;i++) {
      if (i>0) sb.append(',');
      sb.append(values[i]);
    }

    sb.append(',');
    sb.append(st);
    sb.append(',');
    sb.append(et);
    sb.append('>');

    return sb.toString();
  }

	public int getRow_et()
	{
		return this.et;
	}

	public void putRow_time(int s, int e)
	{
		this.st=s;
		this.et=e;
	}



	/* Returns the position of an object in the row */ 
	public int getValPos(Object value)
	{
		int pos=99;
		Object[] rowValues = getRowValues();

		for (int i=0; i<rowValues.length; i++)
		{
			if(value.equals(rowValues[i]))
			{
				pos=i;
			}
		}

		return pos;
	}


	/* Returns the a row value given the position of it */ 
	public Object getRowVal(int pos)
	{
		Object val = new Object();
		Object[] rowValues = getRowValues();

		for (int i=0; i<rowValues.length; i++)
		{
			if(i==pos)
			{
				val=rowValues[i];
			}
		}

		return val;
	}
	
}
