Clover Coverage Report - SmartWeb
Coverage timestamp: Sun Jun 8 2008 21:20:12 CEST
../../../../img/srcFileCovDistChart0.png 29% of files have more coverage
21   174   18   1,24
0   64   0,86   17
17     1,06  
1    
5% of code in this file is excluded from these metrics.
 
  CollectionPaginator       Line # 34 21 18 0% 0.0
 
No Tests
 
1    /*
2    * The SmartWeb Framework
3    * Copyright (C) 2004-2006
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2.1 of the License, or (at your option) any later version.
9    *
10    * This library 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 library; if not, write to the Free Software
17    * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18    *
19    * For further informations on the SmartWeb Framework please visit
20    *
21    * http://smartweb.sourceforge.net
22    */
23   
24    package net.smartlab.web.page;
25   
26    import java.util.Collection;
27    import java.util.Iterator;
28   
29    /**
30    * TODO documentation
31    *
32    * @author rlogiacco
33    */
 
34    public class CollectionPaginator extends Paginator implements Collection {
35   
36    private Collection collection;
37   
38    /**
39    * TODO documentation
40    *
41    * @param collection
42    */
 
43  0 toggle public CollectionPaginator(Collection collection) {
44  0 this(collection, 0);
45    }
46   
47    /**
48    * TODO documentation
49    *
50    * @param collection
51    * @param size
52    */
 
53  0 toggle public CollectionPaginator(Collection collection, int size) {
54  0 this(collection, size, Paginator.UNLIMITED_PAGES);
55    }
56   
57    /**
58    * TODO documentation
59    *
60    * @param collection
61    * @param size
62    * @param pages
63    */
 
64  0 toggle public CollectionPaginator(Collection collection, int size, int pages) {
65  0 super(size, pages);
66  0 super.setCount(collection.size());
67  0 this.collection = collection;
68    }
69   
70    /**
71    * @see net.smartlab.web.Paginator#setArray()
72    */
 
73  0 toggle protected void setArray() {
74  0 Object[] temp = collection.toArray();
75  0 try {
76  0 java.lang.System.arraycopy(temp, (super.getPage() - 1) * array.length, array, 0, array.length);
77    } catch (IndexOutOfBoundsException ioobe) {
78    java.lang.System.arraycopy(temp, (super.getPage() - 1) * array.length, array, 0, collection.size() % array.length);
79    array[collection.size() % array.length] = null;
80    }
81    }
82   
83    /**
84    * @see java.util.Collection#size()
85    */
 
86  0 toggle public int size() {
87  0 return collection.size();
88    }
89   
90    /**
91    * @see java.util.Collection#clear()
92    */
 
93  0 toggle public void clear() {
94  0 collection.clear();
95    }
96   
97    /**
98    * @see java.util.Collection#isEmpty()
99    */
 
100  0 toggle public boolean isEmpty() {
101  0 return collection.isEmpty();
102    }
103   
104    /**
105    * @see java.util.Collection#toArray()
106    */
 
107  0 toggle public Object[] toArray() {
108  0 return this.array;
109    }
110   
111    /**
112    * @see java.util.Collection#add(java.lang.Object)
113    */
 
114  0 toggle public boolean add(Object o) {
115  0 return collection.add(o);
116    }
117   
118    /**
119    * @see java.util.Collection#contains(java.lang.Object)
120    */
 
121  0 toggle public boolean contains(Object o) {
122  0 return collection.contains(o);
123    }
124   
125    /**
126    * @see java.util.Collection#remove(java.lang.Object)
127    */
 
128  0 toggle public boolean remove(Object o) {
129  0 return collection.remove(o);
130    }
131   
132    /**
133    * @see java.util.Collection#addAll(java.util.Collection)
134    */
 
135  0 toggle public boolean addAll(Collection c) {
136  0 return collection.addAll(c);
137    }
138   
139    /**
140    * @see java.util.Collection#containsAll(java.util.Collection)
141    */
 
142  0 toggle public boolean containsAll(Collection c) {
143  0 return collection.containsAll(c);
144    }
145   
146    /**
147    * @see java.util.Collection#removeAll(java.util.Collection)
148    */
 
149  0 toggle public boolean removeAll(Collection c) {
150  0 return collection.removeAll(c);
151    }
152   
153    /**
154    * @see java.util.Collection#retainAll(java.util.Collection)
155    */
 
156  0 toggle public boolean retainAll(Collection c) {
157  0 return collection.retainAll(c);
158    }
159   
160    /**
161    * @see java.util.Collection#iterator()
162    */
 
163  0 toggle public Iterator iterator() {
164  0 return this;
165    }
166   
167    /**
168    * @see java.util.Collection#toArray(java.lang.Object[])
169    */
 
170  0 toggle public Object[] toArray(Object[] a) {
171  0 throw new UnsupportedOperationException();
172    }
173   
174    }