View Javadoc

1   package org.apache.torque.engine.database.model;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.xml.sax.Attributes;
20  
21  /***
22   * A Class for information regarding possible objects representing a table
23   *
24   * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
25   * @version $Id: Inheritance.java 239624 2005-08-24 12:18:03Z henning $
26   */
27  public class Inheritance
28  {
29      private String key;
30      private String className;
31      private String ancestor;
32      private Column parent;
33  
34      /***
35       * Imports foreign key from an XML specification
36       *
37       * @param attrib the xml attributes
38       */
39      public void loadFromXML (Attributes attrib)
40      {
41          setKey(attrib.getValue("key"));
42          setClassName(attrib.getValue("class"));
43          setAncestor(attrib.getValue("extends"));
44      }
45  
46      /***
47       * Get the value of key.
48       * @return value of key.
49       */
50      public String getKey()
51      {
52          return key;
53      }
54  
55      /***
56       * Set the value of key.
57       * @param v  Value to assign to key.
58       */
59      public void setKey(String  v)
60      {
61          this.key = v;
62      }
63  
64  
65      /***
66       * Get the value of parent.
67       * @return value of parent.
68       */
69      public Column getColumn()
70      {
71          return parent;
72      }
73  
74      /***
75       * Set the value of parent.
76       * @param v  Value to assign to parent.
77       */
78      public void setColumn(Column  v)
79      {
80          this.parent = v;
81      }
82  
83      /***
84       * Get the value of className.
85       * @return value of className.
86       */
87      public String getClassName()
88      {
89          return className;
90      }
91  
92      /***
93       * Set the value of className.
94       * @param v  Value to assign to className.
95       */
96      public void setClassName(String  v)
97      {
98          this.className = v;
99      }
100 
101     /***
102      * Get the value of ancestor.
103      * @return value of ancestor.
104      */
105     public String getAncestor()
106     {
107         return ancestor;
108     }
109 
110     /***
111      * Set the value of ancestor.
112      * @param v  Value to assign to ancestor.
113      */
114     public void setAncestor(String  v)
115     {
116         this.ancestor = v;
117     }
118 
119     /***
120      * String representation of the foreign key. This is an xml representation.
121      *
122      * @return string representation in xml
123      */
124     public String toString()
125     {
126         StringBuffer result = new StringBuffer();
127         result.append(" <inheritance key=\"")
128               .append(key)
129               .append("\" class=\"")
130               .append(className)
131               .append('\"');
132 
133 
134         if (ancestor != null)
135         {
136             result.append(" extends=\"")
137                   .append(ancestor)
138                   .append('\"');
139         }
140 
141         result.append("/>");
142 
143         return result.toString();
144     }
145 }