| 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 | |
| 5 |   * or more contributor license agreements.  See the NOTICE file | |
| 6 |   * distributed with this work for additional information | |
| 7 |   * regarding copyright ownership.  The ASF licenses this file | |
| 8 |   * to you under the Apache License, Version 2.0 (the | |
| 9 |   * "License"); you may not use this file except in compliance | |
| 10 |   * with the License.  You may obtain a copy of the License at | |
| 11 |   * | |
| 12 |   *   http://www.apache.org/licenses/LICENSE-2.0 | |
| 13 |   * | |
| 14 |   * Unless required by applicable law or agreed to in writing, | |
| 15 |   * software distributed under the License is distributed on an | |
| 16 |   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| 17 |   * KIND, either express or implied.  See the License for the | |
| 18 |   * specific language governing permissions and limitations | |
| 19 |   * under the License. | |
| 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,v 1.1 2007-10-21 07:57:27 abyrne Exp $ | |
| 29 |   */ | |
| 30 | 0 |  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 | 0 |          setKey(attrib.getValue("key")); | 
| 45 | 0 |          setClassName(attrib.getValue("class")); | 
| 46 | 0 |          setAncestor(attrib.getValue("extends")); | 
| 47 | 0 |      } | 
| 48 | ||
| 49 |      /** | |
| 50 |       * Get the value of key. | |
| 51 |       * @return value of key. | |
| 52 |       */ | |
| 53 |      public String getKey() | |
| 54 |      { | |
| 55 | 0 |          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 | 0 |          this.key = v; | 
| 65 | 0 |      } | 
| 66 | ||
| 67 | ||
| 68 |      /** | |
| 69 |       * Get the value of parent. | |
| 70 |       * @return value of parent. | |
| 71 |       */ | |
| 72 |      public Column getColumn() | |
| 73 |      { | |
| 74 | 0 |          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 | 0 |          this.parent = v; | 
| 84 | 0 |      } | 
| 85 | ||
| 86 |      /** | |
| 87 |       * Get the value of className. | |
| 88 |       * @return value of className. | |
| 89 |       */ | |
| 90 |      public String getClassName() | |
| 91 |      { | |
| 92 | 0 |          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 | 0 |          this.className = v; | 
| 102 | 0 |      } | 
| 103 | ||
| 104 |      /** | |
| 105 |       * Get the value of ancestor. | |
| 106 |       * @return value of ancestor. | |
| 107 |       */ | |
| 108 |      public String getAncestor() | |
| 109 |      { | |
| 110 | 0 |          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 | 0 |          this.ancestor = v; | 
| 120 | 0 |      } | 
| 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 | 0 |          StringBuffer result = new StringBuffer(); | 
| 130 | 0 |          result.append(" <inheritance key=\"") | 
| 131 | .append(key) | |
| 132 |                .append("\" class=\"") | |
| 133 | .append(className) | |
| 134 |                .append('\"'); | |
| 135 | ||
| 136 | ||
| 137 | 0 |          if (ancestor != null) | 
| 138 |          { | |
| 139 | 0 |              result.append(" extends=\"") | 
| 140 | .append(ancestor) | |
| 141 |                    .append('\"'); | |
| 142 | } | |
| 143 | ||
| 144 | 0 |          result.append("/>"); | 
| 145 | ||
| 146 | 0 |          return result.toString(); | 
| 147 | } | |
| 148 | } |