001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.commons.dsi.ddl;
020:
021: import java.util.*;
022:
023: /**
024: * A definition of the a database table.
025: *
026: * @author Michael Bell
027: * @version $Revision: 1.1 $
028: *
029: */
030: public class TableDefinition {
031:
032: /**
033: * The list of columns this table contains.
034: */
035: private List m_cols = null;
036:
037: /**
038: * The name of this table.
039: */
040: private String m_sName = null;
041:
042: /**
043: * Creates a table definition.
044: *
045: * @param sName the name of the table
046: */
047: public TableDefinition(String sName) {
048: m_sName = sName;
049: m_cols = new ArrayList();
050: }
051:
052: /**
053: * Returns the table name.
054: *
055: * @return the table name
056: */
057: public String getName() {
058: return m_sName;
059: }
060:
061: /**
062: * Adds a column definition to this table.
063: *
064: * @param coldef a column definition to add
065: */
066: public void addColumn(ColumnDefinition coldef) {
067: m_cols.add(coldef);
068: }
069:
070: /**
071: * Adds a column definition to this table.
072: *
073: * @param sColName the column name
074: * @param nDataType the data type
075: */
076: public void addColumn(String sColName, int nDataType) {
077: m_cols.add(new ColumnDefinition(sColName, nDataType));
078: }
079:
080: /**
081: * Adds a column definition to this table.
082: *
083: * @param sColName the column name
084: * @param nDataType the data type
085: * @param bAllowNull <code>true</code> if the column can be NULL
086: */
087: public void addColumn(String sColName, int nDataType,
088: boolean bAllowNull) {
089: m_cols
090: .add(new ColumnDefinition(sColName, nDataType,
091: bAllowNull));
092: }
093:
094: /**
095: * Adds a column definition to this table.
096: *
097: * @param sColName the column name
098: * @param bIsPrimaryKey <code>true</code> if the column is a primary key
099: * @param nDataType the data type
100: */
101: public void addColumn(String sColName, boolean bIsPrimaryKey,
102: int nDataType) {
103: m_cols.add(new ColumnDefinition(sColName, bIsPrimaryKey,
104: nDataType));
105: }
106:
107: /**
108: * Adds a column definition to this table.
109: *
110: * @param sColName the column name
111: * @param nDataType the data type
112: * @param defaultVal the default value
113: */
114: public void addColumn(String sColName, int nDataType,
115: Object defaultVal) {
116: m_cols
117: .add(new ColumnDefinition(sColName, nDataType,
118: defaultVal));
119: }
120:
121: /**
122: * Adds a column definition to this table.
123: *
124: * @param sColName the column name
125: * @param bIsPrimaryKey <code>true</code> if the column is a primary key
126: * @param nDataType the data type
127: * @param defaultVal the default value
128: */
129: public void addColumn(String sColName, boolean bIsPrimaryKey,
130: int nDataType, Object defaultVal) {
131: m_cols.add(new ColumnDefinition(sColName, bIsPrimaryKey,
132: nDataType, defaultVal));
133: }
134:
135: /**
136: * Returns an iterator which will iterate through the <code>ColumnDefinition</code>s
137: * of this table.
138: *
139: * @return an iterator which will iterate through the <code>ColumnDefinition</code>s
140: * of this table
141: */
142: public Iterator iterator() {
143: return m_cols.iterator();
144: }
145:
146: }
|