Coverage Report - net.objectlab.qalab.parser.SingleStat
 
Classes in this File Line Coverage Branch Coverage Complexity
SingleStat
68%
17/25
100%
3/3
1.5
 
 1  
 ////////////////////////////////////////////////////////////////////////////////
 2  
 //
 3  
 //                  ObjectLab is sponsoring QALab
 4  
 // 
 5  
 // Based in London, we are world leaders in the design and development 
 6  
 // of bespoke applications for the Securities Financing markets.
 7  
 // 
 8  
 // <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
 9  
 //           ___  _     _           _   _          _
 10  
 //          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
 11  
 //         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
 12  
 //         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
 13  
 //          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
 14  
 //                   |__/
 15  
 //
 16  
 //                   http://www.ObjectLab.co.uk
 17  
 // ---------------------------------------------------------------------------
 18  
 //
 19  
 //QALab is released under the GNU General Public License.
 20  
 //
 21  
 //QALab: Collects QA Statistics from your build over time.
 22  
 //2005+, ObjectLab Ltd
 23  
 //
 24  
 //This library is free software; you can redistribute it and/or
 25  
 //modify it under the terms of the GNU General Public
 26  
 //License as published by the Free Software Foundation; either
 27  
 //version 2.1 of the License, or (at your option) any later version.
 28  
 //
 29  
 //This library is distributed in the hope that it will be useful,
 30  
 //but WITHOUT ANY WARRANTY; without even the implied warranty of
 31  
 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 32  
 //General Public License for more details.
 33  
 //
 34  
 //You should have received a copy of the GNU General Public
 35  
 //License along with this library; if not, write to the Free Software
 36  
 //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 37  
 //
 38  
 ////////////////////////////////////////////////////////////////////////////////
 39  
 package net.objectlab.qalab.parser;
 40  
 
 41  
 import net.objectlab.qalab.util.QALabTags;
 42  
 
 43  
 import java.util.Date;
 44  
 
 45  
 /**
 46  
  * A class to store each result which are stored as part of the FileStat. This
 47  
  * class holds the following data; date, no. of errors and the type of reporting
 48  
  * 
 49  
  * @author Paramjit Rehinsi
 50  
  * @version $Revision: 242 $
 51  
  */
 52  996
 public class SingleStat {
 53  
     private static final int FULL_COVERAGE = 100;
 54  
 
 55  
     /** If the type is a Cobertura type, change the value to be 100 - value. **/
 56  
     private static final String COBERTURA_BRANCH = "cobertura-branch";
 57  
 
 58  
     /** If the type is a Cobertura type, change the value to be 100 - value. **/
 59  
     private static final String COBERTURA_LINE = "cobertura-line";
 60  
 
 61  
     /**
 62  
      * Date and time of the statistics.
 63  
      */
 64  996
     private Date datetime = null;
 65  
 
 66  
     /**
 67  
      * stat value detected.
 68  
      */
 69  996
     private int statvalue = -1;
 70  
 
 71  
     /**
 72  
      * type of error detected.
 73  
      */
 74  
     private String type;
 75  
 
 76  
     /**
 77  
      * @param date
 78  
      *            the date and time of detection of the errors.
 79  
      */
 80  
     public final void setDate(final Date date) {
 81  996
         this.datetime = new Date(date.getTime());
 82  996
     }
 83  
 
 84  
     /**
 85  
      * @return the date and time of detection of the errors.
 86  
      */
 87  
     public final Date getDate() {
 88  2229
         if (datetime != null) {
 89  2229
             return new Date(datetime.getTime());
 90  
         } else {
 91  0
             return null;
 92  
         }
 93  
     }
 94  
 
 95  
     /**
 96  
      * @param errors
 97  
      *            the error count detected.
 98  
      */
 99  
     public final void setStatValue(final int errors) {
 100  996
         this.statvalue = errors;
 101  996
         if (type != null) {
 102  0
             checkForInversion();
 103  
         }
 104  996
     }
 105  
 
 106  
     private void checkForInversion() {
 107  996
         if (statvalue != -1 && (COBERTURA_BRANCH.equals(type) || COBERTURA_LINE.equals(type))) {
 108  0
             statvalue = FULL_COVERAGE - statvalue;
 109  
         }
 110  996
     }
 111  
 
 112  
     /**
 113  
      * @return the error count.
 114  
      */
 115  
     public final int getStatValue() {
 116  1182
         return this.statvalue;
 117  
     }
 118  
 
 119  
     /**
 120  
      * @param statisticsType
 121  
      *            checkstyle|findbugs|pmd|simian
 122  
      */
 123  
     public final void setType(final String statisticsType) {
 124  996
         this.type = statisticsType;
 125  996
         checkForInversion();
 126  996
     }
 127  
 
 128  
     /**
 129  
      * @return the statistic type
 130  
      */
 131  
     public final String getType() {
 132  1155
         return this.type;
 133  
     }
 134  
 
 135  
     /**
 136  
      * @return a text representation
 137  
      */
 138  
     public final String toString() {
 139  0
         StringBuffer buf = new StringBuffer();
 140  
 
 141  0
         buf.append(type).append(" - ");
 142  0
         buf.append(QALabTags.DEFAULT_DATETIME_FORMAT.format(datetime));
 143  0
         buf.append(" - V:").append(statvalue);
 144  
 
 145  0
         return buf.toString();
 146  
     }
 147  
 }
 148  
 /*
 149  
  *                   ObjectLab is sponsoring QALab
 150  
  * 
 151  
  * Based in London, we are world leaders in the design and development 
 152  
  * of bespoke applications for the securities financing markets.
 153  
  * 
 154  
  * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
 155  
  *           ___  _     _           _   _          _
 156  
  *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
 157  
  *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
 158  
  *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
 159  
  *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
 160  
  *                   |__/
 161  
  *
 162  
  *                     www.ObjectLab.co.uk
 163  
  */