01: package jimm.datavision.testdata.postgres;
02:
03: import jimm.datavision.testdata.SchemaGen;
04:
05: public class PostgreSQLSchemaGen extends SchemaGen {
06:
07: protected void makeTable(String tableName) {
08: String name = printableName(tableName);
09: System.out.println("drop table " + name + ";");
10: System.out.print("create table " + name + " (");
11: }
12:
13: protected void endTable() {
14: System.out.println();
15: System.out.println(");");
16: }
17:
18: protected void printType(String type, int size) {
19: System.out.print(" ");
20: if ("integer".equals(type))
21: System.out.print("int");
22: else if ("date".equals(type))
23: System.out.print("date");
24: else if ("boolean".equals(type))
25: System.out.print("bool");
26: else if ("string".equals(type))
27: System.out.print("varchar(" + size + ")");
28: }
29:
30: protected void printNotNull() {
31: System.out.print(" not null");
32: }
33:
34: protected void printPrimaryKey() {
35: System.out.print(" primary key");
36: }
37:
38: public static void main(String[] args) {
39: new PostgreSQLSchemaGen().run("../schema.xml");
40: }
41: }
|