1 /*
2 * PROJECT : DAR Runtime and Tools
3 * COPYRIGHT : Copyright (C) 1999-2004 tim.stephenson@enableit.org
4 * LICENSE : GNU LESSER GENERAL PUBLIC LICENSE
5 * Version 2.1, February 1999
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 package org.enableit.db.darrt;
22
23 import org.enableit.db.beans.Index;
24
25 /***
26 * @author TimSt
27 *
28 * To change the template for this generated type comment go to
29 * Window>Preferences>Java>Code Generation>Code and Comments
30 */
31 public abstract class AbstractDDLGenerator {
32
33 /***
34 * Short cut to the platform-specific line separator.
35 */
36 protected static String EOL = System.getProperty("line.separator");
37
38 /***
39 * Creates DDL for an index.
40 * @param index to create.
41 */
42 public String getCreateIndex(Index index) {
43 StringBuffer ddl = new StringBuffer();
44
45 ddl.append("CREATE ");
46
47 if (index.getUnique().equalsIgnoreCase("TRUE")) {
48 ddl.append("UNIQUE ");
49 }
50
51 ddl.append("INDEX " + index.getName());
52
53 String tableName = index.getTableName();
54
55 ddl.append(" ON ");
56 ddl.append(tableName);
57 ddl.append(" (");
58
59 for (int i = 0; i < index.getColNameCount(); i++) {
60 ddl.append(index.getColName(i));
61
62 if ((i + 1) < index.getColNameCount()) {
63 ddl.append(",");
64 } else {
65 ddl.append(")");
66 }
67 }
68
69 return ddl.toString();
70 }
71
72 }
This page was automatically generated by Maven