Coverage Report - rs.mgifos.mosquito.impl.pdm.PDMType
 
Classes in this File Line Coverage Branch Coverage Complexity
PDMType
42%
10/24
25%
2/8
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.impl.pdm;
 19  
 
 20  
 import java.util.ArrayList;
 21  
 
 22  
 /**
 23  
  * 
 24  
  * @author <a href="mailto:nikola.petkov@gmail.com">Nikola Petkov
 25  
  *         &lt;nikola.petkov@gmail.com&gt;</a>
 26  
  */
 27  
 public class PDMType {
 28  
 
 29  7
         private ArrayList<LenType> alLengthTypes = new ArrayList<LenType>();
 30  
 
 31  7
         private ArrayList<PrecType> alPrecTypes = new ArrayList<PrecType>();
 32  
 
 33  7
         private String defaultJClass = "java.lang.String";
 34  
 
 35  
         private String pdTypeName;
 36  
 
 37  
         /**
 38  
          * 
 39  
          */
 40  0
         public PDMType() {
 41  0
         }
 42  
 
 43  
         /**
 44  
          * @param aPDTypeName
 45  
          * @param aDefaultJClass
 46  
          */
 47  7
         public PDMType(String aPDTypeName, String aDefaultJClass) {
 48  7
                 pdTypeName = aPDTypeName;
 49  7
                 defaultJClass = aDefaultJClass;
 50  7
         }
 51  
 
 52  
         /**
 53  
          * @param aLength
 54  
          * @param aPrecision
 55  
          * @return
 56  
          */
 57  
         public String getClassName(int aLength, int aPrecision) {
 58  
 
 59  25
                 for (PrecType crntPrecType : alPrecTypes) {
 60  0
                         if (aLength <= crntPrecType.getLength()) {
 61  0
                                 return crntPrecType.getJClass();
 62  
                         }
 63  
                 }
 64  
 
 65  25
                 for (LenType crntLenType : alLengthTypes) {
 66  0
                         if (aLength <= crntLenType.getLength()) {
 67  0
                                 return crntLenType.getJClass();
 68  
                         }
 69  
                 }
 70  25
                 return defaultJClass;
 71  
         }
 72  
 
 73  
         /**
 74  
          * @return defaultJType.
 75  
          */
 76  
         public String getDefaultJClass() {
 77  0
                 return defaultJClass;
 78  
         }
 79  
 
 80  
         /**
 81  
          * @return pdTypeName.
 82  
          */
 83  
         public String getPdTypeName() {
 84  0
                 return pdTypeName;
 85  
         }
 86  
 
 87  
         /**
 88  
          * @param aDefaultJType
 89  
          *            The defaultJType to set.
 90  
          */
 91  
         public void setDefaultJClass(String aDefaultJType) {
 92  0
                 defaultJClass = aDefaultJType;
 93  0
         }
 94  
 
 95  
         /**
 96  
          * @param aPdTypeName
 97  
          *            The pdTypeName to set.
 98  
          */
 99  
         public void setPdTypeName(String aPdTypeName) {
 100  0
                 pdTypeName = aPdTypeName;
 101  0
         }
 102  
 
 103  
         /**
 104  
          * @param aPrecType
 105  
          * @return
 106  
          */
 107  
         public boolean addPrec(PrecType aPrecType) {
 108  0
                 return alPrecTypes.add(aPrecType);
 109  
         }
 110  
 
 111  
         /**
 112  
          * @param aLenType
 113  
          * @return
 114  
          */
 115  
         public boolean addLen(LenType aLenType) {
 116  0
                 return alLengthTypes.add(aLenType);
 117  
         }
 118  
 }