View Javadoc

1   /*
2    * joey-gen and its relative products are published under the terms
3    * of the Apache Software License.
4    * 
5    * Created on 2004/08/10 17:15:47
6    */
7   package org.asyrinx.joey.gen.model.rdb;
8   
9   import org.asyrinx.joey.gen.model.Element;
10  
11  /***
12   * @author akima
13   */
14  public class ForeignKeyEntry extends Element {
15  
16      /***
17       *  
18       */
19      public ForeignKeyEntry() {
20          super();
21      }
22  
23      /***
24       *  
25       */
26      public ForeignKeyEntry(String local, String foreign) {
27          this(null, local, foreign);
28      }
29  
30      /***
31       *  
32       */
33      public ForeignKeyEntry(ForeignKey parent, String local, String foreign) {
34          super(parent);
35          this.local = local;
36          this.foreign = foreign;
37      }
38  
39      /*
40       * (non-Javadoc)
41       * 
42       * @see org.asyrinx.joey.gen.model.Element#getParentElement()
43       */
44      public ForeignKey getParent() {
45          return (ForeignKey) super.getParentElement();
46      }
47  
48      private String local = null;
49  
50      private String foreign = null;
51  
52      /***
53       * @return Returns the foreign.
54       */
55      public String getForeign() {
56          return foreign;
57      }
58  
59      /***
60       * @param foreign
61       *            The foreign to set.
62       */
63      public void setForeign(String foreign) {
64          this.foreign = foreign;
65      }
66  
67      /***
68       * @return Returns the local.
69       */
70      public String getLocal() {
71          return local;
72      }
73  
74      /***
75       * @param local
76       *            The local to set.
77       */
78      public void setLocal(String local) {
79          this.local = local;
80      }
81  
82      public Column getLocalColumn() {
83          if (getParent() == null)
84              return null;
85          final Table table = getParent().getLocal();
86          return table.getColumns().getColumn(getLocal());
87      }
88  
89      public Column getForeignColumn() {
90          if (getParent() == null)
91              return null;
92          final Table table = getParent().getForeignTable();
93          return table.getColumns().getColumn(getForeign());
94      }
95  }