[jsword-svn] r1138 - trunk/jsword/src/main/java/org/crosswire/jsword/versification
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Sat Sep 30 20:26:40 MST 2006
Author: dmsmith
Date: 2006-09-30 20:26:33 -0700 (Sat, 30 Sep 2006)
New Revision: 1138
Added:
trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleNames.properties
trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleNames_de.properties
trunk/jsword/src/main/java/org/crosswire/jsword/versification/SectionNames.java
Removed:
trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.properties
trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo_de.properties
Modified:
trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.java
trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleNames.java
Log:
refactoring
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.java 2006-10-01 02:48:59 UTC (rev 1137)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.java 2006-10-01 03:26:33 UTC (rev 1138)
@@ -163,7 +163,7 @@
*/
public static String getOSISName(int book) throws NoSuchVerseException
{
- return bibleNames.getOSISName(book);
+ return OSISNames.getName(book);
}
/**
@@ -174,18 +174,20 @@
public static int getBookNumber(String find)
{
int bookNum = -1;
- if (!containsLetter(find))
+ if (containsLetter(find))
{
- return bookNum;
- }
+ bookNum = OSISNames.getBookNumber(find);
- bookNum = bibleNames.getBookNumber(find);
+ if (bookNum == -1)
+ {
+ bookNum = bibleNames.getBookNumber(find);
+ }
- if (bookNum == -1 && englishBibleNames != null)
- {
- bookNum = englishBibleNames.getBookNumber(find);
+ if (bookNum == -1 && englishBibleNames != null)
+ {
+ bookNum = englishBibleNames.getBookNumber(find);
+ }
}
-
return bookNum;
}
@@ -463,7 +465,7 @@
// If they are too big
if (ref[BOOK] > BOOKS_IN_BIBLE)
{
- ref[BOOK] = BibleNames.Names.REVELATION;
+ ref[BOOK] = BibleNames.REVELATION;
ref[CHAPTER] = chaptersInBook(ref[BOOK]);
ref[VERSE] = versesInChapter(ref[BOOK], ref[CHAPTER]);
return ref;
@@ -476,7 +478,7 @@
if (ref[BOOK] > BOOKS_IN_BIBLE)
{
- ref[BOOK] = BibleNames.Names.REVELATION;
+ ref[BOOK] = BibleNames.REVELATION;
ref[CHAPTER] = chaptersInBook(ref[BOOK]);
ref[VERSE] = versesInChapter(ref[BOOK], ref[CHAPTER]);
return ref;
@@ -495,7 +497,7 @@
if (ref[BOOK] > BOOKS_IN_BIBLE)
{
- ref[BOOK] = BibleNames.Names.REVELATION;
+ ref[BOOK] = BibleNames.REVELATION;
ref[CHAPTER] = chaptersInBook(ref[BOOK]);
ref[VERSE] = versesInChapter(ref[BOOK], ref[CHAPTER]);
return ref;
@@ -568,7 +570,7 @@
*/
public static String getSectionName(int section) throws NoSuchVerseException
{
- return bibleNames.getSectionName(section);
+ return sectionNames.getSectionName(section);
}
/**
@@ -596,12 +598,15 @@
{
Locale locale = Locale.getDefault();
bibleNames = new BibleNames(locale);
+
// If the locale is not the program's default get it for alternates
Locale englishLocale = new Locale("en"); //$NON-NLS-1$
if (!locale.getLanguage().equals(englishLocale.getLanguage()))
{
englishBibleNames = new BibleNames(englishLocale);
}
+
+ sectionNames = new SectionNames();
}
/** Localized BibleNames */
@@ -610,6 +615,9 @@
/** English BibleNames, or null when using the program's default locale */
private static BibleNames englishBibleNames;
+ /** Localized Bible SectionNames */
+ private static SectionNames sectionNames;
+
/**
* How the book names are reported.
*/
Deleted: trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.properties
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.properties 2006-10-01 02:48:59 UTC (rev 1137)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.properties 2006-10-01 03:26:33 UTC (rev 1138)
@@ -1,206 +0,0 @@
-BibleInfo.Full.1=Genesis
-BibleInfo.Short.1=Gen
-BibleInfo.Alt.1=
-BibleInfo.Full.2=Exodus
-BibleInfo.Short.2=Exo
-BibleInfo.Alt.2=
-BibleInfo.Full.3=Leviticus
-BibleInfo.Short.3=Lev
-BibleInfo.Alt.3=
-BibleInfo.Full.4=Numbers
-BibleInfo.Short.4=Num
-BibleInfo.Alt.4=
-BibleInfo.Full.5=Deuteronomy
-BibleInfo.Short.5=Deu
-BibleInfo.Alt.5=dt
-BibleInfo.Full.6=Joshua
-BibleInfo.Short.6=Jos
-BibleInfo.Alt.6=
-BibleInfo.Full.7=Judges
-BibleInfo.Short.7=Judg
-BibleInfo.Alt.7=jdg
-BibleInfo.Full.8=Ruth
-BibleInfo.Short.8=Rut
-BibleInfo.Alt.8=rth
-BibleInfo.Full.9=1 Samuel
-BibleInfo.Short.9=1Sa
-BibleInfo.Alt.9=
-BibleInfo.Full.10=2 Samuel
-BibleInfo.Short.10=2Sa
-BibleInfo.Alt.10=
-BibleInfo.Full.11=1 Kings
-BibleInfo.Short.11=1Ki
-BibleInfo.Alt.11=
-BibleInfo.Full.12=2 Kings
-BibleInfo.Short.12=2Ki
-BibleInfo.Alt.12=
-BibleInfo.Full.13=1 Chronicles
-BibleInfo.Short.13=1Ch
-BibleInfo.Alt.13=
-BibleInfo.Full.14=2 Chronicles
-BibleInfo.Short.14=2Ch
-BibleInfo.Alt.14=
-BibleInfo.Full.15=Ezra
-BibleInfo.Short.15=Ezr
-BibleInfo.Alt.15=
-BibleInfo.Full.16=Nehemiah
-BibleInfo.Short.16=Neh
-BibleInfo.Alt.16=
-BibleInfo.Full.17=Esther
-BibleInfo.Short.17=Est
-BibleInfo.Alt.17=
-BibleInfo.Full.18=Job
-BibleInfo.Short.18=Job
-BibleInfo.Alt.18=
-BibleInfo.Full.19=Psalms
-BibleInfo.Short.19=Psa
-BibleInfo.Alt.19=pss
-BibleInfo.Full.20=Proverbs
-BibleInfo.Short.20=Pro
-BibleInfo.Alt.20=
-BibleInfo.Full.21=Ecclesiastes
-BibleInfo.Short.21=Ecc
-BibleInfo.Alt.21=qoh
-BibleInfo.Full.22=Song of Solomon
-BibleInfo.Short.22=Song
-BibleInfo.Alt.22=ss,canticle,can
-BibleInfo.Full.23=Isaiah
-BibleInfo.Short.23=Isa
-BibleInfo.Alt.23=
-BibleInfo.Full.24=Jeremiah
-BibleInfo.Short.24=Jer
-BibleInfo.Alt.24=
-BibleInfo.Full.25=Lamentations
-BibleInfo.Short.25=Lam
-BibleInfo.Alt.25=
-BibleInfo.Full.26=Ezekiel
-BibleInfo.Short.26=Eze
-BibleInfo.Alt.26=
-BibleInfo.Full.27=Daniel
-BibleInfo.Short.27=Dan
-BibleInfo.Alt.27=
-BibleInfo.Full.28=Hosea
-BibleInfo.Short.28=Hos
-BibleInfo.Alt.28=
-BibleInfo.Full.29=Joel
-BibleInfo.Short.29=Joe
-BibleInfo.Alt.29=
-BibleInfo.Full.30=Amos
-BibleInfo.Short.30=Amo
-BibleInfo.Alt.30=
-BibleInfo.Full.31=Obadiah
-BibleInfo.Short.31=Obd
-BibleInfo.Alt.31=
-BibleInfo.Full.32=Jonah
-BibleInfo.Short.32=Jon
-BibleInfo.Alt.32=jnh
-BibleInfo.Full.33=Micah
-BibleInfo.Short.33=Mic
-BibleInfo.Alt.33=
-BibleInfo.Full.34=Nahum
-BibleInfo.Short.34=Nah
-BibleInfo.Alt.34=
-BibleInfo.Full.35=Habakuk
-BibleInfo.Short.35=Hab
-BibleInfo.Alt.35=
-BibleInfo.Full.36=Zephaniah
-BibleInfo.Short.36=Zep
-BibleInfo.Alt.36=
-BibleInfo.Full.37=Haggai
-BibleInfo.Short.37=Hag
-BibleInfo.Alt.37=
-BibleInfo.Full.38=Zechariah
-BibleInfo.Short.38=Zec
-BibleInfo.Alt.38=
-BibleInfo.Full.39=Malachi
-BibleInfo.Short.39=Mal
-BibleInfo.Alt.39=
-BibleInfo.Full.40=Matthew
-BibleInfo.Short.40=Mat
-BibleInfo.Alt.40=mt
-BibleInfo.Full.41=Mark
-BibleInfo.Short.41=Mar
-BibleInfo.Alt.41=mk,mrk
-BibleInfo.Full.42=Luke
-BibleInfo.Short.42=Luk
-BibleInfo.Alt.42=lk
-BibleInfo.Full.43=John
-BibleInfo.Short.43=Joh
-BibleInfo.Alt.43=jn,jhn
-BibleInfo.Full.44=Acts
-BibleInfo.Short.44=Act
-BibleInfo.Alt.44=
-BibleInfo.Full.45=Romans
-BibleInfo.Short.45=Rom
-BibleInfo.Alt.45=
-BibleInfo.Full.46=1 Corinthians
-BibleInfo.Short.46=1Cor
-BibleInfo.Alt.46=
-BibleInfo.Full.47=2 Corinthians
-BibleInfo.Short.47=2Cor
-BibleInfo.Alt.47=
-BibleInfo.Full.48=Galatians
-BibleInfo.Short.48=Gal
-BibleInfo.Alt.48=
-BibleInfo.Full.49=Ephesians
-BibleInfo.Short.49=Eph
-BibleInfo.Alt.49=
-BibleInfo.Full.50=Philippians
-BibleInfo.Short.50=Phili
-BibleInfo.Alt.50=php
-BibleInfo.Full.51=Colossians
-BibleInfo.Short.51=Col
-BibleInfo.Alt.51=
-BibleInfo.Full.52=1 Thessalonians
-BibleInfo.Short.52=1Th
-BibleInfo.Alt.52=
-BibleInfo.Full.53=2 Thessalonians
-BibleInfo.Short.53=2Th
-BibleInfo.Alt.53=
-BibleInfo.Full.54=1 Timothy
-BibleInfo.Short.54=1Ti
-BibleInfo.Alt.54=1tm
-BibleInfo.Full.55=2 Timothy
-BibleInfo.Short.55=2Ti
-BibleInfo.Alt.55=2tm
-BibleInfo.Full.56=Titus
-BibleInfo.Short.56=Tit
-BibleInfo.Alt.56=
-BibleInfo.Full.57=Philemon
-BibleInfo.Short.57=Phile
-BibleInfo.Alt.57=phm
-BibleInfo.Full.58=Hebrews
-BibleInfo.Short.58=Heb
-BibleInfo.Alt.58=
-BibleInfo.Full.59=James
-BibleInfo.Short.59=Jam
-BibleInfo.Alt.59=jas
-BibleInfo.Full.60=1 Peter
-BibleInfo.Short.60=1Pe
-BibleInfo.Alt.60=1pt
-BibleInfo.Full.61=2 Peter
-BibleInfo.Short.61=2Pe
-BibleInfo.Alt.61=2pt
-BibleInfo.Full.62=1 John
-BibleInfo.Short.62=1Jo
-BibleInfo.Alt.62=1jn,1jhn
-BibleInfo.Full.63=2 John
-BibleInfo.Short.63=2Jo
-BibleInfo.Alt.63=2jn,2jhn
-BibleInfo.Full.64=3 John
-BibleInfo.Short.64=3Jo
-BibleInfo.Alt.64=3jn,3jhn
-BibleInfo.Full.65=Jude
-BibleInfo.Short.65=Jude
-BibleInfo.Alt.65=jud
-BibleInfo.Full.66=Revelation of John
-BibleInfo.Short.66=Rev
-BibleInfo.Alt.66=Rv
-BibleInfo.Sections.1=Pentateuch
-BibleInfo.Sections.2=History
-BibleInfo.Sections.3=Poetry
-BibleInfo.Sections.4=MajorProphets
-BibleInfo.Sections.5=MinorProphets
-BibleInfo.Sections.6=Gospels And Acts
-BibleInfo.Sections.7=Letters
-BibleInfo.Sections.8=Revelation
Deleted: trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo_de.properties
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo_de.properties 2006-10-01 02:48:59 UTC (rev 1137)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo_de.properties 2006-10-01 03:26:33 UTC (rev 1138)
@@ -1,198 +0,0 @@
-BibleInfo.Full.1=1. Mose
-BibleInfo.Short.1=1Mo
-BibleInfo.Alt.1=
-BibleInfo.Full.2=2. Mose
-BibleInfo.Short.2=2Mo
-BibleInfo.Alt.2=
-BibleInfo.Full.3=3. Mose
-BibleInfo.Short.3=3Mo
-BibleInfo.Alt.3=
-BibleInfo.Full.4=4. Mose
-BibleInfo.Short.4=4Mo
-BibleInfo.Alt.4=
-BibleInfo.Full.5=5. Mose
-BibleInfo.Short.5=5Mo
-BibleInfo.Alt.5=
-BibleInfo.Full.6=Josua
-BibleInfo.Short.6=Jos
-BibleInfo.Alt.6=
-BibleInfo.Full.7=Richter
-BibleInfo.Short.7=Ri
-BibleInfo.Alt.7=
-BibleInfo.Full.8=Rut
-BibleInfo.Short.8=Rut
-BibleInfo.Alt.8=
-BibleInfo.Full.9=1. Samuel
-BibleInfo.Short.9=1Sam
-BibleInfo.Alt.9=
-BibleInfo.Full.10=2. Samuel
-BibleInfo.Short.10=2Sam
-BibleInfo.Alt.10=
-BibleInfo.Full.11=1. K\u00f6nige
-BibleInfo.Short.11=1K\u00f6n
-BibleInfo.Alt.11=
-BibleInfo.Full.12=2. K\u00f6nige
-BibleInfo.Short.12=2K\u00f6n
-BibleInfo.Alt.12=
-BibleInfo.Full.13=1. Chronik
-BibleInfo.Short.13=1Chr
-BibleInfo.Alt.13=
-BibleInfo.Full.14=2. Chronik
-BibleInfo.Short.14=2Chr
-BibleInfo.Alt.14=
-BibleInfo.Full.15=Esra
-BibleInfo.Short.15=Esra
-BibleInfo.Alt.15=
-BibleInfo.Full.16=Nehemia
-BibleInfo.Short.16=Neh
-BibleInfo.Alt.16=
-BibleInfo.Full.17=Ester
-BibleInfo.Short.17=Est
-BibleInfo.Alt.17=
-BibleInfo.Full.18=Hiob
-BibleInfo.Short.18=Hiob
-BibleInfo.Alt.18=
-BibleInfo.Full.19=Psalmen
-BibleInfo.Short.19=Ps
-BibleInfo.Alt.19=
-BibleInfo.Full.20=Spr\u00fcche
-BibleInfo.Short.20=Spr
-BibleInfo.Alt.20=
-BibleInfo.Full.21=Prediger
-BibleInfo.Short.21=Pred
-BibleInfo.Alt.21=
-BibleInfo.Full.22=Hoheslied
-BibleInfo.Short.22=Hld
-BibleInfo.Alt.22=
-BibleInfo.Full.23=Jesaja
-BibleInfo.Short.23=Jes
-BibleInfo.Alt.23=
-BibleInfo.Full.24=Jeremia
-BibleInfo.Short.24=Jer
-BibleInfo.Alt.24=
-BibleInfo.Full.25=Klagelieder
-BibleInfo.Short.25=Klgl
-BibleInfo.Alt.25=
-BibleInfo.Full.26=Hesekiel
-BibleInfo.Short.26=Hes
-BibleInfo.Alt.26=
-BibleInfo.Full.27=Daniel
-BibleInfo.Short.27=Dan
-BibleInfo.Alt.27=
-BibleInfo.Full.28=Hosea
-BibleInfo.Short.28=Hos
-BibleInfo.Alt.28=
-BibleInfo.Full.29=Joel
-BibleInfo.Short.29=Joel
-BibleInfo.Alt.29=
-BibleInfo.Full.30=Amos
-BibleInfo.Short.30=Am
-BibleInfo.Alt.30=
-BibleInfo.Full.31=Obadja
-BibleInfo.Short.31=Obd
-BibleInfo.Alt.31=
-BibleInfo.Full.32=Jona
-BibleInfo.Short.32=Jona
-BibleInfo.Alt.32=
-BibleInfo.Full.33=Micha
-BibleInfo.Short.33=Mi
-BibleInfo.Alt.33=
-BibleInfo.Full.34=Nahum
-BibleInfo.Short.34=Nah
-BibleInfo.Alt.34=
-BibleInfo.Full.35=Habakuk
-BibleInfo.Short.35=Hab
-BibleInfo.Alt.35=
-BibleInfo.Full.36=Zefanja
-BibleInfo.Short.36=Zef
-BibleInfo.Alt.36=
-BibleInfo.Full.37=Haggai
-BibleInfo.Short.37=Hag
-BibleInfo.Alt.37=
-BibleInfo.Full.38=Sacharja
-BibleInfo.Short.38=Sach
-BibleInfo.Alt.38=
-BibleInfo.Full.39=Maleachi
-BibleInfo.Short.39=Mal
-BibleInfo.Alt.39=
-BibleInfo.Full.40=Matth\u00e4us
-BibleInfo.Short.40=Mt
-BibleInfo.Alt.40=
-BibleInfo.Full.41=Markus
-BibleInfo.Short.41=Mk
-BibleInfo.Alt.41=
-BibleInfo.Full.42=Lukas
-BibleInfo.Short.42=Lk
-BibleInfo.Alt.42=
-BibleInfo.Full.43=Johannes
-BibleInfo.Short.43=Joh
-BibleInfo.Alt.43=
-BibleInfo.Full.44=Apostelgeschichte
-BibleInfo.Short.44=Apg
-BibleInfo.Alt.44=
-BibleInfo.Full.45=R\u00f6mer
-BibleInfo.Short.45=R\u00f6m
-BibleInfo.Alt.45=
-BibleInfo.Full.46=1. Korinther
-BibleInfo.Short.46=1Kor
-BibleInfo.Alt.46=
-BibleInfo.Full.47=2. Korinther
-BibleInfo.Short.47=2Kor
-BibleInfo.Alt.47=
-BibleInfo.Full.48=Galater
-BibleInfo.Short.48=Gal
-BibleInfo.Alt.48=
-BibleInfo.Full.49=Epheser
-BibleInfo.Short.49=Eph
-BibleInfo.Alt.49=
-BibleInfo.Full.50=Philipper
-BibleInfo.Short.50=Phil
-BibleInfo.Alt.50=
-BibleInfo.Full.51=Kolosser
-BibleInfo.Short.51=Kol
-BibleInfo.Alt.51=
-BibleInfo.Full.52=1. Thessalonicher
-BibleInfo.Short.52=1Thess
-BibleInfo.Alt.52=
-BibleInfo.Full.53=2. Thessalonicher
-BibleInfo.Short.53=2Thess
-BibleInfo.Alt.53=
-BibleInfo.Full.54=1. Timotheus
-BibleInfo.Short.54=1Tim
-BibleInfo.Alt.54=
-BibleInfo.Full.55=2. Timotheus
-BibleInfo.Short.55=2Tim
-BibleInfo.Alt.55=
-BibleInfo.Full.56=Titus
-BibleInfo.Short.56=Tit
-BibleInfo.Alt.56=
-BibleInfo.Full.57=Philemon
-BibleInfo.Short.57=Phlm
-BibleInfo.Alt.57=
-BibleInfo.Full.58=Hebr\u00e4er
-BibleInfo.Short.58=Heb
-BibleInfo.Alt.58=
-BibleInfo.Full.59=Jakobus
-BibleInfo.Short.59=Jak
-BibleInfo.Alt.59=
-BibleInfo.Full.60=1. Petrus
-BibleInfo.Short.60=1Pet
-BibleInfo.Alt.60=
-BibleInfo.Full.61=2. Petrus
-BibleInfo.Short.61=2Pet
-BibleInfo.Alt.61=
-BibleInfo.Full.62=1. Johannes
-BibleInfo.Short.62=1Joh
-BibleInfo.Alt.62=
-BibleInfo.Full.63=2. Johannes
-BibleInfo.Short.63=2Joh
-BibleInfo.Alt.63=
-BibleInfo.Full.64=3. Johannes
-BibleInfo.Short.64=3Joh
-BibleInfo.Alt.64=
-BibleInfo.Full.65=Judas
-BibleInfo.Short.65=Jud
-BibleInfo.Alt.65=
-BibleInfo.Full.66=Offenbarung
-BibleInfo.Short.66=Offb
-BibleInfo.Alt.66=Apc
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleNames.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleNames.java 2006-10-01 02:48:59 UTC (rev 1137)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleNames.java 2006-10-01 03:26:33 UTC (rev 1138)
@@ -138,27 +138,6 @@
}
/**
- * Get the OSIS name for a book.
- * @param book The book number (1-66)
- * @return the OSIS defined short name for a book
- * @exception NoSuchVerseException If the book number is not valid
- */
- public String getOSISName(int book) throws NoSuchVerseException
- {
- try
- {
- return osisBooks[book - 1];
- }
- catch (ArrayIndexOutOfBoundsException ex)
- {
- // This is faster than doing the check explicitly, unless
- // The exception is actually thrown, then it is a lot slower
- // I'd like to think that the norm is to get it right
- throw new NoSuchVerseException(Msg.BOOKS_BOOK, new Object[] { new Integer(book) });
- }
- }
-
- /**
* Get number of a book from its name.
* @param find The string to identify
* @return The book number (1 to 66) On error -1
@@ -167,19 +146,12 @@
{
String match = normalize(find);
- // Favor OSIS names.
- Integer bookNum = (Integer) osisMap.get(match);
+ Integer bookNum = (Integer) fullBooksMap.get(match);
if (bookNum != null)
{
return bookNum.intValue();
}
- bookNum = (Integer) fullBooksMap.get(match);
- if (bookNum != null)
- {
- return bookNum.intValue();
- }
-
bookNum = (Integer) shortBooksMap.get(match);
if (bookNum != null)
{
@@ -236,172 +208,6 @@
}
/**
- * Is this book part of the Pentateuch?
- * @param book The book to test
- * @return True if this book is a part of this section
- */
- public static boolean isPentateuch(int book)
- {
- return book >= Names.GENESIS && book <= Names.DEUTERONOMY;
- }
-
- /**
- * Is this book part of the OT History?
- * @param book The book to test
- * @return True if this book is a part of this section
- */
- public static boolean isHistory(int book)
- {
- return book >= Names.JOSHUA && book <= Names.ESTHER;
- }
-
- /**
- * Is this book part of the OT History?
- * @param book The book to test
- * @return True if this book is a part of this section
- */
- public static boolean isPoetry(int book)
- {
- return book >= Names.JOB && book <= Names.SONGOFSOLOMON;
- }
-
- /**
- * Is this book part of the major prophets?
- * @param book The book to test
- * @return True if this book is a part of this section
- */
- public static boolean isMajorProphet(int book)
- {
- return book >= Names.ISAIAH && book <= Names.DANIEL;
- }
-
- /**
- * Is this book part of the minor prophets?
- * @param book The book to test
- * @return True if this book is a part of this section
- */
- public static boolean isMinorProphet(int book)
- {
- return book >= Names.HOSEA && book <= Names.MALACHI;
- }
-
- /**
- * Is this book part of the Gospels?
- * @param book The book to test
- * @return True if this book is a part of this section
- */
- public static boolean isGospel(int book)
- {
- return book >= Names.MATTHEW && book <= Names.JOHN;
- }
-
- /**
- * Is this book part of the Gospels or Acts?
- * @param book The book to test
- * @return True if this book is a part of this section
- */
- public static boolean isGospelOrActs(int book)
- {
- return book >= Names.MATTHEW && book <= Names.ACTS;
- }
-
- /**
- * Is this book part of the letters?
- * @param book The book to test
- * @return True if this book is a part of this section
- */
- public static boolean isLetter(int book)
- {
- return book >= Names.ROMANS && book <= Names.JUDE;
- }
-
- /**
- * What section is this book a part of?
- * @param book The book to test
- * @return True The section
- * @see BibleNames.Section
- */
- public static int getSection(int book)
- {
- // Ordered by section size for speed
- if (isLetter(book))
- {
- return Section.LETTERS;
- }
-
- if (isHistory(book))
- {
- return Section.HISTORY;
- }
-
- if (isMinorProphet(book))
- {
- return Section.MINOR_PROPHETS;
- }
-
- if (isGospelOrActs(book))
- {
- return Section.GOSPELS_AND_ACTS;
- }
-
- if (isPentateuch(book))
- {
- return Section.PENTATEUCH;
- }
-
- if (isPoetry(book))
- {
- return Section.POETRY;
- }
-
- if (isMajorProphet(book))
- {
- return Section.MAJOR_PROPHETS;
- }
-
- return Section.REVELATION;
- }
-
- /**
- * Get the full name of a book (e.g. "Genesis").
- * Altered by the case setting (see setBookCase())
- * @param section The book number (1-66)
- * @return The full name of the book
- * @exception NoSuchVerseException If the book number is not valid
- */
- public String getSectionName(int section) throws NoSuchVerseException
- {
- if (section == 0)
- {
- throw new NoSuchVerseException(Msg.BOOKS_SECTION, new Object[] { new Integer(section)});
- }
-
- try
- {
- CaseType bookCase = BibleInfo.getDefaultCase();
-
- if (bookCase.equals(CaseType.LOWER))
- {
- return sections[section - 1].toLowerCase();
- }
-
- if (bookCase.equals(CaseType.UPPER))
- {
- return sections[section - 1].toUpperCase();
- }
-
- return sections[section - 1];
- }
- catch (ArrayIndexOutOfBoundsException ex)
- {
- // This is faster than doing the check explicitly, unless
- // The exception is actually thrown, then it is a lot slower
- // I'd like to think that the norm is to get it right
- throw new NoSuchVerseException(Msg.BOOKS_SECTION, new Object[] { new Integer(section) });
- }
- }
-
- /**
* Normalize by stripping punctuation and whitespace.
* @param str the string to normalize
* @return the normalized string
@@ -431,9 +237,9 @@
altBooks = new String[booksInBible][];
altBooksMap = new HashMap(booksInBible);
- ResourceBundle resources = ResourceBundle.getBundle(BibleInfo.class.getName(), locale, new CWClassLoader(BibleInfo.class));
+ ResourceBundle resources = ResourceBundle.getBundle(BibleNames.class.getName(), locale, new CWClassLoader(BibleNames.class));
- for (int i = 0; i < booksInBible; i++)
+ for (int i = 0; i < booksInBible; i++ )
{
Integer bookNum = new Integer(i + 1);
String fullBook = getString(resources, FULL_KEY + (i + 1));
@@ -449,37 +255,14 @@
shortBooksMap.put(normalized, bookNum);
String altBook = getString(resources, ALT_KEY + (i + 1));
- String [] alternates = StringUtil.split(altBook, ',');
+ String[] alternates = StringUtil.split(altBook, ',');
altBooks[i] = alternates;
- for (int j = 0; j < alternates.length; j++)
+ for (int j = 0; j < alternates.length; j++ )
{
altBooksMap.put(alternates[j], bookNum);
}
}
-
- sections = new String[SECTIONS_IN_BIBLE];
-
- for (int i = 0; i < SECTIONS_IN_BIBLE; i++)
- {
- String section = getString(resources, SECTION_KEY + (i + 1));
- sections[i] = section;
- }
-
- if (osisBooks == null)
- {
- osisBooks = new String[booksInBible];
- osisMap = new HashMap(booksInBible);
-
- // Get all the OSIS standard book names
- resources = ResourceBundle.getBundle(OSIS_PROPERTIES, Locale.getDefault(), new CWClassLoader(BibleInfo.class));
-
- for (int i = 0; i < osisBooks.length; i++)
- {
- osisBooks[i] = getString(resources, OSIS_KEY + (i + 1));
- osisMap.put(normalize(osisBooks[i]), new Integer(i + 1));
- }
- }
}
/*
@@ -498,145 +281,118 @@
return null;
}
- private static final String FULL_KEY = "BibleNames.Full."; //$NON-NLS-1$
- private static final String SHORT_KEY = "BibleNames.Short."; //$NON-NLS-1$
- private static final String ALT_KEY = "BibleNames.Alt."; //$NON-NLS-1$
- private static final String SECTION_KEY = "BibleNames.Sections."; //$NON-NLS-1$
- private static final String OSIS_KEY = "BibleNames.OSIS."; //$NON-NLS-1$
- private static final String OSIS_PROPERTIES = "OSISNames"; //$NON-NLS-1$
+ private static final String FULL_KEY = "BibleNames.Full."; //$NON-NLS-1$
+ private static final String SHORT_KEY = "BibleNames.Short."; //$NON-NLS-1$
+ private static final String ALT_KEY = "BibleNames.Alt."; //$NON-NLS-1$
/**
- * Handy section finder. There is a bit of moderately bad programming
- * here because org.crosswire.jsword.control.map.sw*ng.GroupVerseColor
- * uses these numbers as an index into an array, so we shouldn't
- * change these numbers without fixing that, however I don't imagine
- * that this section could ever change without breaking
- * GroupVerseColor anyway so I don't see it as a big problem.
- */
- public static class Section
- {
- public static final byte PENTATEUCH = 1;
- public static final byte HISTORY = 2;
- public static final byte POETRY = 3;
- public static final byte MAJOR_PROPHETS = 4;
- public static final byte MINOR_PROPHETS = 5;
- public static final byte GOSPELS_AND_ACTS = 6;
- public static final byte LETTERS = 7;
- public static final byte REVELATION = 8;
- }
-
- /**
* Handy book finder
*/
- public static class Names
- {
- public static final byte GENESIS = 1;
- public static final byte EXODUS = 2;
- public static final byte LEVITICUS = 3;
- public static final byte NUMBERS = 4;
- public static final byte DEUTERONOMY = 5;
- public static final byte JOSHUA = 6;
- public static final byte JUDGES = 7;
- public static final byte RUTH = 8;
- public static final byte SAMUEL1 = 9;
- public static final byte SAMUEL2 = 10;
- public static final byte KINGS1 = 11;
- public static final byte KINGS2 = 12;
- public static final byte CHRONICLES1 = 13;
- public static final byte CHRONICLES2 = 14;
- public static final byte EZRA = 15;
- public static final byte NEHEMIAH = 16;
- public static final byte ESTHER = 17;
- public static final byte JOB = 18;
- public static final byte PSALMS = 19;
- public static final byte PROVERBS = 20;
- public static final byte ECCLESIASTES = 21;
- public static final byte SONGOFSOLOMON = 22;
- public static final byte ISAIAH = 23;
- public static final byte JEREMIAH = 24;
- public static final byte LAMENTATIONS = 25;
- public static final byte EZEKIEL = 26;
- public static final byte DANIEL = 27;
- public static final byte HOSEA = 28;
- public static final byte JOEL = 29;
- public static final byte AMOS = 30;
- public static final byte OBADIAH = 31;
- public static final byte JONAH = 32;
- public static final byte MICAH = 33;
- public static final byte NAHUM = 34;
- public static final byte HABAKKUK = 35;
- public static final byte ZEPHANIAH = 36;
- public static final byte HAGGAI = 37;
- public static final byte ZECHARIAH = 38;
- public static final byte MALACHI = 39;
- public static final byte MATTHEW = 40;
- public static final byte MARK = 41;
- public static final byte LUKE = 42;
- public static final byte JOHN = 43;
- public static final byte ACTS = 44;
- public static final byte ROMANS = 45;
- public static final byte CORINTHIANS1 = 46;
- public static final byte CORINTHIANS2 = 47;
- public static final byte GALATIANS = 48;
- public static final byte EPHESIANS = 49;
- public static final byte PHILIPPIANS = 50;
- public static final byte COLOSSIANS = 51;
- public static final byte THESSALONIANS1 = 52;
- public static final byte THESSALONIANS2 = 53;
- public static final byte TIMOTHY1 = 54;
- public static final byte TIMOTHY2 = 55;
- public static final byte TITUS = 56;
- public static final byte PHILEMON = 57;
- public static final byte HEBREWS = 58;
- public static final byte JAMES = 59;
- public static final byte PETER1 = 60;
- public static final byte PETER2 = 61;
- public static final byte JOHN1 = 62;
- public static final byte JOHN2 = 63;
- public static final byte JOHN3 = 64;
- public static final byte JUDE = 65;
- public static final byte REVELATION = 66;
- }
+ public static final byte GENESIS = 1;
+ public static final byte EXODUS = 2;
+ public static final byte LEVITICUS = 3;
+ public static final byte NUMBERS = 4;
+ public static final byte DEUTERONOMY = 5;
+ public static final byte JOSHUA = 6;
+ public static final byte JUDGES = 7;
+ public static final byte RUTH = 8;
+ public static final byte SAMUEL1 = 9;
+ public static final byte SAMUEL2 = 10;
+ public static final byte KINGS1 = 11;
+ public static final byte KINGS2 = 12;
+ public static final byte CHRONICLES1 = 13;
+ public static final byte CHRONICLES2 = 14;
+ public static final byte EZRA = 15;
+ public static final byte NEHEMIAH = 16;
+ public static final byte ESTHER = 17;
+ public static final byte JOB = 18;
+ public static final byte PSALMS = 19;
+ public static final byte PROVERBS = 20;
+ public static final byte ECCLESIASTES = 21;
+ public static final byte SONGOFSOLOMON = 22;
+ public static final byte ISAIAH = 23;
+ public static final byte JEREMIAH = 24;
+ public static final byte LAMENTATIONS = 25;
+ public static final byte EZEKIEL = 26;
+ public static final byte DANIEL = 27;
+ public static final byte HOSEA = 28;
+ public static final byte JOEL = 29;
+ public static final byte AMOS = 30;
+ public static final byte OBADIAH = 31;
+ public static final byte JONAH = 32;
+ public static final byte MICAH = 33;
+ public static final byte NAHUM = 34;
+ public static final byte HABAKKUK = 35;
+ public static final byte ZEPHANIAH = 36;
+ public static final byte HAGGAI = 37;
+ public static final byte ZECHARIAH = 38;
+ public static final byte MALACHI = 39;
+ public static final byte MATTHEW = 40;
+ public static final byte MARK = 41;
+ public static final byte LUKE = 42;
+ public static final byte JOHN = 43;
+ public static final byte ACTS = 44;
+ public static final byte ROMANS = 45;
+ public static final byte CORINTHIANS1 = 46;
+ public static final byte CORINTHIANS2 = 47;
+ public static final byte GALATIANS = 48;
+ public static final byte EPHESIANS = 49;
+ public static final byte PHILIPPIANS = 50;
+ public static final byte COLOSSIANS = 51;
+ public static final byte THESSALONIANS1 = 52;
+ public static final byte THESSALONIANS2 = 53;
+ public static final byte TIMOTHY1 = 54;
+ public static final byte TIMOTHY2 = 55;
+ public static final byte TITUS = 56;
+ public static final byte PHILEMON = 57;
+ public static final byte HEBREWS = 58;
+ public static final byte JAMES = 59;
+ public static final byte PETER1 = 60;
+ public static final byte PETER2 = 61;
+ public static final byte JOHN1 = 62;
+ public static final byte JOHN2 = 63;
+ public static final byte JOHN3 = 64;
+ public static final byte JUDE = 65;
+ public static final byte REVELATION = 66;
/** The locale for the Bible Names */
- private Locale locale;
+ private Locale locale;
/** The full names of the book of the Bible, in mixed case */
- private String[] fullBooks;
+ private String[] fullBooks;
/** The full names of the book of the Bible, normalized, generated at runtime */
- private String[] fullBooksSearch;
+ private String[] fullBooksSearch;
/** The full names of the book of the Bible, normalized, generated at runtime */
- private Map fullBooksMap;
+ private Map fullBooksMap;
/** Standard shortened names for the book of the Bible, in mixed case */
- private String[] shortBooks;
+ private String[] shortBooks;
- /** Standard shortened names for the book of the Bible, normalized, generated at runtime. */
- private String[] shortBooksSearch;
+ /**
+ * Standard shortened names for the book of the Bible, normalized, generated
+ * at runtime.
+ */
+ private String[] shortBooksSearch;
- /** Standard shortened names for the book of the Bible, normalized, generated at runtime. */
- private Map shortBooksMap;
+ /**
+ * Standard shortened names for the book of the Bible, normalized, generated
+ * at runtime.
+ */
+ private Map shortBooksMap;
- /** Alternative shortened names for the book of the Bible, expected to be normalized */
- private String[][] altBooks;
+ /**
+ * Alternative shortened names for the book of the Bible, expected to be
+ * normalized
+ */
+ private String[][] altBooks;
- /** Alternative shortened names for the book of the Bible, normalized, generated at runtime */
- private Map altBooksMap;
+ /**
+ * Alternative shortened names for the book of the Bible, normalized,
+ * generated at runtime
+ */
+ private Map altBooksMap;
- /** Standard OSIS names for the book of the Bible, in mixed case */
- private static String[] osisBooks;
-
- /** Standard OSIS names for the book of the Bible, in lowercase, generated at runtime */
- private static Map osisMap;
-
- /** Standard names for the sections */
- private String[] sections;
-
- private static Pattern normPattern = Pattern.compile("[. ]"); //$NON-NLS-1$
-
- /** Constant for the number of sections in the Bible */
- private static final int SECTIONS_IN_BIBLE = 8;
-
+ private static Pattern normPattern = Pattern.compile("[. ]"); //$NON-NLS-1$
}
Copied: trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleNames.properties (from rev 1137, trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo.properties)
Copied: trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleNames_de.properties (from rev 1137, trunk/jsword/src/main/java/org/crosswire/jsword/versification/BibleInfo_de.properties)
Added: trunk/jsword/src/main/java/org/crosswire/jsword/versification/SectionNames.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/versification/SectionNames.java 2006-10-01 02:48:59 UTC (rev 1137)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/versification/SectionNames.java 2006-10-01 03:26:33 UTC (rev 1138)
@@ -0,0 +1,273 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ * http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ * Free Software Foundation, Inc.
+ * 59 Temple Place - Suite 330
+ * Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2005
+ * The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: BibleNames.java 1068 2006-04-07 22:20:41 -0400 (Fri, 07 Apr 2006) dmsmith $
+ */
+package org.crosswire.jsword.versification;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.crosswire.common.util.CWClassLoader;
+import org.crosswire.jsword.book.CaseType;
+import org.crosswire.jsword.passage.NoSuchVerseException;
+
+/**
+ * SectionNames is a class that deals with sections of the Bible.
+ *
+ * @see gnu.lgpl.License for license details.
+ * The copyright to this program is held by it's authors.
+ * @author Joe Walker [joe at eireneh dot com]
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public final class SectionNames
+{
+ /**
+ * Ensure that we can not be instantiated
+ */
+ public SectionNames()
+ {
+ initialize();
+ }
+
+ /**
+ * Is this book part of the Pentateuch?
+ * @param book The book to test
+ * @return True if this book is a part of this section
+ */
+ public static boolean isPentateuch(int book)
+ {
+ return book >= BibleNames.GENESIS && book <= BibleNames.DEUTERONOMY;
+ }
+
+ /**
+ * Is this book part of the OT History?
+ * @param book The book to test
+ * @return True if this book is a part of this section
+ */
+ public static boolean isHistory(int book)
+ {
+ return book >= BibleNames.JOSHUA && book <= BibleNames.ESTHER;
+ }
+
+ /**
+ * Is this book part of the OT History?
+ * @param book The book to test
+ * @return True if this book is a part of this section
+ */
+ public static boolean isPoetry(int book)
+ {
+ return book >= BibleNames.JOB && book <= BibleNames.SONGOFSOLOMON;
+ }
+
+ /**
+ * Is this book part of the major prophets?
+ * @param book The book to test
+ * @return True if this book is a part of this section
+ */
+ public static boolean isMajorProphet(int book)
+ {
+ return book >= BibleNames.ISAIAH && book <= BibleNames.DANIEL;
+ }
+
+ /**
+ * Is this book part of the minor prophets?
+ * @param book The book to test
+ * @return True if this book is a part of this section
+ */
+ public static boolean isMinorProphet(int book)
+ {
+ return book >= BibleNames.HOSEA && book <= BibleNames.MALACHI;
+ }
+
+ /**
+ * Is this book part of the Gospels?
+ * @param book The book to test
+ * @return True if this book is a part of this section
+ */
+ public static boolean isGospel(int book)
+ {
+ return book >= BibleNames.MATTHEW && book <= BibleNames.JOHN;
+ }
+
+ /**
+ * Is this book part of the Gospels or Acts?
+ * @param book The book to test
+ * @return True if this book is a part of this section
+ */
+ public static boolean isGospelOrActs(int book)
+ {
+ return book >= BibleNames.MATTHEW && book <= BibleNames.ACTS;
+ }
+
+ /**
+ * Is this book part of the letters?
+ * @param book The book to test
+ * @return True if this book is a part of this section
+ */
+ public static boolean isLetter(int book)
+ {
+ return book >= BibleNames.ROMANS && book <= BibleNames.JUDE;
+ }
+
+ /**
+ * What section is this book a part of?
+ * @param book The book to test
+ * @return True The section
+ * @see SectionNames.Section
+ */
+ public static int getSection(int book)
+ {
+ // Ordered by section size for speed
+ if (isLetter(book))
+ {
+ return LETTERS;
+ }
+
+ if (isHistory(book))
+ {
+ return HISTORY;
+ }
+
+ if (isMinorProphet(book))
+ {
+ return MINOR_PROPHETS;
+ }
+
+ if (isGospelOrActs(book))
+ {
+ return GOSPELS_AND_ACTS;
+ }
+
+ if (isPentateuch(book))
+ {
+ return PENTATEUCH;
+ }
+
+ if (isPoetry(book))
+ {
+ return POETRY;
+ }
+
+ if (isMajorProphet(book))
+ {
+ return MAJOR_PROPHETS;
+ }
+
+ return REVELATION;
+ }
+
+ /**
+ * Get the full name of a book (e.g. "Genesis").
+ * Altered by the case setting (see setBookCase())
+ * @param section The book number (1-66)
+ * @return The full name of the book
+ * @exception NoSuchVerseException If the book number is not valid
+ */
+ public String getSectionName(int section) throws NoSuchVerseException
+ {
+ if (section == 0)
+ {
+ throw new NoSuchVerseException(Msg.BOOKS_SECTION, new Object[] { new Integer(section)});
+ }
+
+ try
+ {
+ CaseType bookCase = BibleInfo.getDefaultCase();
+
+ if (bookCase.equals(CaseType.LOWER))
+ {
+ return sections[section - 1].toLowerCase();
+ }
+
+ if (bookCase.equals(CaseType.UPPER))
+ {
+ return sections[section - 1].toUpperCase();
+ }
+
+ return sections[section - 1];
+ }
+ catch (ArrayIndexOutOfBoundsException ex)
+ {
+ // This is faster than doing the check explicitly, unless
+ // The exception is actually thrown, then it is a lot slower
+ // I'd like to think that the norm is to get it right
+ throw new NoSuchVerseException(Msg.BOOKS_SECTION, new Object[] { new Integer(section) });
+ }
+ }
+
+ /**
+ * Load up the resources for Bible book and section names,
+ * and cache the upper and lower versions of them.
+ */
+ private void initialize()
+ {
+ ResourceBundle resources = ResourceBundle.getBundle(SectionNames.class.getName(), Locale.getDefault(), new CWClassLoader(SectionNames.class));
+
+ sections = new String[SECTIONS_IN_BIBLE];
+
+ for (int i = 0; i < SECTIONS_IN_BIBLE; i++)
+ {
+ String section = getString(resources, SECTION_KEY + (i + 1));
+ sections[i] = section;
+ }
+ }
+
+ /*
+ * Helper to make the code more readable.
+ */
+ private String getString(ResourceBundle resources, String key)
+ {
+ try
+ {
+ return resources.getString(key);
+ }
+ catch (Exception e)
+ {
+ assert false;
+ }
+ return null;
+ }
+
+ private static final String SECTION_KEY = "BibleNames.Sections."; //$NON-NLS-1$
+
+ /**
+ * Handy section finder. There is a bit of moderately bad programming
+ * here because org.crosswire.jsword.control.map.sw*ng.GroupVerseColor
+ * uses these numbers as an index into an array, so we shouldn't
+ * change these numbers without fixing that, however I don't imagine
+ * that this section could ever change without breaking
+ * GroupVerseColor anyway so I don't see it as a big problem.
+ */
+ public static final byte PENTATEUCH = 1;
+ public static final byte HISTORY = 2;
+ public static final byte POETRY = 3;
+ public static final byte MAJOR_PROPHETS = 4;
+ public static final byte MINOR_PROPHETS = 5;
+ public static final byte GOSPELS_AND_ACTS = 6;
+ public static final byte LETTERS = 7;
+ public static final byte REVELATION = 8;
+
+ /** Standard names for the sections */
+ private String[] sections;
+
+ /** Constant for the number of sections in the Bible */
+ private static final int SECTIONS_IN_BIBLE = 8;
+
+}
More information about the jsword-svn
mailing list