Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DivisionName |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$1 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$10 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$11 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$12 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$13 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$14 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$2 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$3 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$4 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$5 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$6 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$7 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$8 |
|
| 1.4516129032258065;1.452 | ||||
DivisionName$9 |
|
| 1.4516129032258065;1.452 |
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.versification; | |
21 | ||
22 | import org.crosswire.jsword.JSMsg; | |
23 | ||
24 | /** | |
25 | * DivisionName deals with traditional sections of the Bible. | |
26 | * | |
27 | * AV11N(DMS): Is this right? | |
28 | * <ul> | |
29 | * <li><strong>contains(BibleBook)</strong> - This has several problems: | |
30 | * <ol> | |
31 | * <li>The use of BibleBook.ordinal() is dependent upon the ordering of the | |
32 | * members of the BibleBook enum. Currently it is ordered OT and NT according to | |
33 | * the KJV and then has the deuterocanonical and apocryphal books in no | |
34 | * particular order.</li> | |
35 | * <li>Each versification defines the what books are present and the order of | |
36 | * books. So for one versification, GEN might not be the first and REV might not | |
37 | * be the last. E.g. Some V11Ns consist only of the OT.</li> | |
38 | * </ol> | |
39 | * </li> | |
40 | * <li><strong>getSize()</strong> - This can vary by versification for at least | |
41 | * BIBLE, OT and NT for those that include deuterocanonical or apocryphal books. | |
42 | * </li> | |
43 | * <li><strong>getRange()</strong> - This range is fixed text giving end points | |
44 | * that may include BibleBooks that are not intended and may exclude BibleBooks | |
45 | * that are intended. It works for the default Versification and may not work | |
46 | * for others.</li> | |
47 | * <li>A given V11N might be a single testament or just the gospels. In this case, | |
48 | * it'd be good to know whether a division isDefined()</li> | |
49 | * </ul> | |
50 | * | |
51 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
52 | * @author Joe Walker | |
53 | * @author DM Smith | |
54 | */ | |
55 | 0 | public enum DivisionName { |
56 | /** BIBLE consists of the entire/whole Bible (Gen - Rev) **/ | |
57 | 0 | BIBLE { |
58 | @Override | |
59 | public boolean contains(BibleBook book) { | |
60 | 0 | int bookNum = book.ordinal(); |
61 | 0 | return bookNum >= BibleBook.GEN.ordinal() && bookNum <= BibleBook.REV.ordinal(); |
62 | } | |
63 | ||
64 | @Override | |
65 | public int getSize() { | |
66 | 0 | return 66; |
67 | } | |
68 | ||
69 | @Override | |
70 | public String getName() { | |
71 | // TRANSLATOR: The entire/whole Bible (Gen - Rev) | |
72 | 0 | return JSMsg.gettext("The Whole Bible"); |
73 | } | |
74 | ||
75 | @Override | |
76 | public String getRange() { | |
77 | 0 | return "Gen-Rev"; |
78 | } | |
79 | ||
80 | }, | |
81 | /** OLD_TESTAMENT consists of the old testament (Gen - Mal) **/ | |
82 | 0 | OLD_TESTAMENT { |
83 | @Override | |
84 | public boolean contains(BibleBook book) { | |
85 | 0 | int bookNum = book.ordinal(); |
86 | 0 | return bookNum >= BibleBook.GEN.ordinal() && bookNum <= BibleBook.MAL.ordinal(); |
87 | } | |
88 | ||
89 | @Override | |
90 | public int getSize() { | |
91 | 0 | return 39; |
92 | } | |
93 | ||
94 | @Override | |
95 | public String getName() { | |
96 | // TRANSLATOR: The old testament (Gen - Mal) | |
97 | 0 | return JSMsg.gettext("Old Testament"); |
98 | } | |
99 | ||
100 | @Override | |
101 | public String getRange() { | |
102 | 0 | return "Gen-Mal"; |
103 | } | |
104 | }, | |
105 | /** PENTATEUCH consists of the 5 books of Moses (Gen - Deu) **/ | |
106 | 0 | PENTATEUCH { |
107 | @Override | |
108 | public boolean contains(BibleBook book) { | |
109 | 0 | int bookNum = book.ordinal(); |
110 | 0 | return bookNum >= BibleBook.GEN.ordinal() && bookNum <= BibleBook.DEUT.ordinal(); |
111 | } | |
112 | ||
113 | @Override | |
114 | public int getSize() { | |
115 | 0 | return 5; |
116 | } | |
117 | ||
118 | @Override | |
119 | public String getName() { | |
120 | // TRANSLATOR: Pentateuch is the first 5 books of the Bible. | |
121 | 0 | return JSMsg.gettext("Pentateuch"); |
122 | } | |
123 | ||
124 | @Override | |
125 | public String getRange() { | |
126 | 0 | return "Gen-Deu"; |
127 | } | |
128 | }, | |
129 | /** HISTORY consists of the history in the Old Testament of Israel */ | |
130 | 0 | HISTORY { |
131 | @Override | |
132 | public boolean contains(BibleBook book) { | |
133 | 0 | int bookNum = book.ordinal(); |
134 | 0 | return bookNum >= BibleBook.JOSH.ordinal() && bookNum <= BibleBook.ESTH.ordinal(); |
135 | } | |
136 | ||
137 | @Override | |
138 | public int getSize() { | |
139 | 0 | return 12; |
140 | } | |
141 | ||
142 | @Override | |
143 | public String getName() { | |
144 | // TRANSLATOR: History are the books of the Old Testament that give the history of Israel | |
145 | 0 | return JSMsg.gettext("History"); |
146 | } | |
147 | ||
148 | @Override | |
149 | public String getRange() { | |
150 | 0 | return "Jos-Est"; |
151 | } | |
152 | }, | |
153 | /** POETRY consists of the poetic works (Job-Song) */ | |
154 | 0 | POETRY { |
155 | @Override | |
156 | public boolean contains(BibleBook book) { | |
157 | 0 | int bookNum = book.ordinal(); |
158 | 0 | return bookNum >= BibleBook.JOB.ordinal() && bookNum <= BibleBook.SONG.ordinal(); |
159 | } | |
160 | ||
161 | @Override | |
162 | public int getSize() { | |
163 | 0 | return 5; |
164 | } | |
165 | ||
166 | @Override | |
167 | public String getName() { | |
168 | // TRANSLATOR: The poetic works of the Bible consisting of: | |
169 | // Job, Psalms, Proverbs, Ecclesiastes, and Song of Solomon | |
170 | 0 | return JSMsg.gettext("Poetry"); |
171 | } | |
172 | ||
173 | @Override | |
174 | public String getRange() { | |
175 | 0 | return "Job-Song"; |
176 | } | |
177 | }, | |
178 | /** PROPHECY consists of the Deu 28, major prophets, minor prophets, Revelation (Isa-Mal, Rev) */ | |
179 | 0 | PROPHECY { |
180 | @Override | |
181 | public boolean contains(BibleBook book) { | |
182 | 0 | int bookNum = book.ordinal(); |
183 | 0 | return bookNum == BibleBook.REV.ordinal() || bookNum >= BibleBook.ISA.ordinal() && bookNum <= BibleBook.MAL.ordinal(); |
184 | } | |
185 | ||
186 | @Override | |
187 | public int getSize() { | |
188 | 0 | return 18; |
189 | } | |
190 | ||
191 | @Override | |
192 | public String getName() { | |
193 | // TRANSLATOR: A division of the Bible containing prophecy: | |
194 | // Deuteronomy 28 | |
195 | // Major Prophets: Isaiah, Jeremiah, Lamentations, Ezekiel, Daniel | |
196 | // Minor Prophets: Hosea, Joel, Amos, Obadiah, Jonah, Micah, Nahum, | |
197 | // Habakkuk, Zephaniah, Haggai, Zechariah, Malachi | |
198 | // Revelation | |
199 | 0 | return JSMsg.gettext("All Prophecy"); |
200 | } | |
201 | ||
202 | @Override | |
203 | public String getRange() { | |
204 | 0 | return "Deu 28,Isa-Mal,Rev"; |
205 | } | |
206 | }, | |
207 | /** MAJOR_PROPHETS consists of the major prophets (Isa-Dan) */ | |
208 | 0 | MAJOR_PROPHETS { |
209 | @Override | |
210 | public boolean contains(BibleBook book) { | |
211 | 0 | int bookNum = book.ordinal(); |
212 | 0 | return bookNum >= BibleBook.ISA.ordinal() && bookNum <= BibleBook.DAN.ordinal(); |
213 | } | |
214 | ||
215 | @Override | |
216 | public int getSize() { | |
217 | 0 | return 5; |
218 | } | |
219 | ||
220 | @Override | |
221 | public String getName() { | |
222 | // TRANSLATOR: A division of the Bible containing the major prophets (Isa-Dan) | |
223 | // Isaiah, Jeremiah, Lamentations, Ezekiel, Daniel | |
224 | 0 | return JSMsg.gettext("Major Prophets"); |
225 | } | |
226 | ||
227 | @Override | |
228 | public String getRange() { | |
229 | 0 | return "Isa-Dan"; |
230 | } | |
231 | }, | |
232 | /** MINOR_PROPHETS consists of the minor prophets (Hos-Mal) */ | |
233 | 0 | MINOR_PROPHETS { |
234 | @Override | |
235 | public boolean contains(BibleBook book) { | |
236 | 0 | int bookNum = book.ordinal(); |
237 | 0 | return bookNum >= BibleBook.HOS.ordinal() && bookNum <= BibleBook.MAL.ordinal(); |
238 | } | |
239 | ||
240 | @Override | |
241 | public int getSize() { | |
242 | 0 | return 12; |
243 | } | |
244 | ||
245 | @Override | |
246 | public String getName() { | |
247 | // TRANSLATOR: A division of the Bible containing the minor prophets (Hos-Mal) | |
248 | // Hosea, Joel, Amos, Obadiah, Jonah, Micah, Nahum, | |
249 | // Habakkuk, Zephaniah, Haggai, Zechariah, Malachi | |
250 | 0 | return JSMsg.gettext("Minor Prophets"); |
251 | } | |
252 | ||
253 | @Override | |
254 | public String getRange() { | |
255 | 0 | return "Hos-Mal"; |
256 | } | |
257 | }, | |
258 | /** NEW_TESTAMENT consists of the new testament (Mat - Rev) **/ | |
259 | 0 | NEW_TESTAMENT { |
260 | @Override | |
261 | public boolean contains(BibleBook book) { | |
262 | 0 | int bookNum = book.ordinal(); |
263 | 0 | return bookNum >= BibleBook.MATT.ordinal() && bookNum <= BibleBook.REV.ordinal(); |
264 | } | |
265 | ||
266 | @Override | |
267 | public int getSize() { | |
268 | 0 | return 27; |
269 | } | |
270 | ||
271 | @Override | |
272 | public String getName() { | |
273 | // TRANSLATOR: The New Testament (Mat - Rev) | |
274 | 0 | return JSMsg.gettext("New Testament"); |
275 | } | |
276 | ||
277 | @Override | |
278 | public String getRange() { | |
279 | 0 | return "Mat-Rev"; |
280 | } | |
281 | }, | |
282 | /** GOSPELS_AND_ACTS consists of the 4 Gospels and Acts (Mat-Acts) */ | |
283 | 0 | GOSPELS_AND_ACTS { |
284 | @Override | |
285 | public boolean contains(BibleBook book) { | |
286 | 0 | int bookNum = book.ordinal(); |
287 | 0 | return bookNum >= BibleBook.MATT.ordinal() && bookNum <= BibleBook.ACTS.ordinal(); |
288 | } | |
289 | ||
290 | @Override | |
291 | public int getSize() { | |
292 | 0 | return 5; |
293 | } | |
294 | ||
295 | @Override | |
296 | public String getName() { | |
297 | // TRANSLATOR: A division of the Bible containing the 4 Gospels and Acts (Mat-Acts) | |
298 | // Matthew, Mark, Luke, John, Acts | |
299 | 0 | return JSMsg.gettext("Gospels and Acts"); |
300 | } | |
301 | ||
302 | @Override | |
303 | public String getRange() { | |
304 | 0 | return "Mat-Acts"; |
305 | } | |
306 | }, | |
307 | /** LETTERS consists of the letters/epistles (Rom-Jud) */ | |
308 | 0 | LETTERS { |
309 | @Override | |
310 | public boolean contains(BibleBook book) { | |
311 | 0 | int bookNum = book.ordinal(); |
312 | 0 | return bookNum >= BibleBook.ROM.ordinal() && bookNum <= BibleBook.JUDE.ordinal(); |
313 | } | |
314 | ||
315 | @Override | |
316 | public int getSize() { | |
317 | 0 | return 21; |
318 | } | |
319 | ||
320 | @Override | |
321 | public String getName() { | |
322 | // TRANSLATOR: A division of the Bible containing the letters/epistles (Rom-Jud) | |
323 | // Pauline: Romans, 1&2 Corinthians, Galatians, Ephesians, Philippians, Colossians, | |
324 | // 1&2 Thessalonians, 1&2 Timothy, Titus, Philemon, Hebrews | |
325 | // General: James, 1-2 Peter, 1-3 John, Jude | |
326 | 0 | return JSMsg.gettext("Letters"); |
327 | } | |
328 | ||
329 | @Override | |
330 | public String getRange() { | |
331 | 0 | return "Rom-Jud"; |
332 | } | |
333 | }, | |
334 | /** LETTERS consists of the Pauline letters/epistles (Rom-Heb) */ | |
335 | 0 | PAULINE_LETTERS { |
336 | @Override | |
337 | public boolean contains(BibleBook book) { | |
338 | 0 | int bookNum = book.ordinal(); |
339 | 0 | return bookNum >= BibleBook.ROM.ordinal() && bookNum <= BibleBook.JUDE.ordinal(); |
340 | } | |
341 | ||
342 | @Override | |
343 | public int getSize() { | |
344 | 0 | return 14; |
345 | } | |
346 | ||
347 | @Override | |
348 | public String getName() { | |
349 | // TRANSLATOR: A division of the Bible containing the Pauline letters/epistles (Rom-Heb) | |
350 | // Romans, 1-2 Corinthians, Galatians, Ephesians, Philippians, Colossians, | |
351 | // 1-2 Thessalonians, 1-2 Timothy, Titus, Philemon, Hebrews | |
352 | 0 | return JSMsg.gettext("Letters to People"); |
353 | } | |
354 | ||
355 | @Override | |
356 | public String getRange() { | |
357 | 0 | return "Rom-Heb"; |
358 | } | |
359 | }, | |
360 | /** LETTERS consists of the general letters/epistles (Jas-Jud) */ | |
361 | 0 | GENERAL_LETTERS { |
362 | @Override | |
363 | public boolean contains(BibleBook book) { | |
364 | 0 | int bookNum = book.ordinal(); |
365 | 0 | return bookNum >= BibleBook.JAS.ordinal() && bookNum <= BibleBook.JUDE.ordinal(); |
366 | } | |
367 | ||
368 | @Override | |
369 | public int getSize() { | |
370 | 0 | return 7; |
371 | } | |
372 | ||
373 | @Override | |
374 | public String getName() { | |
375 | // TRANSLATOR: A division of the Bible containing the general letters/epistles (Jas-Jud) | |
376 | // James, 1-2 Peter, 1-3 John, Jude | |
377 | 0 | return JSMsg.gettext("Letters from People"); |
378 | } | |
379 | ||
380 | @Override | |
381 | public String getRange() { | |
382 | 0 | return "Jas-Jud"; |
383 | } | |
384 | }, | |
385 | /** REVELATION consists of the book of Revelation (Rev) */ | |
386 | 0 | REVELATION { |
387 | @Override | |
388 | public boolean contains(BibleBook book) { | |
389 | 0 | return book == BibleBook.REV; |
390 | } | |
391 | ||
392 | @Override | |
393 | public int getSize() { | |
394 | 0 | return 1; |
395 | } | |
396 | ||
397 | @Override | |
398 | public String getName() { | |
399 | // TRANSLATOR: A division of the Bible containing the book of Revelation (Rev) | |
400 | 0 | return JSMsg.gettext("Revelation"); |
401 | } | |
402 | ||
403 | @Override | |
404 | public String getRange() { | |
405 | 0 | return "Rev"; |
406 | } | |
407 | }; | |
408 | ||
409 | /** | |
410 | * Determine whether the book is contained within the section. | |
411 | * @param book | |
412 | * @return true if the book is contained within the division | |
413 | */ | |
414 | public abstract boolean contains(BibleBook book); | |
415 | ||
416 | /** | |
417 | * Get the number of whole books in the section. | |
418 | * @return the number of whole books in the section | |
419 | */ | |
420 | public abstract int getSize(); | |
421 | ||
422 | /** | |
423 | * Obtain a localized string description of the section. | |
424 | * @return the localized name. | |
425 | */ | |
426 | public abstract String getName(); | |
427 | ||
428 | /** | |
429 | * Obtain a string representation of the scope of the section. | |
430 | * @return the localized name. | |
431 | */ | |
432 | public abstract String getRange(); | |
433 | ||
434 | @Override | |
435 | public String toString() { | |
436 | 0 | return getName(); |
437 | } | |
438 | ||
439 | /** | |
440 | * Determine the section to which this book belongs. | |
441 | * | |
442 | * @param book The book to test | |
443 | * @return the section | |
444 | */ | |
445 | public static DivisionName getSection(BibleBook book) { | |
446 | // Ordered by section size for speed | |
447 | 0 | if (LETTERS.contains(book)) { |
448 | 0 | return LETTERS; |
449 | } | |
450 | ||
451 | 0 | if (HISTORY.contains(book)) { |
452 | 0 | return HISTORY; |
453 | } | |
454 | ||
455 | 0 | if (MINOR_PROPHETS.contains(book)) { |
456 | 0 | return MINOR_PROPHETS; |
457 | } | |
458 | ||
459 | 0 | if (GOSPELS_AND_ACTS.contains(book)) { |
460 | 0 | return GOSPELS_AND_ACTS; |
461 | } | |
462 | ||
463 | 0 | if (PENTATEUCH.contains(book)) { |
464 | 0 | return PENTATEUCH; |
465 | } | |
466 | ||
467 | 0 | if (POETRY.contains(book)) { |
468 | 0 | return POETRY; |
469 | } | |
470 | ||
471 | 0 | if (MAJOR_PROPHETS.contains(book)) { |
472 | 0 | return MAJOR_PROPHETS; |
473 | } | |
474 | ||
475 | // AAV11N(DMS): might not be true | |
476 | 0 | return REVELATION; |
477 | } | |
478 | ||
479 | /** | |
480 | * Handy section finder. There is a bit of moderately bad programming here | |
481 | * because org.crosswire.biblemapper.sw*ng.GroupVerseColor uses these | |
482 | * numbers as an index into an array, so we shouldn't change these numbers | |
483 | * without fixing that, however I don't imagine that this section could ever | |
484 | * change without breaking GroupVerseColor anyway so I don't see it as a big | |
485 | * problem. | |
486 | public static final byte PENTATEUCH = 1; | |
487 | public static final byte HISTORY = 2; | |
488 | public static final byte POETRY = 3; | |
489 | public static final byte MAJOR_PROPHETS = 4; | |
490 | public static final byte MINOR_PROPHETS = 5; | |
491 | public static final byte GOSPELS_AND_ACTS = 6; | |
492 | public static final byte LETTERS = 7; | |
493 | public static final byte REVELATION = 8; | |
494 | */ | |
495 | ||
496 | /** Constant for the number of sections in the Bible | |
497 | private static final int SECTIONS_IN_BIBLE = 8; | |
498 | */ | |
499 | } |