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.util.Collection;
20
21 import org.apache.commons.collections.primitives.BooleanIterator;
22 import org.apache.commons.collections.primitives.BooleanCollection;
23
24
25
26
27
28
29 abstract class AbstractCollectionBooleanCollection
30 implements BooleanCollection {
31
32 protected AbstractCollectionBooleanCollection() {
33 }
34
35 public boolean add(boolean element) {
36 return getCollection().add(new Boolean(element));
37 }
38
39 public boolean addAll(BooleanCollection c) {
40 return getCollection().addAll(BooleanCollectionCollection.wrap(c));
41 }
42
43 public void clear() {
44 getCollection().clear();
45 }
46
47 public boolean contains(boolean element) {
48 return getCollection().contains(new Boolean(element));
49 }
50
51 public boolean containsAll(BooleanCollection c) {
52 return getCollection().containsAll(
53 BooleanCollectionCollection.wrap(c));
54 }
55
56 public String toString() {
57 return getCollection().toString();
58 }
59
60 public boolean isEmpty() {
61 return getCollection().isEmpty();
62 }
63
64
65
66
67
68
69 public BooleanIterator iterator() {
70 return IteratorBooleanIterator.wrap(getCollection().iterator());
71 }
72
73 public boolean removeElement(boolean element) {
74 return getCollection().remove(new Boolean(element));
75 }
76
77 public boolean removeAll(BooleanCollection c) {
78 return getCollection().removeAll(BooleanCollectionCollection.wrap(c));
79 }
80
81 public boolean retainAll(BooleanCollection c) {
82 return getCollection().retainAll(BooleanCollectionCollection.wrap(c));
83 }
84
85 public int size() {
86 return getCollection().size();
87 }
88
89 public boolean[] toArray() {
90 Object[] src = getCollection().toArray();
91 boolean[] dest = new boolean[src.length];
92 for(int i=0;i<src.length;i++) {
93 dest[i] = ((Boolean)(src[i])).booleanValue();
94 }
95 return dest;
96 }
97
98 public boolean[] toArray(boolean[] dest) {
99 Object[] src = getCollection().toArray();
100 if(dest.length < src.length) {
101 dest = new boolean[src.length];
102 }
103 for(int i=0;i<src.length;i++) {
104 dest[i] = ((Boolean)(src[i])).booleanValue();
105 }
106 return dest;
107 }
108
109 protected abstract Collection getCollection();
110
111 }