1 package org.apache.torque.engine.database.model;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.xml.sax.Attributes;
23
24 /***
25 * A Class for information regarding possible objects representing a table
26 *
27 * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
28 * @version $Id: Inheritance.java 473814 2006-11-11 22:30:30Z tv $
29 */
30 public class Inheritance
31 {
32 private String key;
33 private String className;
34 private String ancestor;
35 private Column parent;
36
37 /***
38 * Imports foreign key from an XML specification
39 *
40 * @param attrib the xml attributes
41 */
42 public void loadFromXML (Attributes attrib)
43 {
44 setKey(attrib.getValue("key"));
45 setClassName(attrib.getValue("class"));
46 setAncestor(attrib.getValue("extends"));
47 }
48
49 /***
50 * Get the value of key.
51 * @return value of key.
52 */
53 public String getKey()
54 {
55 return key;
56 }
57
58 /***
59 * Set the value of key.
60 * @param v Value to assign to key.
61 */
62 public void setKey(String v)
63 {
64 this.key = v;
65 }
66
67
68 /***
69 * Get the value of parent.
70 * @return value of parent.
71 */
72 public Column getColumn()
73 {
74 return parent;
75 }
76
77 /***
78 * Set the value of parent.
79 * @param v Value to assign to parent.
80 */
81 public void setColumn(Column v)
82 {
83 this.parent = v;
84 }
85
86 /***
87 * Get the value of className.
88 * @return value of className.
89 */
90 public String getClassName()
91 {
92 return className;
93 }
94
95 /***
96 * Set the value of className.
97 * @param v Value to assign to className.
98 */
99 public void setClassName(String v)
100 {
101 this.className = v;
102 }
103
104 /***
105 * Get the value of ancestor.
106 * @return value of ancestor.
107 */
108 public String getAncestor()
109 {
110 return ancestor;
111 }
112
113 /***
114 * Set the value of ancestor.
115 * @param v Value to assign to ancestor.
116 */
117 public void setAncestor(String v)
118 {
119 this.ancestor = v;
120 }
121
122 /***
123 * String representation of the foreign key. This is an xml representation.
124 *
125 * @return string representation in xml
126 */
127 public String toString()
128 {
129 StringBuffer result = new StringBuffer();
130 result.append(" <inheritance key=\"")
131 .append(key)
132 .append("\" class=\"")
133 .append(className)
134 .append('\"');
135
136
137 if (ancestor != null)
138 {
139 result.append(" extends=\"")
140 .append(ancestor)
141 .append('\"');
142 }
143
144 result.append("/>");
145
146 return result.toString();
147 }
148 }