Coverage report

  %line %branch
org.apache.torque.map.ColumnMap
49% 
94% 

 1  
 package org.apache.torque.map;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 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  
 /**
 20  
  * ColumnMap is used to model a column of a table in a database.
 21  
  *
 22  
  * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
 23  
  * @version $Id: ColumnMap.java 239630 2005-08-24 12:25:32Z henning $
 24  
  */
 25  
 public class ColumnMap implements java.io.Serializable
 26  
 {
 27  
     /** Type of the column. */
 28  8
     private Object type = null;
 29  
 
 30  
     /** Size of the column. */
 31  8
     private int size = 0;
 32  
 
 33  
     /** Is it a primary key? */
 34  8
     private boolean pk = false;
 35  
 
 36  
     /** Is null value allowed ?*/
 37  8
     private boolean notNull = false;
 38  
 
 39  
     /** Name of the table that this column is related to. */
 40  8
     private String relatedTableName = "";
 41  
 
 42  
     /** Name of the column that this column is related to. */
 43  8
     private String relatedColumnName = "";
 44  
 
 45  
     /** The TableMap for this column. */
 46  
     private TableMap table;
 47  
 
 48  
     /** The name of the column. */
 49  
     private String columnName;
 50  
 
 51  
 
 52  
     /**
 53  
      * Constructor.
 54  
      *
 55  
      * @param name The name of the column.
 56  
      * @param containingTable TableMap of the table this column is in.
 57  
      */
 58  
     public ColumnMap(String name, TableMap containingTable)
 59  8
     {
 60  8
         this.columnName = name;
 61  8
         table = containingTable;
 62  8
     }
 63  
 
 64  
     /**
 65  
      * Get the name of a column.
 66  
      *
 67  
      * @return A String with the column name.
 68  
      */
 69  
     public String getColumnName()
 70  
     {
 71  0
         return columnName;
 72  
     }
 73  
 
 74  
     /**
 75  
      * Get the table name + column name.
 76  
      *
 77  
      * @return A String with the full column name.
 78  
      */
 79  
     public String getFullyQualifiedName()
 80  
     {
 81  0
         return table.getName() + "." + columnName;
 82  
     }
 83  
 
 84  
     /**
 85  
      * Get the name of the table this column is in.
 86  
      *
 87  
      * @return A String with the table name.
 88  
      */
 89  
     public String getTableName()
 90  
     {
 91  0
         return table.getName();
 92  
     }
 93  
 
 94  
     /**
 95  
      * Set the type of this column.
 96  
      *
 97  
      * @param type An Object specifying the type.
 98  
      */
 99  
     public void setType (Object type)
 100  
     {
 101  8
         this.type = type;
 102  8
     }
 103  
 
 104  
     /**
 105  
      * Set the size of this column.
 106  
      *
 107  
      * @param size An int specifying the size.
 108  
      */
 109  
     public void setSize(int size)
 110  
     {
 111  8
         this.size = size;
 112  8
     }
 113  
 
 114  
     /**
 115  
      * Set if this column is a primary key or not.
 116  
      *
 117  
      * @param pk True if column is a primary key.
 118  
      */
 119  
     public void setPrimaryKey(boolean pk)
 120  
     {
 121  8
         this.pk = pk;
 122  8
     }
 123  
 
 124  
     /**
 125  
      * Set if this column may be null.
 126  
      *
 127  
      * @param nn True if column may be null.
 128  
      */
 129  
     public void setNotNull(boolean nn)
 130  
     {
 131  0
         this.notNull = nn;
 132  0
     }
 133  
 
 134  
     /**
 135  
      * Set the foreign key for this column.
 136  
      *
 137  
      * @param fullyQualifiedName The name of the table.column that is
 138  
      * foreign.
 139  
      */
 140  
     public void setForeignKey(String fullyQualifiedName)
 141  
     {
 142  0
         if (fullyQualclass="keyword">ifiedName != null && fullyQualclass="keyword">ifiedName.length() > 0)
 143  
         {
 144  0
             relatedTableName = fullyQualifiedName.substring(
 145  
                     0, fullyQualifiedName.indexOf('.'));
 146  0
             relatedColumnName = fullyQualifiedName.substring(
 147  
                     fullyQualifiedName.indexOf('.') + 1);
 148  
         }
 149  
         else
 150  
         {
 151  0
             relatedTableName = "";
 152  0
             relatedColumnName = "";
 153  
         }
 154  0
     }
 155  
 
 156  
     /**
 157  
      * Set the foreign key for this column.
 158  
      *
 159  
      * @param tableName The name of the table that is foreign.
 160  
      * @param columnName The name of the column that is foreign.
 161  
      */
 162  
     public void setForeignKey(String tableName, String columnName)
 163  
     {
 164  8
         if (tableName != null && tableName.length() > 0 && columnName != class="keyword">null
 165  
                 && columnName.length() > 0)
 166  
         {
 167  0
             relatedTableName = tableName;
 168  0
             relatedColumnName = columnName;
 169  
         }
 170  
         else
 171  
         {
 172  8
             relatedTableName = "";
 173  8
             relatedColumnName = "";
 174  
         }
 175  8
     }
 176  
 
 177  
     /**
 178  
      * Get the type of this column.
 179  
      *
 180  
      * @return An Object specifying the type.
 181  
      */
 182  
     public Object getType()
 183  
     {
 184  0
         return type;
 185  
     }
 186  
 
 187  
     /**
 188  
      * Get the size of this column.
 189  
      *
 190  
      * @return An int specifying the size.
 191  
      */
 192  
     public int getSize()
 193  
     {
 194  0
         return size;
 195  
     }
 196  
 
 197  
     /**
 198  
      * Is this column a primary key?
 199  
      *
 200  
      * @return True if column is a primary key.
 201  
      */
 202  
     public boolean isPrimaryKey()
 203  
     {
 204  0
         return pk;
 205  
     }
 206  
 
 207  
     /**
 208  
      * Is null value allowed ?
 209  
      *
 210  
      * @return True if column may be null.
 211  
      */
 212  
     public boolean isNotNull()
 213  
     {
 214  0
         return (notNull || isPrimaryKey());
 215  
     }
 216  
 
 217  
     /**
 218  
      * Is this column a foreign key?
 219  
      *
 220  
      * @return True if column is a foreign key.
 221  
      */
 222  
     public boolean isForeignKey()
 223  
     {
 224  0
         return (relatedTableName != null && relatedTableName.length() > 0);
 225  
     }
 226  
 
 227  
     /**
 228  
      * Get the table.column that this column is related to.
 229  
      *
 230  
      * @return A String with the full name for the related column.
 231  
      */
 232  
     public String getRelatedName()
 233  
     {
 234  0
         return relatedTableName + "." + relatedColumnName;
 235  
     }
 236  
 
 237  
     /**
 238  
      * Get the table name that this column is related to.
 239  
      *
 240  
      * @return A String with the name for the related table.
 241  
      */
 242  
     public String getRelatedTableName()
 243  
     {
 244  0
         return relatedTableName;
 245  
     }
 246  
 
 247  
     /**
 248  
      * Get the column name that this column is related to.
 249  
      *
 250  
      * @return A String with the name for the related column.
 251  
      */
 252  
     public String getRelatedColumnName()
 253  
     {
 254  0
         return relatedColumnName;
 255  
     }
 256  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.