1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.criteria.impl

File Duration.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

0
7
7
1
97
33
7
1
1
7
1

Classes

Class Line # Actions
Duration 28 7 0% 7 4
0.7142857371.4%
 

Contributing tests

This file is covered by 10 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.criteria.impl;
21   
22    /**
23    * Immutable duration for retrieving statistics. A duration of time is uniquely identified by its span. For instance, a
24    * duration of 3 minutes doesn't imply a specific start time. It can start at any time, but it takes just 3 minutes. A
25    * Duration can be used to sample a Period of time. For instance the period between November 1th 2007 and December 1th
26    * 2007 can be divided in samples each having a duration of 3 days.
27    */
 
28    public class Duration
29    {
30    private org.joda.time.Period span;
31   
32    /**
33    * Creates a duration by specifying a value for each of its fields.
34    *
35    * @param years The number of years
36    * @param months The number of months
37    * @param weeks The number of weeks
38    * @param days The number of days
39    */
 
40  24 toggle public Duration(int years, int months, int weeks, int days)
41    {
42  24 this.span = new org.joda.time.Period(years, months, weeks, days, 0, 0, 0, 0);
43    }
44   
45    /**
46    * Creates a duration by specifying a value for each of its fields.
47    *
48    * @param years The number of years
49    * @param months The number of months
50    * @param weeks The number of weeks
51    * @param days The number of days
52    */
 
53  0 toggle public Duration(int years, int months, int weeks, int days, int hours)
54    {
55  0 this.span = new org.joda.time.Period(years, months, weeks, days, hours, 0, 0, 0);
56    }
57   
58    /**
59    * @return The number of years this duration has
60    */
 
61  24 toggle public int getYears()
62    {
63  24 return this.span.getYears();
64    }
65   
66    /**
67    * @return The number of months this duration has
68    */
 
69  24 toggle public int getMonths()
70    {
71  24 return this.span.getMonths();
72    }
73   
74    /**
75    * @return The number of weeks this duration has
76    */
 
77  24 toggle public int getWeeks()
78    {
79  24 return this.span.getWeeks();
80    }
81   
82    /**
83    * @return The number of days this duration has
84    */
 
85  24 toggle public int getDays()
86    {
87  24 return this.span.getDays();
88    }
89   
90    /**
91    * @return The number of hours this duration has
92    */
 
93  0 toggle public int getHours()
94    {
95  0 return this.span.getHours();
96    }
97    }