/*
* Copyright (c) 2004-2005, The Hong Kong University of Science and Technology (HKUST)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
*   * Redistributions of source code must retain the above copyright notice,
*     this list of conditions,the authors and the following disclaimer.
*   * Redistributions in binary form must reproduce the above copyright notice,
*     this list of conditions,the authors and the following disclaimer in
*     the documentation and/or other materials provided with the distribution.
*   * Neither the name of the university nor the names of its
*     contributors may be used to endorse or promote products derived from
*     this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
 * SDGEN: a data generator for Bisque
 * @Author: Bingsheng He (saven@cs.ust.hk)
 * @Date:28/3/3005
 * @Version: 1.0
 * @Function: this module implements the basic structure for a table.
 */
 import java.io.*;
 import java.util.*;
 class DTuple{
 	public Vector values;
 	DTuple()
 	{
 		values=new Vector();
 	}
 	public Object elementAt(int index)
 	{
 		return values.elementAt(index);
 	}
 	public void add(Object o)
 	{
 		values.add(o);
 	}
 	public void add(int index,Object o )
 	{
 		values.add(index,o);
 	}
 	public void print()
 	{
 		for(int i=0;i<values.size();i++)
 		System.out.print(values.elementAt(i)+" ");
 		System.out.println("");
 	}

 }
 public class DTable{
 	public Vector tuples;
 	DTable()
 	{
 		tuples=new Vector();
 	}
 	public DTuple tupleAt(int index)
 	{
 		return (DTuple)(tuples.elementAt(index));
 	}

 	public Object attributeAt(int rowIndex, int columnIndex)
 	{
 		DTuple tmp=tupleAt(rowIndex);
 		return tmp.elementAt(columnIndex);
 	}
 	public void add(DTuple d)
 	{
 		tuples.add(d);
 	}

 	public void add(int index,DTuple d)
 	{
 		tuples.add(index,d);
 	}

 	public void print()
 	{
 		for(int i=0;i<tuples.size();i++)
 		 ((DTuple)(tuples.elementAt(i))).print();
 	}
 	public void clear()
 	{
 		tuples.removeAllElements();
 	}
 	public Vector getCopy()
 	{
 		return (Vector)(this.tuples.clone());
 	}

 	public void addValue(int rowIndex, int columnIndex, Object value)
 	{
 		if(rowIndex>=tuples.size())
 		{
 			System.out.println("you should not be here");
 			System.out.println("contact your developer");
 			System.exit(0);
 		}
 		DTuple tmpT=(DTuple)(tuples.elementAt(rowIndex));
 		tmpT.values.add(columnIndex,value);
 	}
 }