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