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,v 1.1 2007-10-21 07:57:27 abyrne Exp $ 029 */ 030 public class Inheritance 031 { 032 private String key; 033 private String className; 034 private String ancestor; 035 private Column parent; 036 037 /** 038 * Imports foreign key from an XML specification 039 * 040 * @param attrib the xml attributes 041 */ 042 public void loadFromXML (Attributes attrib) 043 { 044 setKey(attrib.getValue("key")); 045 setClassName(attrib.getValue("class")); 046 setAncestor(attrib.getValue("extends")); 047 } 048 049 /** 050 * Get the value of key. 051 * @return value of key. 052 */ 053 public String getKey() 054 { 055 return key; 056 } 057 058 /** 059 * Set the value of key. 060 * @param v Value to assign to key. 061 */ 062 public void setKey(String v) 063 { 064 this.key = v; 065 } 066 067 068 /** 069 * Get the value of parent. 070 * @return value of parent. 071 */ 072 public Column getColumn() 073 { 074 return parent; 075 } 076 077 /** 078 * Set the value of parent. 079 * @param v Value to assign to parent. 080 */ 081 public void setColumn(Column v) 082 { 083 this.parent = v; 084 } 085 086 /** 087 * Get the value of className. 088 * @return value of className. 089 */ 090 public String getClassName() 091 { 092 return className; 093 } 094 095 /** 096 * Set the value of className. 097 * @param v Value to assign to className. 098 */ 099 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 }