Coverage Report - org.crosswire.jsword.versification.BibleBook
 
Classes in this File Line Coverage Branch Coverage Complexity
BibleBook
0%
0/146
N/A
1
 
 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 java.util.HashMap;
 23  
 import java.util.Locale;
 24  
 import java.util.Map;
 25  
 
 26  
 /**
 27  
  * A BibleBook is a book of the Bible. It may or may not be canonical.
 28  
  * Note that the ordering of these books varies from one Versification to another.
 29  
  *
 30  
  * @see gnu.lgpl.License The GNU Lesser General Public License for details.
 31  
  * @author DM Smith
 32  
  */
 33  0
 public enum BibleBook {
 34  
     // JSword introduction to the Bible
 35  0
     INTRO_BIBLE("Intro.Bible"),
 36  
     // JSword introduction to the Old Testament
 37  0
     INTRO_OT("Intro.OT"),
 38  
     // Old Testament
 39  0
     GEN("Gen"),
 40  0
     EXOD("Exod"),
 41  0
     LEV("Lev"),
 42  0
     NUM("Num"),
 43  0
     DEUT("Deut"),
 44  0
     JOSH("Josh"),
 45  0
     JUDG("Judg"),
 46  0
     RUTH("Ruth"),
 47  0
     SAM1("1Sam"),
 48  0
     SAM2("2Sam"),
 49  0
     KGS1("1Kgs"),
 50  0
     KGS2("2Kgs"),
 51  0
     CHR1("1Chr"),
 52  0
     CHR2("2Chr"),
 53  0
     EZRA("Ezra"),
 54  0
     NEH("Neh"),
 55  0
     ESTH("Esth"),
 56  0
     JOB("Job"),
 57  0
     PS("Ps"),
 58  0
     PROV("Prov"),
 59  0
     ECCL("Eccl"),
 60  0
     SONG("Song"),
 61  0
     ISA("Isa"),
 62  0
     JER("Jer"),
 63  0
     LAM("Lam"),
 64  0
     EZEK("Ezek"),
 65  0
     DAN("Dan"),
 66  0
     HOS("Hos"),
 67  0
     JOEL("Joel"),
 68  0
     AMOS("Amos"),
 69  0
     OBAD("Obad", true),
 70  0
     JONAH("Jonah"),
 71  0
     MIC("Mic"),
 72  0
     NAH("Nah"),
 73  0
     HAB("Hab"),
 74  0
     ZEPH("Zeph"),
 75  0
     HAG("Hag"),
 76  0
     ZECH("Zech"),
 77  0
     MAL("Mal"),
 78  
     // JSword introduction to the New Testament
 79  0
     INTRO_NT("Intro.NT"),
 80  
     // New Testament
 81  0
     MATT("Matt"),
 82  0
     MARK("Mark"),
 83  0
     LUKE("Luke"),
 84  0
     JOHN("John"),
 85  0
     ACTS("Acts"),
 86  0
     ROM("Rom"),
 87  0
     COR1("1Cor"),
 88  0
     COR2("2Cor"),
 89  0
     GAL("Gal"),
 90  0
     EPH("Eph"),
 91  0
     PHIL("Phil"),
 92  0
     COL("Col"),
 93  0
     THESS1("1Thess"),
 94  0
     THESS2("2Thess"),
 95  0
     TIM1("1Tim"),
 96  0
     TIM2("2Tim"),
 97  0
     TITUS("Titus"),
 98  0
     PHLM("Phlm", true),
 99  0
     HEB("Heb"),
 100  0
     JAS("Jas"),
 101  0
     PET1("1Pet"),
 102  0
     PET2("2Pet"),
 103  0
     JOHN1("1John"),
 104  0
     JOHN2("2John", true),
 105  0
     JOHN3("3John", true),
 106  0
     JUDE("Jude", true),
 107  0
     REV("Rev"),
 108  
     // Apocrypha
 109  0
     TOB("Tob"),
 110  0
     JDT("Jdt"),
 111  0
     ADD_ESTH("AddEsth"),
 112  0
     WIS("Wis"),
 113  0
     SIR("Sir"),
 114  0
     BAR("Bar"),
 115  0
     EP_JER("EpJer", true),
 116  0
     PR_AZAR("PrAzar"),
 117  0
     SUS("Sus"),
 118  0
     BEL("Bel"),
 119  0
     MACC1("1Macc"),
 120  0
     MACC2("2Macc"),
 121  0
     MACC3("3Macc"),
 122  0
     MACC4("4Macc"),
 123  0
     PR_MAN("PrMan", true),
 124  0
     ESD1("1Esd"),
 125  0
     ESD2("2Esd"),
 126  0
     PSS151("Ps151"),
 127  
     // Rahlfs' LXX
 128  0
     ODES("Odes"),
 129  0
     PSALM_SOL("PssSol"),
 130  
     // Vulgate & other later Latin mss
 131  0
     EP_LAO("EpLao"),
 132  0
     ESD3("3Esd"),
 133  0
     ESD4("4Esd"),
 134  0
     ESD5("5Esd"),
 135  
     // Ethiopian Orthodox Canon/Ge'ez Translation
 136  0
     EN1("1En"),
 137  0
     JUBS("Jub"),
 138  0
     BAR4("4Bar"),
 139  0
     ASCEN_ISA("AscenIsa"),
 140  0
     PS_JOS("PsJos"),
 141  
     // Coptic Orthodox Canon
 142  0
     APOSTOLIC("AposCon"),
 143  0
     CLEM1("1Clem"),
 144  0
     CLEM2("2Clem"),
 145  
     // Armenian Orthodox Canon
 146  0
     COR3("3Cor"),
 147  0
     EP_COR_PAUL("EpCorPaul"),
 148  0
     JOS_ASEN("JosAsen"),
 149  0
     T12PATR("T12Patr"),
 150  0
     T12PATR_TASH("T12Patr.TAsh"),
 151  0
     T12PATR_TBENJ("T12Patr.TBenj"),
 152  0
     T12PATR_TDAN("T12Patr.TDan"),
 153  0
     T12PATR_GAD("T12Patr.TGad"),
 154  0
     T12PATR_TISS("T12Patr.TIss"),
 155  0
     T12PATR_TJOS("T12Patr.TJos"),
 156  0
     T12PATR_TJUD("T12Patr.TJud"),
 157  0
     T12PATR_TLEVI("T12Patr.TLevi"),
 158  0
     T12PATR_TNAPH("T12Patr.TNaph"),
 159  0
     T12PATR_TREU("T12Patr.TReu"),
 160  0
     T12PATR_TSIM("T12Patr.TSim"),
 161  0
     T12PATR_TZeb("T12Patr.TZeb"),
 162  
     // Peshitta
 163  0
     BAR2("2Bar"),
 164  0
     EP_BAR("EpBar"),
 165  
     // Codex Sinaiticus
 166  0
     BARN("Barn"),
 167  0
     HERM("Herm"),
 168  0
     HERM_MAND("Herm.Mand"),
 169  0
     HERM_SIM("Herm.Sim"),
 170  0
     HERM_VIS("Herm.Vis"),
 171  
     // Other books
 172  0
     ADD_DAN("AddDan"),
 173  0
     ADD_PS("AddPs"),
 174  0
     ESTH_GR("EsthGr");
 175  
 
 176  
     BibleBook(String osis, boolean shortBook) {
 177  0
         this(osis);
 178  0
         this.isShortBook = shortBook;
 179  0
     }
 180  
 
 181  0
     BibleBook(String osis) {
 182  0
         this.osis = osis;
 183  0
     }
 184  
 
 185  
     /**
 186  
      * Get the OSIS representation of this BibleBook.
 187  
      *
 188  
      * @return the OSIS name
 189  
      */
 190  
     public String getOSIS() {
 191  0
         return osis;
 192  
     }
 193  
 
 194  
     /**
 195  
      * Get the OSIS representation of this BibleBook.
 196  
      *
 197  
      * @return the OSIS name
 198  
      */
 199  
     @Override
 200  
     public String toString() {
 201  0
         return osis;
 202  
     }
 203  
 
 204  
     /**
 205  
      * Case insensitive search for BibleBook for an OSIS name.
 206  
      *
 207  
      * @param osis
 208  
      * @return the matching BibleBook or null
 209  
      */
 210  
     public static BibleBook fromOSIS(String osis) {
 211  0
         String match = BookName.normalize(osis, Locale.ENGLISH);
 212  0
         return osisMap.get(match);
 213  
     }
 214  
 
 215  
     /**
 216  
      * @param osis the osis book reference, case sensitive
 217  
      * @return the corresponding BibleBook
 218  
      */
 219  
     public static BibleBook fromExactOSIS(String osis) {
 220  0
         return exactMatches.get(osis);
 221  
     }
 222  
 
 223  
     /**
 224  
      * @return true to indicate a 1-chapter book only
 225  
      */
 226  
     public boolean isShortBook() {
 227  0
         return isShortBook;
 228  
     }
 229  
 
 230  
     /**
 231  
      * The OSIS name for the book. 
 232  
      */
 233  
     private String osis;
 234  
 
 235  
     /**
 236  
      * Indicates that the book consists of a single chapter.
 237  
      */
 238  
     private boolean isShortBook;
 239  
 
 240  
     /** A quick lookup based on OSIS name for the book */
 241  0
     private static Map<String, BibleBook> osisMap = new HashMap<String, BibleBook>(128);
 242  0
     private static Map<String, BibleBook> exactMatches = new HashMap<String, BibleBook>(128);
 243  
 
 244  
      static {
 245  0
         for (BibleBook book : BibleBook.values()) {
 246  0
             osisMap.put(BookName.normalize(book.getOSIS(), Locale.ENGLISH), book);
 247  0
             exactMatches.put(book.getOSIS(), book);
 248  
         }
 249  0
     }
 250  
 
 251  
 }