KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > torque > engine > database > model > Inheritance


1 package org.apache.torque.engine.database.model;
2
3 /*
4  * Copyright 2001,2004 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 JavaDoc;
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,v 1.2 2004/02/22 06:27:19 jmcnally Exp $
26  */

27 public class Inheritance
28 {
29     private String JavaDoc key;
30     private String JavaDoc className;
31     private String JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc v)
97     {
98         this.className = v;
99     }
100
101     /**
102      * Get the value of ancestor.
103      * @return value of ancestor.
104      */

105     public String JavaDoc 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 JavaDoc 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 JavaDoc toString()
125     {
126         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
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 }
146
Popular Tags