Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SetKeyList |
|
| 1.105263157894737;1.105 |
1 | /** | |
2 | * Distribution License: | |
3 | * JSword is free software; you can redistribute it and/or modify it under | |
4 | * the terms of the GNU Lesser General Public License, version 2.1 or later | |
5 | * as published by the Free Software Foundation. This program is distributed | |
6 | * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
7 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
8 | * See the GNU Lesser General Public License for more details. | |
9 | * | |
10 | * The License is available on the internet at: | |
11 | * http://www.gnu.org/copyleft/lgpl.html | |
12 | * or by writing to: | |
13 | * Free Software Foundation, Inc. | |
14 | * 59 Temple Place - Suite 330 | |
15 | * Boston, MA 02111-1307, USA | |
16 | * | |
17 | * © CrossWire Bible Society, 2005 - 2016 | |
18 | * | |
19 | */ | |
20 | package org.crosswire.jsword.passage; | |
21 | ||
22 | import java.util.ArrayList; | |
23 | import java.util.Iterator; | |
24 | import java.util.List; | |
25 | import java.util.Set; | |
26 | ||
27 | import org.slf4j.Logger; | |
28 | import org.slf4j.LoggerFactory; | |
29 | ||
30 | /** | |
31 | * A Key that uses a Set of Keys as it's store of data. | |
32 | * | |
33 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
34 | * @author Joe Walker | |
35 | */ | |
36 | public class SetKeyList extends AbstractKeyList { | |
37 | /** | |
38 | * Simple ctor | |
39 | * @param set | |
40 | */ | |
41 | public SetKeyList(Set<Key> set) { | |
42 | 0 | this(set, null, null); |
43 | 0 | } |
44 | ||
45 | /** | |
46 | * Simple ctor | |
47 | * @param set | |
48 | * @param name | |
49 | */ | |
50 | public SetKeyList(Set<Key> set, String name) { | |
51 | 0 | this(set, null, name); |
52 | 0 | } |
53 | ||
54 | /** | |
55 | * Simple ctor | |
56 | * @param set | |
57 | * @param parent | |
58 | */ | |
59 | public SetKeyList(Set<Key> set, Key parent) { | |
60 | 0 | this(set, parent, null); |
61 | 0 | } |
62 | ||
63 | /** | |
64 | * Simple ctor | |
65 | * @param set | |
66 | * @param parent | |
67 | * @param name | |
68 | */ | |
69 | public SetKeyList(Set<Key> set, Key parent, String name) { | |
70 | 0 | super(name); |
71 | 0 | this.parent = parent; |
72 | 0 | list.addAll(set); |
73 | 0 | } |
74 | ||
75 | /* | |
76 | * (non-Javadoc) | |
77 | * | |
78 | * @see | |
79 | * org.crosswire.jsword.passage.Key#add(org.crosswire.jsword.passage.Key) | |
80 | */ | |
81 | public void addAll(Key key) { | |
82 | 0 | list.add(key); |
83 | 0 | } |
84 | ||
85 | /* | |
86 | * (non-Javadoc) | |
87 | * | |
88 | * @see org.crosswire.jsword.passage.Key#clear() | |
89 | */ | |
90 | public void clear() { | |
91 | 0 | list.clear(); |
92 | 0 | } |
93 | ||
94 | /* | |
95 | * (non-Javadoc) | |
96 | * | |
97 | * @see | |
98 | * org.crosswire.jsword.passage.Key#contains(org.crosswire.jsword.passage | |
99 | * .Key) | |
100 | */ | |
101 | @Override | |
102 | public boolean contains(Key key) { | |
103 | 0 | return list.contains(key); |
104 | } | |
105 | ||
106 | /* | |
107 | * (non-Javadoc) | |
108 | * | |
109 | * @see java.lang.Object#equals(java.lang.Object) | |
110 | */ | |
111 | @Override | |
112 | public boolean equals(Object obj) { | |
113 | 0 | if (obj instanceof SetKeyList) { |
114 | 0 | SetKeyList that = (SetKeyList) obj; |
115 | 0 | return list.equals(that.list); |
116 | } | |
117 | 0 | return false; |
118 | } | |
119 | ||
120 | /* | |
121 | * (non-Javadoc) | |
122 | * | |
123 | * @see java.lang.Object#hashCode() | |
124 | */ | |
125 | @Override | |
126 | public int hashCode() { | |
127 | 0 | return list.hashCode(); |
128 | } | |
129 | ||
130 | /* | |
131 | * (non-Javadoc) | |
132 | * | |
133 | * @see org.crosswire.jsword.passage.Key#isEmpty() | |
134 | */ | |
135 | @Override | |
136 | public boolean isEmpty() { | |
137 | 0 | return list.isEmpty(); |
138 | } | |
139 | ||
140 | /* | |
141 | * (non-Javadoc) | |
142 | * | |
143 | * @see org.crosswire.jsword.passage.Key#iterator() | |
144 | */ | |
145 | public Iterator<Key> iterator() { | |
146 | 0 | return list.iterator(); |
147 | } | |
148 | ||
149 | /* | |
150 | * (non-Javadoc) | |
151 | * | |
152 | * @see | |
153 | * org.crosswire.jsword.passage.Key#remove(org.crosswire.jsword.passage.Key) | |
154 | */ | |
155 | public void removeAll(Key key) { | |
156 | 0 | list.remove(key); |
157 | 0 | } |
158 | ||
159 | /* | |
160 | * (non-Javadoc) | |
161 | * | |
162 | * @see org.crosswire.jsword.passage.Key#getCardinality() | |
163 | */ | |
164 | public int getCardinality() { | |
165 | 0 | return list.size(); |
166 | } | |
167 | ||
168 | /* | |
169 | * (non-Javadoc) | |
170 | * | |
171 | * @see org.crosswire.jsword.passage.Key#canHaveChildren() | |
172 | */ | |
173 | public boolean canHaveChildren() { | |
174 | 0 | return false; |
175 | } | |
176 | ||
177 | /* | |
178 | * (non-Javadoc) | |
179 | * | |
180 | * @see org.crosswire.jsword.passage.Key#getChildCount() | |
181 | */ | |
182 | public int getChildCount() { | |
183 | 0 | return 0; |
184 | } | |
185 | ||
186 | /* | |
187 | * (non-Javadoc) | |
188 | * | |
189 | * @see org.crosswire.jsword.passage.Key#get(int) | |
190 | */ | |
191 | public Key get(int index) { | |
192 | 0 | return list.get(index); |
193 | } | |
194 | ||
195 | /* | |
196 | * (non-Javadoc) | |
197 | * | |
198 | * @see | |
199 | * org.crosswire.jsword.passage.Key#indexOf(org.crosswire.jsword.passage | |
200 | * .Key) | |
201 | */ | |
202 | public int indexOf(Key that) { | |
203 | 0 | return list.indexOf(that); |
204 | } | |
205 | ||
206 | /* | |
207 | * (non-Javadoc) | |
208 | * | |
209 | * @see org.crosswire.jsword.passage.Key#getParent() | |
210 | */ | |
211 | public Key getParent() { | |
212 | 0 | return parent; |
213 | } | |
214 | ||
215 | /* | |
216 | * (non-Javadoc) | |
217 | * | |
218 | * @see org.crosswire.jsword.passage.Key#blur(int) | |
219 | */ | |
220 | public void blur(int by, RestrictionType restrict) { | |
221 | 0 | log.warn("attempt to blur a non-blur-able list"); |
222 | 0 | } |
223 | ||
224 | /** | |
225 | * The parent of this key | |
226 | */ | |
227 | private Key parent; | |
228 | ||
229 | /** | |
230 | * The Set that we are proxying to | |
231 | */ | |
232 | 0 | private List<Key> list = new ArrayList<Key>(); |
233 | ||
234 | /** | |
235 | * Serialization ID | |
236 | */ | |
237 | private static final long serialVersionUID = -1460162676283475117L; | |
238 | ||
239 | /** | |
240 | * The log stream | |
241 | */ | |
242 | 0 | private static final Logger log = LoggerFactory.getLogger(SetKeyList.class); |
243 | } |