Coverage Report - rs.mgifos.mosquito.model.MetaReference
 
Classes in this File Line Coverage Branch Coverage Complexity
MetaReference
39%
12/31
N/A
0
 
 1  
 /* 
 2  
  * This file is part of Mosquito meta-loader.
 3  
  *
 4  
  * Mosquito meta-loader is free software; you can redistribute it and/or modify
 5  
  * it under the terms of the GNU Lesser General Public License as published by
 6  
  * the Free Software Foundation; either version 3 of the License, or
 7  
  * (at your option) any later version.
 8  
  *
 9  
  * Mosquito meta-loader is distributed in the hope that it will be useful,
 10  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
  * GNU Lesser General Public License for more details.
 13  
  *
 14  
  * You should have received a copy of the GNU Lesser General Public License
 15  
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 16  
  */
 17  
 
 18  
 package rs.mgifos.mosquito.model;
 19  
 
 20  
 import java.util.Enumeration;
 21  
 import java.util.Hashtable;
 22  
 import java.util.Iterator;
 23  
 
 24  
 /**
 25  
  *
 26  
  * @author <a href="mailto:nikola.petkov@gmail.com">Nikola Petkov &lt;nikola.petkov@gmail.com&gt;</a>
 27  
  */
 28  
 public class MetaReference implements Iterable<MetaColumn> {
 29  
 
 30  
     protected String code;
 31  
 
 32  4
     protected Hashtable<String, MetaColumn> htColumns = new Hashtable<String, MetaColumn>();
 33  
 
 34  
     protected String name;
 35  
 
 36  
     protected MetaTable sourceTable;
 37  
 
 38  
     protected MetaTable parentTable;
 39  
 
 40  
     /**
 41  
      * 
 42  
      */
 43  0
     public MetaReference() {
 44  
 
 45  0
     }
 46  
 
 47  
     /**
 48  
      * @param aName
 49  
      * @param aCode
 50  
      */
 51  4
     public MetaReference(String aName, String aCode) {
 52  4
         name = aName;
 53  4
         code = aCode;
 54  4
     }
 55  
 
 56  
     /**
 57  
      * Adds a new MetaColumn into key group
 58  
      * 
 59  
      * @param aMetaColumn
 60  
      */
 61  
     public void addColumn(MetaColumn aMetaColumn) {
 62  4
         htColumns.put(aMetaColumn.getCode(), aMetaColumn);
 63  4
     }
 64  
 
 65  
     /**
 66  
      * @param aMetaColumn
 67  
      * @return true if aMetaColumn is part of this MetaKey
 68  
      */
 69  
     public boolean containsColumn(MetaColumn aMetaColumn) {
 70  0
         return htColumns.containsValue(aMetaColumn);
 71  
     }
 72  
 
 73  
     /**
 74  
      * @param aColCode
 75  
      * @return
 76  
      * @throws NullPointerException
 77  
      */
 78  
     public boolean containsColumnCode(String aColCode)
 79  
             throws NullPointerException {
 80  0
         return htColumns.containsKey(aColCode);
 81  
     }
 82  
 
 83  
     /**
 84  
      * @return Enumeration of all columns of this MetaKey
 85  
      */
 86  
     public Enumeration<MetaColumn> eColumns() {
 87  0
         return htColumns.elements();
 88  
     }
 89  
 
 90  
     /**
 91  
      * @return code.
 92  
      */
 93  
     public String getCode() {
 94  4
         return code;
 95  
     }
 96  
 
 97  
     /**
 98  
      * @param aCode
 99  
      * @return MetaColumn if it exists, otherwise returns null
 100  
      */
 101  
     public MetaColumn getColByCode(String aCode) {
 102  0
         MetaColumn retVal = null;
 103  
         try {
 104  0
             retVal = (MetaColumn) htColumns.get(aCode);
 105  0
         } catch (Exception e) {
 106  0
             retVal = null;
 107  0
         }
 108  0
         return retVal;
 109  
     }
 110  
 
 111  
     /**
 112  
      * @return name.
 113  
      */
 114  
     public String getName() {
 115  0
         return name;
 116  
     }
 117  
 
 118  
     /**
 119  
      * @param aCode
 120  
      *            The code to set.
 121  
      */
 122  
     public void setCode(String aCode) {
 123  0
         code = aCode;
 124  0
     }
 125  
 
 126  
     /**
 127  
      * @param aName
 128  
      *            The name to set.
 129  
      */
 130  
     public void setName(String aName) {
 131  0
         name = aName;
 132  0
     }
 133  
 
 134  
     /**
 135  
      * Get referenced table
 136  
      * 
 137  
      * @return
 138  
      */
 139  
     public MetaTable getParentTable() {
 140  0
         return parentTable;
 141  
     }
 142  
 
 143  
     /**
 144  
      * @param aParentTable
 145  
      */
 146  
     public void setParentTable(MetaTable aParentTable) {
 147  4
         parentTable = aParentTable;
 148  4
     }
 149  
 
 150  
     /**
 151  
      * @return
 152  
      */
 153  
     public MetaTable getSourceTable() {
 154  0
         return sourceTable;
 155  
     }
 156  
 
 157  
     /**
 158  
      * @param aSourceTable
 159  
      */
 160  
     public void setSourceTable(MetaTable aSourceTable) {
 161  4
         sourceTable = aSourceTable;
 162  4
     }
 163  
 
 164  
     /**
 165  
      * @see java.lang.Iterable#iterator()
 166  
      */
 167  
     public Iterator<MetaColumn> iterator() {
 168  0
         return htColumns.values().iterator();
 169  
     }
 170  
 }