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