KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > test > synth > DbState


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.test.synth;
6
7 import java.sql.SQLException JavaDoc;
8 import java.util.ArrayList JavaDoc;
9
10 public class DbState implements DbInterface {
11     
12     private TestSynth config;
13     private ArrayList JavaDoc tables = new ArrayList JavaDoc();
14     private ArrayList JavaDoc indexes = new ArrayList JavaDoc();
15     boolean connected;
16     boolean autoCommit;
17     
18     DbState(TestSynth config) {
19         this.config = config;
20     }
21     
22     public void reset() throws SQLException JavaDoc {
23         tables = new ArrayList JavaDoc();
24         indexes = new ArrayList JavaDoc();
25     }
26     
27     public void connect() throws SQLException JavaDoc {
28         connected = true;
29     }
30     
31     public void disconnect() throws SQLException JavaDoc {
32         connected = false;
33     }
34     
35     public void createTable(Table table) throws SQLException JavaDoc {
36         tables.add(table);
37     }
38     
39     public void dropTable(Table table) throws SQLException JavaDoc {
40         tables.remove(table);
41     }
42     
43     public void createIndex(Index index) throws SQLException JavaDoc {
44         indexes.add(index);
45     }
46     
47     public void dropIndex(Index index) throws SQLException JavaDoc {
48         indexes.remove(index);
49     }
50
51     public Result insert(Table table, Column[] c, Value[] v) throws SQLException JavaDoc {
52         return null;
53     }
54
55     public Result select(String JavaDoc sql) throws SQLException JavaDoc {
56         return null;
57     }
58
59     public Result delete(Table table, String JavaDoc condition) throws SQLException JavaDoc {
60         return null;
61     }
62
63     public Result update(Table table, Column[] columns, Value[] values, String JavaDoc condition) {
64         return null;
65     }
66
67     public void setAutoCommit(boolean b) throws SQLException JavaDoc {
68         autoCommit = b;
69     }
70
71     public void commit() throws SQLException JavaDoc {
72     }
73
74     public void rollback() throws SQLException JavaDoc {
75     }
76
77     public Table randomTable() {
78         if(tables.size() == 0) {
79             return null;
80         }
81         int i = config.random().getInt(tables.size());
82         return (Table) tables.get(i);
83     }
84
85     public void end() throws SQLException JavaDoc {
86     }
87     
88 }
89
Popular Tags