View Javadoc

1   /*
2    * 
3    * 
4    */
5   package oscon2006.mock;
6   
7   import java.math.BigDecimal;
8   import java.util.Calendar;
9   import javax.swing.table.DefaultTableModel;
10  
11  /**
12   * 
13   * 
14   * mock table model
15   * 
16   *
17   */
18  public class MockTableModel extends DefaultTableModel
19  {
20  	public MockTableModel(int rows)
21  	{
22  	      String[] stringData = new String[rows];
23  	      StringBuffer[] stringBufferData = new StringBuffer[rows];
24  	      
25  	      BigDecimal[] bdData = new BigDecimal[rows];
26  	      Long[] longData = new Long[rows];
27  	      Integer[] intData = new Integer[rows];
28  	      Double[] doubleData = new Double[rows];
29  	      
30  	      Character[] charData = new Character[rows];
31  	      
32  	      Boolean[] booleanData = new Boolean[rows];
33  	      
34  	      java.util.Date[] dateData = new java.util.Date[rows];
35  	      
36  	      Calendar[] calendarData = new Calendar[rows];
37  	      
38  	      java.util.Date currentDate = new java.util.Date();
39  	      Calendar cal = Calendar.getInstance();
40  	      cal.setTime(currentDate);
41  	      
42  	      for (int i = 0; i < rows; i++)
43  	      {
44  	    	  stringData[i] = "string-" + i;
45  	    	  stringBufferData[i] = new StringBuffer("stringbuffer-" + i);
46  	    	  bdData[i] = new BigDecimal(i + 0.5);
47  	    	  longData[i] = new Long(i);
48  	    	  dateData[i] = currentDate;
49  	    	  calendarData[i] = cal;
50  	    	  intData[i] = i;
51  	    	  doubleData[i] = i + 0.25;
52  	    	  charData[i] = new Character('a');
53  	    	  
54  	    	  if (i % 2 == 0)
55  	    	  {
56  	    		  booleanData[i] = true;
57  	    	  }
58  	    	  else
59  	    	  {
60  	    		  booleanData[i] = false;
61  	    	  }
62  	      }
63  	      
64  	      this.addColumn("StringColumn", stringData);
65  	      this.addColumn("StringBufferColumn", stringBufferData);
66  	      this.addColumn("BigDecimalColumn", bdData);
67  	      this.addColumn("LongData", longData);
68  	      this.addColumn("DateData", dateData);
69  	      this.addColumn("CalendarData", calendarData);
70  	      this.addColumn("IntegerData", intData);
71  	      this.addColumn("DoubleData", doubleData);
72  	      this.addColumn("CharacterData", charData);
73  	      this.addColumn("BooleanData", booleanData);
74  		
75  	}
76  }