KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > sqls > ForeignKey


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15
16  */

17 package org.apache.ws.jaxme.sqls;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.Iterator JavaDoc;
21
22
23 /** <p>Interface of a foreign key.</p>
24  *
25  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
26  */

27 public interface ForeignKey extends ColumnSet {
28    public class Mode implements Serializable JavaDoc {
29       private String JavaDoc name;
30       private Mode(String JavaDoc pName) {
31          name = pName;
32       }
33       public String JavaDoc getName() { return name; }
34       public String JavaDoc toString() { return name; }
35       public static final Mode CASCADE = new Mode("CASCADE");
36       public static final Mode REJECT = new Mode("REJECT");
37       public static final Mode SETNULL = new Mode("SETNULL");
38       private static final Mode[] instances = new Mode[]{
39          CASCADE, REJECT, SETNULL
40       };
41       public static Mode[] getInstances() {
42          return instances;
43       }
44       public static Mode valueOf(String JavaDoc pMode) {
45          for (int i = 0; i < instances.length; i++) {
46             if (instances[i].getName().equals(pMode)) {
47                return instances[i];
48             }
49          }
50          throw new IllegalArgumentException JavaDoc("Unknown mode: " + pMode);
51       }
52       public int hashCode() {
53          return name.hashCode();
54       }
55       public boolean equals(Object JavaDoc o) {
56          return o != null && (o instanceof Mode) && name.equals(((Mode) o).name);
57       }
58    }
59
60    public interface ColumnLink {
61       /** <p>Returns the column referencing a column in the referenced
62        * table.</p>
63        */

64       public Column getLocalColumn();
65       /** <p>Returns the column being referenced in the referenced
66        * table.</p>
67        */

68       public Column getReferencedColumn();
69    }
70
71    /** <p>Returns the referenced table.</p>
72     */

73    public Table getReferencedTable();
74
75    /** <p>Sets the OnDelete mode.</p>
76     */

77    public void setOnDelete(Mode pMode);
78
79    /** <p>Returns the OnDelete mode.</p>
80     */

81    public Mode getOnDelete();
82
83    /** <p>Sets the OnUpdate mode.</p>
84     */

85    public void setOnUpdate(Mode pMode);
86
87    /** <p>Returns the OnUpdate mode.</p>
88     */

89    public Mode getOnUpdate();
90
91    /** <p>Adds a reference between the given columns.</p>
92     * @param pColumn A column of the table, on which the foreign key is
93     * defined
94     * @param pReferencedColumn A column of the referenced table
95     */

96    public void addColumnLink(Column pColumn, Column pReferencedColumn);
97
98    /** <p>Adds a reference between the given columns.</p>
99     * @param pName Column name of the table, on which the foreign
100     * key is defined
101     * @param pReferencedName Column name of the referenced table.
102     */

103    public void addColumnLink(Column.Name pName, Column.Name pReferencedName);
104
105    /** <p>Adds a reference between the given columns.</p>
106     * @param pName Column name of the table, on which the foreign
107     * key is defined
108     * @param pReferencedName Column name of the referenced table.
109     */

110    public void addColumnLink(String JavaDoc pName, String JavaDoc pReferencedName);
111
112    /** <p>Returns all column references in the foreign key. Any instance
113     * returned by the {@link Iterator} is an instance of
114     * {@link ForeignKey.ColumnLink}.</p>
115     */

116    public Iterator JavaDoc getColumnLinks();
117
118    /** <p>Returns the set of referenced columns.</p>
119     */

120    public ColumnSet getReferencedColumns();
121 }
122
Popular Tags