Source code: org/objectstyle/ashwood/dbutil/ForeignKey.java
1 /* ====================================================================
2 *
3 * Copyright(c) 2003, Andriy Shapochka
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials
17 * provided with the distribution.
18 *
19 * 3. Neither the name of the ASHWOOD nor the
20 * names of its contributors may be used to endorse or
21 * promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 * ====================================================================
36 *
37 * This software consists of voluntary contributions made by
38 * individuals on behalf of the ASHWOOD Project and was originally
39 * created by Andriy Shapochka.
40 *
41 */
42
43 package org.objectstyle.ashwood.dbutil;
44
45 import java.io.Serializable;
46
47 public class ForeignKey implements Serializable {
48
49 private String pkTableCatalog;
50 private String pkTableSchema;
51 private String pkTableName;
52 private String pkColumnName;
53 private Table owner;
54 private String columnName;
55 private short updateRule;
56 private short deleteRule;
57 private String name;
58 private String pkName;
59 private short deferrability;
60 private short keySequence;
61 public ForeignKey() {
62 }
63 public ForeignKey(Column fkColumn) {
64 columnName = fkColumn.getName();
65 owner = fkColumn.getOwner();
66 keySequence = (short)(owner.getForeignKeys().size() + 1);
67 name = owner.getName() + "_FK" + keySequence;
68 }
69 public String getPkTableCatalog() {
70 return pkTableCatalog;
71 }
72 public void setPkTableCatalog(String pkTableCatalog) {
73 this.pkTableCatalog = pkTableCatalog;
74 }
75 public void setPkTableSchema(String pkTableSchema) {
76 this.pkTableSchema = pkTableSchema;
77 }
78 public String getPkTableSchema() {
79 return pkTableSchema;
80 }
81 public void setPkTableName(String pkTableName) {
82 this.pkTableName = pkTableName;
83 }
84 public String getPkTableName() {
85 return pkTableName;
86 }
87 public void setPkColumnName(String pkColumnName) {
88 this.pkColumnName = pkColumnName;
89 }
90 public String getPkColumnName() {
91 return pkColumnName;
92 }
93 public void setOwner(Table owner) {
94 this.owner = owner;
95 }
96 public Table getOwner() {
97 return owner;
98 }
99 public void setColumnName(String columnName) {
100 this.columnName = columnName;
101 }
102 public String getColumnName() {
103 return columnName;
104 }
105 public void setKeySequence(short keySequence) {
106 this.keySequence = keySequence;
107 }
108 public short getKeySequence() {
109 return keySequence;
110 }
111 public void setUpdateRule(short updateRule) {
112 this.updateRule = updateRule;
113 }
114 public short getUpdateRule() {
115 return updateRule;
116 }
117 public void setDeleteRule(short deleteRule) {
118 this.deleteRule = deleteRule;
119 }
120 public short getDeleteRule() {
121 return deleteRule;
122 }
123 public void setName(String name) {
124 this.name = name;
125 }
126 public String getName() {
127 return name;
128 }
129 public void setPkName(String pkName) {
130 this.pkName = pkName;
131 }
132 public String getPkName() {
133 return pkName;
134 }
135 public void setDeferrability(short deferrability) {
136 this.deferrability = deferrability;
137 }
138 public short getDeferrability() {
139 return deferrability;
140 }
141 }