001: package net.sourceforge.squirrel_sql.fw.sql;
002:
003: /*
004: * Copyright (C) 2003 Colin Bell
005: * colbell@users.sourceforge.net
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021: /**
022: * This represents the primary key definition for a table.
023: *
024: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
025: */
026: public class PrimaryKeyInfo extends DatabaseObjectInfo {
027: static final long serialVersionUID = 4785889679696720264L;
028:
029: /**
030: * the name of the column which belongs to a list of columns that form a
031: * unique key for a table
032: */
033: private String columnName = null;
034:
035: /** sequence number within primary key */
036: private short keySequence;
037:
038: /**
039: * The table that has this primary key constraint
040: */
041: private String tableName = null;
042:
043: /**
044: * @deprecated use the version of the constructor that accepts args to
045: * provide complete information about this key.
046: */
047: PrimaryKeyInfo() {
048: super (null, null, null, null, null);
049: }
050:
051: /**
052: * Create a new PrimaryKeyInfo object.
053: *
054: * @param catalog catalog name
055: * @param schema schema name
056: * @param aColumnName the name of the column that either by itself or along
057: * with others form(s) a unique index value for a single
058: * row in a table.
059: * @param aKeySequence sequence number within primary key
060: * @param aPrimaryKeyName the name of the primary key
061: * @param md
062: */
063: public PrimaryKeyInfo(String catalog, String schema,
064: String aTableName, String aColumnName, short aKeySequence,
065: String aPrimaryKeyName, ISQLDatabaseMetaData md) {
066: super (catalog, schema, aPrimaryKeyName,
067: DatabaseObjectType.PRIMARY_KEY, md);
068: columnName = aColumnName;
069: tableName = aTableName;
070: keySequence = aKeySequence;
071: }
072:
073: /**
074: * @param columnName The columnName to set.
075: */
076: public void setColumnName(String columnName) {
077: this .columnName = columnName;
078: }
079:
080: /**
081: * @return Returns the columnName.
082: */
083: public String getColumnName() {
084: return columnName;
085: }
086:
087: /**
088: * @param keySequence The keySequence to set.
089: */
090: public void setKeySequence(short keySequence) {
091: this .keySequence = keySequence;
092: }
093:
094: /**
095: * @return Returns the keySequence.
096: */
097: public short getKeySequence() {
098: return keySequence;
099: }
100:
101: /**
102: * @param tableName the tableName to set
103: */
104: public void setTableName(String tableName) {
105: this .tableName = tableName;
106: }
107:
108: /**
109: * @return the tableName
110: */
111: public String getTableName() {
112: return tableName;
113: }
114:
115: public String getQualifiedColumnName() {
116: if (tableName != null && !"".equals(tableName)) {
117: return tableName + "." + columnName;
118: }
119: return columnName;
120: }
121: }
|