KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class Index {
8     Table table;
9     String JavaDoc name;
10     Column[] columns;
11     boolean unique;
12     
13     Index(Table table, String JavaDoc name, Column[] columns, boolean unique) {
14         this.table = table;
15         this.name = name;
16         this.columns = columns;
17         this.unique = unique;
18     }
19     
20     public String JavaDoc getName() {
21         return name;
22     }
23     
24     public String JavaDoc getCreateSQL() {
25         String JavaDoc sql = "CREATE ";
26         if(unique) {
27             sql += "UNIQUE ";
28         }
29         sql += "INDEX " + name + " ON " + table.getName() + "(";
30         for(int i=0; i<columns.length; i++) {
31             if(i>0) {
32                 sql += ", ";
33             }
34             sql += columns[i].getName();
35         }
36         sql += ")";
37         return sql;
38     }
39     
40     public String JavaDoc getDropSQL() {
41         return "DROP INDEX " + name;
42     }
43
44     public Table getTable() {
45         return table;
46     }
47
48 }
49
Popular Tags