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