Coverage Report - rs.mgifos.mosquito.model.MetaKey
 
Classes in this File Line Coverage Branch Coverage Complexity
MetaKey
36%
9/25
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 MetaKey implements Iterable<MetaColumn>{
 29  
 
 30  
     protected String code;
 31  
 
 32  5
     protected Hashtable<String, MetaColumn> htColumns = new Hashtable<String, MetaColumn>();
 33  
 
 34  
     protected String name;
 35  
 
 36  
     /**
 37  
      *  
 38  
      */
 39  0
     public MetaKey() {
 40  0
     }
 41  
 
 42  
     /**
 43  
      * 
 44  
      * @param aName
 45  
      * @param aCode
 46  
      */
 47  5
     public MetaKey(String aName, String aCode) {
 48  5
         name = aName;
 49  5
         code = aCode;
 50  5
     }
 51  
 
 52  
     /**
 53  
      * Adds a new MetaColumn into key group
 54  
      * 
 55  
      * @param aMetaColumn
 56  
      */
 57  
     public void addColumn(MetaColumn aMetaColumn) {
 58  5
         htColumns.put(aMetaColumn.getCode(), aMetaColumn);
 59  5
     }
 60  
 
 61  
     /**
 62  
      * @param aMetaColumn
 63  
      * @return true if aMetaColumn is part of this MetaKey
 64  
      */
 65  
     public boolean containsColumn(MetaColumn aMetaColumn) {
 66  18
         return htColumns.containsValue(aMetaColumn);
 67  
     }
 68  
 
 69  
     /**
 70  
      * @param aColCode
 71  
      * @return @throws
 72  
      *         NullPointerException
 73  
      */
 74  
     public boolean containsColumnCode(String aColCode)
 75  
             throws NullPointerException {
 76  0
         return htColumns.containsKey(aColCode);
 77  
     }
 78  
 
 79  
     /**
 80  
      * @return Enumeration of all columns of this MetaKey
 81  
      */
 82  
     public Enumeration<MetaColumn> eColumns() {
 83  0
         return htColumns.elements();
 84  
     }
 85  
 
 86  
     /**
 87  
      * @return code.
 88  
      */
 89  
     public String getCode() {
 90  5
         return code;
 91  
     }
 92  
 
 93  
     /**
 94  
      * @param aCode
 95  
      * @return MetaColumn if it exists, otherwise returns null
 96  
      */
 97  
     public MetaColumn getColByCode(String aCode) {
 98  0
         MetaColumn retVal = null;
 99  
         try {
 100  0
             retVal = (MetaColumn) htColumns.get(aCode);
 101  0
         } catch (Exception e) {
 102  0
             retVal = null;
 103  0
         }
 104  0
         return retVal;
 105  
     }
 106  
 
 107  
     /**
 108  
      * @return name.
 109  
      */
 110  
     public String getName() {
 111  0
         return name;
 112  
     }
 113  
 
 114  
     /**
 115  
      * @see java.lang.Iterable#iterator()
 116  
      */
 117  
     public Iterator<MetaColumn> iterator() {
 118  0
         return htColumns.values().iterator();
 119  
     }
 120  
 
 121  
     /**
 122  
      * @param aCode
 123  
      *            The code to set.
 124  
      */
 125  
     public void setCode(String aCode) {
 126  0
         code = aCode;
 127  0
     }
 128  
 
 129  
     /**
 130  
      * @param aName
 131  
      *            The name to set.
 132  
      */
 133  
     public void setName(String aName) {
 134  0
         name = aName;
 135  0
     }
 136  
 }