001: package net.sourceforge.squirrel_sql.fw.sql;
002:
003: /*
004: * Copyright (C) 2002-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 class represents a foreign key relationship.
023: *
024: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
025: */
026: public class ForeignKeyInfo extends DatabaseObjectInfo {
027: static final long serialVersionUID = -4223544514849570902L;
028:
029: /**
030: * JavaBean property names for this class.
031: */
032: public interface IPropertyNames {
033: /** Primary Key Catalog name. */
034: String PK_CATALOG_NAME = "primaryKeyCatalogName";
035:
036: /** Primary Key Schema name. */
037: String PK_SCHEMA_NAME = "primaryKeySchemaName";
038: }
039:
040: private final String _pkCatalog;
041: private final String _pkSchema;
042: private final String _pkTableName;
043: private final String _pkColumnName;
044: private final String _fkTableName;
045: private final String _fkColumnName;
046: private final int _updateRule;
047: private final int _deleteRule;
048: private final String _pkName;
049: private final int _deferability;
050: private ForeignKeyColumnInfo[] _columnInfo;
051:
052: /**
053: * @deprecated use the version of the constructor accepts fk and pk column
054: * names.
055: */
056: ForeignKeyInfo(String pkCatalog, String pkSchema,
057: String pkTableName, String fkCatalog, String fkSchema,
058: String fkTableName, int updateRule, int deleteRule,
059: String fkName, String pkName, int deferability,
060: ForeignKeyColumnInfo[] columnInfo, SQLDatabaseMetaData md) {
061: super (fkCatalog, fkSchema, fkName,
062: DatabaseObjectType.FOREIGN_KEY, md);
063: _pkCatalog = pkCatalog;
064: _pkSchema = pkSchema;
065: _pkTableName = pkTableName;
066: _fkTableName = fkTableName;
067: _updateRule = updateRule;
068: _deleteRule = deleteRule;
069: _pkName = pkName;
070: _deferability = deferability;
071: setForeignKeyColumnInfo(columnInfo);
072: _pkColumnName = null;
073: _fkColumnName = null;
074: }
075:
076: ForeignKeyInfo(String pkCatalog, String pkSchema,
077: String pkTableName, String pkColumnName, String fkCatalog,
078: String fkSchema, String fkTableName, String fkColumnName,
079: int updateRule, int deleteRule, String fkName,
080: String pkName, int deferability,
081: ForeignKeyColumnInfo[] columnInfo, SQLDatabaseMetaData md) {
082: super (fkCatalog, fkSchema, fkName,
083: DatabaseObjectType.FOREIGN_KEY, md);
084: _pkCatalog = pkCatalog;
085: _pkSchema = pkSchema;
086: _pkTableName = pkTableName;
087: _pkColumnName = pkColumnName;
088: _fkTableName = fkTableName;
089: _fkColumnName = fkColumnName;
090: _updateRule = updateRule;
091: _deleteRule = deleteRule;
092: _pkName = pkName;
093: _deferability = deferability;
094: setForeignKeyColumnInfo(columnInfo);
095: }
096:
097: public String getPrimaryKeyCatalogName() {
098: return _pkCatalog;
099: }
100:
101: public String getPrimaryKeySchemaName() {
102: return _pkSchema;
103: }
104:
105: public String getPrimaryKeyTableName() {
106: return _pkTableName;
107: }
108:
109: public String getPrimaryKeyColumnName() {
110: return _pkColumnName;
111: }
112:
113: public String getPrimaryKeyName() {
114: return _pkName;
115: }
116:
117: public String getForeignKeyCatalogName() {
118: return getCatalogName();
119: }
120:
121: public String getForeignKeySchemaName() {
122: return getCatalogName();
123: }
124:
125: public String getForeignKeyTableName() {
126: return _fkTableName;
127: }
128:
129: public String getForeignKeyColumnName() {
130: return _fkColumnName;
131: }
132:
133: public String getForeignKeyName() {
134: return getSimpleName();
135: }
136:
137: public int getUpdateRule() {
138: return _updateRule;
139: }
140:
141: public int getDeleteRule() {
142: return _deleteRule;
143: }
144:
145: public int getDeferability() {
146: return _deferability;
147: }
148:
149: public ForeignKeyColumnInfo[] getForeignKeyColumnInfo() {
150: return _columnInfo;
151: }
152:
153: public void setForeignKeyColumnInfo(ForeignKeyColumnInfo[] value) {
154: _columnInfo = value != null ? value
155: : new ForeignKeyColumnInfo[0];
156: }
157: }
|