1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.apache.commons.collections.primitives.adapters; |
18 | |
|
19 | |
import java.lang.reflect.Array; |
20 | |
import java.util.Collection; |
21 | |
import java.util.Iterator; |
22 | |
|
23 | |
import org.apache.commons.collections.primitives.BooleanCollection; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 457 | abstract class AbstractBooleanCollectionCollection implements Collection { |
30 | |
|
31 | |
public boolean add(Object element) { |
32 | 64 | return getBooleanCollection().add(((Boolean)element).booleanValue()); |
33 | |
} |
34 | |
|
35 | |
public boolean addAll(Collection c) { |
36 | 262 | return getBooleanCollection() |
37 | |
.addAll(CollectionBooleanCollection.wrap(c)); |
38 | |
} |
39 | |
|
40 | |
public void clear() { |
41 | 4 | getBooleanCollection().clear(); |
42 | 4 | } |
43 | |
|
44 | |
public boolean contains(Object element) { |
45 | 306 | return getBooleanCollection() |
46 | |
.contains(((Boolean)element).booleanValue()); |
47 | |
} |
48 | |
|
49 | |
|
50 | |
public boolean containsAll(Collection c) { |
51 | 14 | return getBooleanCollection().containsAll(CollectionBooleanCollection.wrap(c)); |
52 | |
} |
53 | |
|
54 | |
public String toString() { |
55 | 4 | return getBooleanCollection().toString(); |
56 | |
} |
57 | |
|
58 | |
public boolean isEmpty() { |
59 | 882 | return getBooleanCollection().isEmpty(); |
60 | |
} |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
public Iterator iterator() { |
70 | 2663 | return BooleanIteratorIterator.wrap(getBooleanCollection().iterator()); |
71 | |
} |
72 | |
|
73 | |
public boolean remove(Object element) { |
74 | 102 | return getBooleanCollection().removeElement( |
75 | |
((Boolean)element).booleanValue()); |
76 | |
} |
77 | |
|
78 | |
public boolean removeAll(Collection c) { |
79 | 0 | return getBooleanCollection() |
80 | |
.removeAll(CollectionBooleanCollection.wrap(c)); |
81 | |
} |
82 | |
|
83 | |
public boolean retainAll(Collection c) { |
84 | 0 | return getBooleanCollection(). |
85 | |
retainAll(CollectionBooleanCollection.wrap(c)); |
86 | |
} |
87 | |
|
88 | |
public int size() { |
89 | 2047 | return getBooleanCollection().size(); |
90 | |
} |
91 | |
|
92 | |
public Object[] toArray() { |
93 | 884 | boolean[] a = getBooleanCollection().toArray(); |
94 | 884 | Object[] A = new Object[a.length]; |
95 | 14417 | for(int i=0;i<a.length;i++) { |
96 | 13533 | A[i] = new Boolean(a[i]); |
97 | |
} |
98 | 884 | return A; |
99 | |
} |
100 | |
|
101 | |
public Object[] toArray(Object[] A) { |
102 | 10 | boolean[] a = getBooleanCollection().toArray(); |
103 | 10 | if(A.length < a.length) { |
104 | 6 | A = (Object[])(Array.newInstance(A.getClass().getComponentType(), a.length)); |
105 | |
} |
106 | 72 | for(int i=0;i<a.length;i++) { |
107 | 66 | A[i] = new Boolean(a[i]); |
108 | |
} |
109 | 6 | if(A.length > a.length) { |
110 | 2 | A[a.length] = null; |
111 | |
} |
112 | |
|
113 | 6 | return A; |
114 | |
} |
115 | |
|
116 | |
protected abstract BooleanCollection getBooleanCollection(); |
117 | |
} |