Clover coverage report - brownies library - 1.0-beta-1
Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00
file stats: LOC: 151   Methods: 16
NCLOC: 81   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
SimpleDateRange.java 45.8% 58.1% 37.5% 49.3%
coverage coverage
 1   
 /*
 2   
  * Joey and its relative products are published under the terms
 3   
  * of the Apache Software License.
 4   
  */
 5   
 package org.asyrinx.brownie.core.util;
 6   
 
 7   
 import java.util.Date;
 8   
 
 9   
 import org.apache.commons.lang.ObjectUtils;
 10   
 import org.apache.commons.lang.StringUtils;
 11   
 
 12   
 /**
 13   
  * @author akima
 14   
  */
 15   
 public class SimpleDateRange {
 16   
 
 17   
     /**
 18   
      *  
 19   
      */
 20  48
     public SimpleDateRange(SimpleDate from, SimpleDate to) {
 21  48
         super();
 22  48
         this.from = from;
 23  48
         this.to = to;
 24   
     }
 25   
 
 26   
     /**
 27   
      *  
 28   
      */
 29  0
     public SimpleDateRange(DateRange dateRange) {
 30  0
         this(toSimpleDate(dateRange.getFrom()), toSimpleDate(dateRange.getTo()));
 31   
     }
 32   
 
 33   
     /**
 34   
      *  
 35   
      */
 36  34
     public SimpleDateRange(int fromYear, int fromMonth, int fromDay,
 37   
             int toYear, int toMonth, int toDay) {
 38  34
         this(toSimpleDate(fromYear, fromMonth, fromDay), toSimpleDate(toYear,
 39   
                 toMonth, toDay));
 40   
     }
 41   
 
 42  68
     private static SimpleDate toSimpleDate(int y, int m, int d) {
 43  68
         if (d < 1)
 44  25
             return null;
 45   
         else
 46  43
             return new SimpleDate(y, m, d);
 47   
     }
 48   
 
 49  0
     public static SimpleDate toSimpleDate(Date d) {
 50  0
         if (d != null)
 51  0
             return new SimpleDate(d);
 52   
         else
 53  0
             return null;
 54   
     }
 55   
 
 56   
     private final SimpleDate from;
 57   
 
 58   
     private final SimpleDate to;
 59   
 
 60   
     /**
 61   
      * @param obj
 62   
      * @return @see java.lang.Object#equals(java.lang.Object)
 63   
      */
 64  6
     public boolean equals(Object obj) {
 65  6
         if (obj instanceof SimpleDateRange) {
 66  6
             final SimpleDateRange range = (SimpleDateRange) obj;
 67  6
             return ObjectUtils.equals(this.from, range.from)
 68   
                     && ObjectUtils.equals(this.to, range.to);
 69   
         } else {
 70  0
             return super.equals(obj);
 71   
         }
 72   
     }
 73   
 
 74  63
     public boolean include(SimpleDate when) {
 75  63
         if (from == null && to == null) {
 76  5
             return true;
 77  58
         } else if (from != null && to == null) {
 78  23
             return from.before(when) || from.equals(when);
 79  35
         } else if (from == null && to != null) {
 80  14
             return to.after(when) || to.equals(when);
 81   
         } else {
 82  21
             return (from.before(when) || from.equals(when))
 83   
                     && (to.after(when) || to.equals(when));
 84   
         }
 85   
     }
 86   
 
 87   
     /**
 88   
      * @return @see java.lang.Object#toString()
 89   
      */
 90  0
     public String toString() {
 91  0
         return StringUtils.defaultString(from.toString()) + "-"
 92   
                 + StringUtils.defaultString(to.toString());
 93   
     }
 94   
 
 95   
     /**
 96   
      * @return
 97   
      */
 98  0
     public SimpleDate getFrom() {
 99  0
         return from;
 100   
     }
 101   
 
 102   
     /**
 103   
      * @return
 104   
      */
 105  0
     public SimpleDate getTo() {
 106  0
         return to;
 107   
     }
 108   
 
 109   
     /**
 110   
      * @return
 111   
      */
 112  0
     public int getFromDay() {
 113  0
         return (from == null) ? 0 : from.getDay();
 114   
     }
 115   
 
 116   
     /**
 117   
      * @return
 118   
      */
 119  0
     public int getFromMonth() {
 120  0
         return (from == null) ? 0 : from.getMonth();
 121   
     }
 122   
 
 123   
     /**
 124   
      * @return
 125   
      */
 126  22
     public int getFromYear() {
 127  22
         return (from == null) ? 0 : from.getYear();
 128   
     }
 129   
 
 130   
     /**
 131   
      * @return
 132   
      */
 133  0
     public int getToDay() {
 134  0
         return (to == null) ? 0 : to.getDay();
 135   
     }
 136   
 
 137   
     /**
 138   
      * @return
 139   
      */
 140  0
     public int getToMonth() {
 141  0
         return (to == null) ? 0 : to.getMonth();
 142   
     }
 143   
 
 144   
     /**
 145   
      * @return
 146   
      */
 147  0
     public int getToYear() {
 148  0
         return (to == null) ? 0 : to.getYear();
 149   
     }
 150   
 
 151   
 }