001: package com.salmonllc.sql;
002:
003: import java.io.Serializable;
004:
005: /////////////////////////
006: //$Archive: /SOFIA/SourceCode/com/salmonllc/sql/ColumnDefinition.java $
007: //$Author: Dan $
008: //$Revision: 16 $
009: //$Modtime: 11/19/03 3:11p $
010: /////////////////////////
011:
012: /**
013: * Represents on database column returned by the DataDictionary class
014: */
015: public class ColumnDefinition implements Serializable {
016: private String _tableName;
017: private String _columnName;
018: private String _dbDataType;
019: private int _dsDataType;
020: private int _precision;
021: private int _scale;
022: private int _length;
023: private boolean _nullable;
024: private boolean _isPkey;
025:
026: /**
027: * Creates a new column definition object.
028: */
029: public ColumnDefinition(String dbms, String tableName,
030: String columnName, String dbDataType, int length,
031: boolean nullable) {
032: _tableName = tableName;
033: _columnName = columnName;
034: _dbDataType = dbDataType;
035: _dsDataType = DataType.toDSDataType(dbms, dbDataType);
036: _length = length;
037: _nullable = nullable;
038: }
039:
040: /**
041: * Creates a new column definition object.
042: */
043: public ColumnDefinition(String dbms, String tableName,
044: String columnName, String dbDataType, int length,
045: boolean nullable, int precision, int scale) {
046: _tableName = tableName;
047: _columnName = columnName;
048: _dbDataType = dbDataType;
049: _dsDataType = DataType.toDSDataType(dbms, dbDataType,
050: precision, scale);
051: _length = length;
052: _nullable = nullable;
053: _precision = precision;
054: _scale = scale;
055: }
056:
057: /**
058: * Creates a new column definition object.
059: */
060: public ColumnDefinition(String tableName, String columnName,
061: String dbDataType, int length, boolean nullable) {
062: _tableName = tableName;
063: _columnName = columnName;
064: _dbDataType = dbDataType;
065: _dsDataType = DataType.toDSDataType(dbDataType);
066: _length = length;
067: _nullable = nullable;
068: }
069:
070: /**
071: * Creates a new column definition object.
072: */
073: public ColumnDefinition(String tableName, String columnName,
074: String dbDataType, int length, boolean nullable,
075: int precision, int scale) {
076: _tableName = tableName;
077: _columnName = columnName;
078: _dbDataType = dbDataType;
079: _dsDataType = DataType.toDSDataType(dbDataType, precision,
080: scale);
081: _length = length;
082: _nullable = nullable;
083: _precision = precision;
084: _scale = scale;
085: }
086:
087: /**
088: * Creates a new column definition object.
089: */
090: public ColumnDefinition(String tableName, String columnName,
091: int dsDataType, boolean pkey) {
092: _tableName = tableName;
093: _columnName = columnName;
094: _dsDataType = dsDataType;
095: _isPkey = pkey;
096: }
097:
098: /**
099: * Returns the name of the colum.
100: */
101: public java.lang.String getColumnName() {
102: return _columnName;
103: }
104:
105: /**
106: * Returns the database datatype of the colum.
107: */
108: public java.lang.String getDBDataType() {
109: return _dbDataType;
110: }
111:
112: /**
113: * Returns the datastore datatype of the colum.
114: */
115: public int getDSDataType() {
116: return _dsDataType;
117: }
118:
119: /**
120: * Returns the length of the column
121: */
122: public int getLength() {
123: return _length;
124: }
125:
126: /**
127: * Returns the precision of the column.
128: */
129: public int getPrecision() {
130: return _precision;
131: }
132:
133: /**
134: * Returns the scale (number of decimal places) of the column.
135: */
136: public int getScale() {
137: return _scale;
138: }
139:
140: /**
141: * Returns the tablename of the column.
142: */
143: public java.lang.String getTableName() {
144: return _tableName;
145: }
146:
147: /**
148: * Returns true if the column can be set to null.
149: */
150: public boolean isNullable() {
151: return _nullable;
152: }
153:
154: /**
155: * Returns true if the column is part of the table's primary key.
156: */
157: public boolean isPkey() {
158: return _isPkey;
159: }
160:
161: public void setPkey() {
162: _isPkey = true;
163: }
164:
165: public String toString() {
166: return _columnName;
167: }
168:
169: void setTableName(String string) {
170: _tableName = string;
171: }
172:
173: }
|