01: /*
02: * Copyright 2006 Le Duc Bao, Ralf Joachim
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package org.castor.ddlgen.schemaobject;
17:
18: import org.castor.ddlgen.DDLGenConfiguration;
19: import org.castor.ddlgen.DDLWriter;
20: import org.castor.ddlgen.GeneratorException;
21:
22: /**
23: * Table contains fields, foreignkeys, indexes and table's options.
24: *
25: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
26: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
27: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
28: * @since 1.1
29: */
30: public final class DefaultTable extends Table {
31: //--------------------------------------------------------------------------
32:
33: /**
34: * {@inheritDoc}
35: */
36: public void toCreateDDL(final DDLWriter writer)
37: throws GeneratorException {
38: String delimiter = DDLGenConfiguration.DEFAULT_STATEMENT_DELIMITER;
39:
40: writer.println();
41: writer.println();
42: writer
43: .println("CREATE TABLE {0} (",
44: new Object[] { getName() });
45: fields(writer);
46: writer.println();
47: writer.print(")");
48: writer.print(delimiter);
49: }
50:
51: /**
52: * {@inheritDoc}
53: */
54: public void toDropDDL(final DDLWriter writer) {
55: String delimiter = DDLGenConfiguration.DEFAULT_STATEMENT_DELIMITER;
56:
57: writer.println();
58: writer.println();
59: writer.print("DROP TABLE {0}{1}", new Object[] { getName(),
60: delimiter });
61: }
62:
63: //--------------------------------------------------------------------------
64: }
|