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

File RangeFactory.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

0
7
8
1
111
38
8
1.14
0.88
8
1

Classes

Class Line # Actions
RangeFactory 25 7 0% 8 6
0.660%
 

Contributing tests

This file is covered by 5 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    * Helper factory class for creating Range objects in velocity
24    */
 
25    public class RangeFactory
26    {
27    /**
28    * The interval that matches the entire list it is applied to.
29    */
30    public static final Range ALL = createRange(0, 0);
31   
32    /**
33    * The interval that matches just the first element of the list it is applied to.
34    */
35    public static final Range FIRST = createRange(0, 1);
36   
37    /**
38    * The interval that matches just the last element of the list it is applied to.
39    */
40    public static final Range LAST = createRange(0, -1);
41   
 
42  7 toggle public RangeFactory()
43    {
44    }
45   
46    /**
47    * @see Range#Range(int, int)
48    */
 
49  33 toggle public static Range createRange(int start, int size)
50    {
51  33 return new Range(start, size);
52    }
53   
54    /**
55    * Creates a new Range which matches all the elements of the list it is applied to.
56    *
57    * @return A new Range instance
58    */
 
59  14 toggle public static Range createAllRange()
60    {
61  14 return new Range(0, 0);
62    }
63   
64    /**
65    * Creates a new Range starting from 0 and having the specified size. It matches the first <code>size</code>
66    * elements of the list it is applied to.
67    *
68    * @param size The size of the interval
69    * @return A new Range instance
70    */
 
71  4 toggle public static Range createHeadRange(int size)
72    {
73  4 return createRange(0, Math.abs(size));
74    }
75   
76    /**
77    * Creates a new Range starting from the end of the list it is applied to and having the specified size. It matches
78    * the last <code>size</code> elements of the list.
79    *
80    * @param size The size of the interval
81    * @return A new Range instance
82    */
 
83  4 toggle public static Range createTailRange(int size)
84    {
85  4 return createRange(0, -Math.abs(size));
86    }
87   
88    /**
89    * Helper method for accessing {@link #ALL} static field in velocity
90    */
 
91  0 toggle public static Range getALL()
92    {
93  0 return ALL;
94    }
95   
96    /**
97    * Helper method for accessing {@link #FIRST} static field in velocity
98    */
 
99  0 toggle public static Range getFIRST()
100    {
101  0 return FIRST;
102    }
103   
104    /**
105    * Helper method for accessing {@link #LAST} static field in velocity
106    */
 
107  0 toggle public static Range getLAST()
108    {
109  0 return LAST;
110    }
111    }