KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > commons > dsi > ddl > TableDefinition


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.commons.dsi.ddl;
20
21 import java.util.*;
22
23 /**
24  * A definition of the a database table.
25  *
26  * @author Michael Bell
27  * @version $Revision: 1.1 $
28  *
29  */

30 public class TableDefinition {
31
32     /**
33      * The list of columns this table contains.
34      */

35     private List m_cols = null;
36     
37     /**
38      * The name of this table.
39      */

40     private String JavaDoc m_sName = null;
41     
42     /**
43      * Creates a table definition.
44      *
45      * @param sName the name of the table
46      */

47     public TableDefinition(String JavaDoc sName) {
48         m_sName = sName;
49         m_cols = new ArrayList();
50     }
51     
52     /**
53      * Returns the table name.
54      *
55      * @return the table name
56      */

57     public String JavaDoc getName() {
58         return m_sName;
59     }
60     
61     /**
62      * Adds a column definition to this table.
63      *
64      * @param coldef a column definition to add
65      */

66     public void addColumn(ColumnDefinition coldef) {
67         m_cols.add(coldef);
68     }
69     
70     /**
71      * Adds a column definition to this table.
72      *
73      * @param sColName the column name
74      * @param nDataType the data type
75      */

76     public void addColumn(String JavaDoc sColName,int nDataType) {
77         m_cols.add(new ColumnDefinition(sColName,nDataType));
78     }
79     
80     /**
81      * Adds a column definition to this table.
82      *
83      * @param sColName the column name
84      * @param nDataType the data type
85      * @param bAllowNull <code>true</code> if the column can be NULL
86      */

87     public void addColumn(String JavaDoc sColName,int nDataType,boolean bAllowNull) {
88         m_cols.add(new ColumnDefinition(sColName,nDataType,bAllowNull));
89     }
90     
91     /**
92      * Adds a column definition to this table.
93      *
94      * @param sColName the column name
95      * @param bIsPrimaryKey <code>true</code> if the column is a primary key
96      * @param nDataType the data type
97      */

98     public void addColumn(String JavaDoc sColName,boolean bIsPrimaryKey,int nDataType) {
99         m_cols.add(new ColumnDefinition(sColName,bIsPrimaryKey,nDataType));
100     }
101     
102     /**
103      * Adds a column definition to this table.
104      *
105      * @param sColName the column name
106      * @param nDataType the data type
107      * @param defaultVal the default value
108      */

109     public void addColumn(String JavaDoc sColName,int nDataType,Object JavaDoc defaultVal) {
110         m_cols.add(new ColumnDefinition(sColName,nDataType,defaultVal));
111     }
112     
113     /**
114      * Adds a column definition to this table.
115      *
116      * @param sColName the column name
117      * @param bIsPrimaryKey <code>true</code> if the column is a primary key
118      * @param nDataType the data type
119      * @param defaultVal the default value
120      */

121     public void addColumn(String JavaDoc sColName,boolean bIsPrimaryKey,int nDataType,Object JavaDoc defaultVal) {
122         m_cols.add(new ColumnDefinition(sColName,bIsPrimaryKey,nDataType,defaultVal));
123     }
124     
125     /**
126      * Returns an iterator which will iterate through the <code>ColumnDefinition</code>s
127      * of this table.
128      *
129      * @return an iterator which will iterate through the <code>ColumnDefinition</code>s
130      * of this table
131      */

132     public Iterator iterator() {
133         return m_cols.iterator();
134     }
135
136 }
137
Popular Tags