001: package org.apache.torque.engine.database.model;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: import org.xml.sax.Attributes;
023:
024: /**
025: * A Class for information regarding possible objects representing a table
026: *
027: * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
028: * @version $Id: Inheritance.java 473814 2006-11-11 22:30:30Z tv $
029: */
030: public class Inheritance {
031: private String key;
032: private String className;
033: private String ancestor;
034: private Column parent;
035:
036: /**
037: * Imports foreign key from an XML specification
038: *
039: * @param attrib the xml attributes
040: */
041: public void loadFromXML(Attributes attrib) {
042: setKey(attrib.getValue("key"));
043: setClassName(attrib.getValue("class"));
044: setAncestor(attrib.getValue("extends"));
045: }
046:
047: /**
048: * Get the value of key.
049: * @return value of key.
050: */
051: public String getKey() {
052: return key;
053: }
054:
055: /**
056: * Set the value of key.
057: * @param v Value to assign to key.
058: */
059: public void setKey(String v) {
060: this .key = v;
061: }
062:
063: /**
064: * Get the value of parent.
065: * @return value of parent.
066: */
067: public Column getColumn() {
068: return parent;
069: }
070:
071: /**
072: * Set the value of parent.
073: * @param v Value to assign to parent.
074: */
075: public void setColumn(Column v) {
076: this .parent = v;
077: }
078:
079: /**
080: * Get the value of className.
081: * @return value of className.
082: */
083: public String getClassName() {
084: return className;
085: }
086:
087: /**
088: * Set the value of className.
089: * @param v Value to assign to className.
090: */
091: public void setClassName(String v) {
092: this .className = v;
093: }
094:
095: /**
096: * Get the value of ancestor.
097: * @return value of ancestor.
098: */
099: public String getAncestor() {
100: return ancestor;
101: }
102:
103: /**
104: * Set the value of ancestor.
105: * @param v Value to assign to ancestor.
106: */
107: public void setAncestor(String v) {
108: this .ancestor = v;
109: }
110:
111: /**
112: * String representation of the foreign key. This is an xml representation.
113: *
114: * @return string representation in xml
115: */
116: public String toString() {
117: StringBuffer result = new StringBuffer();
118: result.append(" <inheritance key=\"").append(key).append(
119: "\" class=\"").append(className).append('\"');
120:
121: if (ancestor != null) {
122: result.append(" extends=\"").append(ancestor).append('\"');
123: }
124:
125: result.append("/>");
126:
127: return result.toString();
128: }
129: }
|