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

File RevisionCriteria.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

6
17
12
1
163
66
15
0.88
1.42
12
1.25

Classes

Class Line # Actions
RevisionCriteria 31 17 0% 15 6
0.8285714482.9%
 

Contributing tests

No tests hitting this source file were found.

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    import java.util.Date;
23   
24    /**
25    * information about document versions used to retreive a set of document versions.
26    *
27    * @version $Id: e43a6356bc839fef7979f8a0fbdcf3589a2e3712 $
28    * @see com.xpn.xwiki.doc.XWikiDocument#getRevisions(RevisionCriteria, com.xpn.xwiki.XWikiContext)
29    * @since 1.4M1
30    */
 
31    public class RevisionCriteria
32    {
33    /**
34    * regexp matching the author of version set.
35    */
36    private String author = "";
37   
38    /**
39    * date range of the version set
40    */
41    private Period period = PeriodFactory.createMaximumPeriod();
42   
43    /**
44    * range allowing to limit the size of the set by getting only N first items or N last items
45    */
46    private Range range = RangeFactory.createAllRange();
47   
48    /**
49    * include minor edit versions in the set.
50    */
51    private boolean includeMinorVersions = false;
52   
53    /**
54    * Default constructor, the default query match the versions created by any author, from January 1, 1970, 00:00:00
55    * GMT (epoch) to the maximum possible date (Long.MAX_VALUE), minor versions aren't included
56    */
 
57  0 toggle public RevisionCriteria()
58    {
59    // Nothing to do here.
60    }
61   
62    /**
63    * Fully featured constructor, allow to set all the query parameters, null arguments are ignored
64    */
 
65  7 toggle public RevisionCriteria(String author, Period period, Range range,
66    boolean includeMinorVersions)
67    {
68  7 if (author != null) {
69  7 setAuthor(author);
70    }
71  7 if (period != null) {
72  7 setPeriod(period);
73    }
74  7 if (range != null) {
75  7 setRange(range);
76    }
77  7 setIncludeMinorVersions(includeMinorVersions);
78    }
79   
80    /**
81    * @return author the author of version set.
82    */
 
83  22 toggle public String getAuthor()
84    {
85  22 return this.author;
86    }
87   
88    /**
89    * @param author the author of version set.
90    */
 
91  7 toggle public void setAuthor(String author)
92    {
93  7 this.author = author;
94    }
95   
96    /**
97    * @return period the Period (time limits) desired for the results
98    */
 
99  0 toggle public Period getPeriod()
100    {
101  0 return this.period;
102    }
103   
104    /**
105    * Set the Period (time limits) desired for the results
106    *
107    * @param period
108    */
 
109  7 toggle public void setPeriod(Period period)
110    {
111  7 this.period = period;
112    }
113   
114    /**
115    * @return range the Range (size limits) desired for the results
116    */
 
117  14 toggle public Range getRange()
118    {
119  14 return this.range;
120    }
121   
122    /**
123    * Set the Range (size limits) desired for the results
124    *
125    * @param range desired range @see Range
126    */
 
127  14 toggle public void setRange(Range range)
128    {
129  14 this.range = range;
130    }
131   
132    /**
133    * @return minimum date of version set.
134    */
 
135  22 toggle public Date getMinDate()
136    {
137  22 return new Date(this.period.getStart());
138    }
139   
140    /**
141    * @return maximum date of version set.
142    */
 
143  22 toggle public Date getMaxDate()
144    {
145  22 return new Date(this.period.getEnd());
146    }
147   
148    /**
149    * include minor versions in the set.
150    */
 
151  8 toggle public boolean getIncludeMinorVersions()
152    {
153  8 return this.includeMinorVersions;
154    }
155   
156    /**
157    * @param includeMinorVersions true to include minor versions in the set, false to ignore them.
158    */
 
159  7 toggle public void setIncludeMinorVersions(boolean includeMinorVersions)
160    {
161  7 this.includeMinorVersions = includeMinorVersions;
162    }
163    }