org.crosswire.jsword.versification
Class BookName

java.lang.Object
  extended by org.crosswire.jsword.versification.BookName

public final class BookName
extends Object

BookName represents the different ways a book of the bible is named.

Author:
DM Smith
See Also:
The GNU Lesser General Public License for details.

Field Summary
private  String[] alternateNames
           
private  BibleBook book
           
private static CaseType bookCase
          How the book names are reported.
private static boolean fullBookName
          Whether long or short, full or abbreviated names are used.
private  Locale locale
          The locale for the Book Name
private  String longName
           
private  String normalizedLongName
           
private  String normalizedShortName
           
private static Pattern normPattern
          remove spaces and some punctuation in Book Name (make sure , is allowed)
private  String shortName
           
 
Constructor Summary
BookName(Locale locale, BibleBook book, String longName, String shortName, String alternateNames)
          Create a BookName for a Book of the Bible in a given language.
 
Method Summary
 boolean equals(Object obj)
           
 BibleBook getBook()
          Get the BibleBook to which this set of names is tied.
static int getCase()
          This is only used by config
static CaseType getDefaultCase()
          How do we report the names of the books?.
 String getLongName()
          Get the full name of a book (e.g.
 String getNormalizedLongName()
           
 String getNormalizedShortName()
           
 String getPreferredName()
          Get the preferred name of a book.
 String getShortName()
          Get the short name of a book (e.g.
 int hashCode()
           
static boolean isFullBookName()
          This is only used by config
 boolean match(String normalizedName)
          Match the normalized name as closely as possible.
static String normalize(String str, Locale locale)
          Normalize by stripping punctuation and whitespace and lowercasing.
static void setCase(CaseType newBookCase)
          How do we report the names of the books?.
static void setCase(int bookCase)
          This is only used by config.
static void setFullBookName(boolean fullName)
          Set whether the name should be full or abbreviated, long or short.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

normPattern

private static Pattern normPattern
remove spaces and some punctuation in Book Name (make sure , is allowed)


book

private BibleBook book

longName

private String longName

normalizedLongName

private String normalizedLongName

shortName

private String shortName

normalizedShortName

private String normalizedShortName

alternateNames

private String[] alternateNames

locale

private Locale locale
The locale for the Book Name


bookCase

private static CaseType bookCase
How the book names are reported.


fullBookName

private static boolean fullBookName
Whether long or short, full or abbreviated names are used.

Constructor Detail

BookName

public BookName(Locale locale,
                BibleBook book,
                String longName,
                String shortName,
                String alternateNames)
Create a BookName for a Book of the Bible in a given language.

Parameters:
locale - the language of this BookName
book - the Book's canonical number
longName - the Book's long name
shortName - the Book's short name, if any
alternateNames - optional comma separated list of alternates for the Book
Method Detail

getBook

public BibleBook getBook()
Get the BibleBook to which this set of names is tied.

Returns:
The book

getPreferredName

public String getPreferredName()
Get the preferred name of a book. Altered by the case setting (see setBookCase() and isFullBookName())

Returns:
The preferred name of the book

getLongName

public String getLongName()
Get the full name of a book (e.g. "Genesis"). Altered by the case setting (see setBookCase())

Returns:
The full name of the book

getShortName

public String getShortName()
Get the short name of a book (e.g. "Gen"). Altered by the case setting (see setBookCase())

Returns:
The short name of the book

getNormalizedLongName

public String getNormalizedLongName()
Returns:
the normalizedLongName

getNormalizedShortName

public String getNormalizedShortName()
Returns:
the normalizedShortName

match

public boolean match(String normalizedName)
Match the normalized name as closely as possible. It will match if:
  1. it is a prefix of a normalized alternate name
  2. a normalized alternate name is a prefix of it
  3. it is a prefix of a normalized long name
  4. it is a prefix of a normalized short name
  5. a normalized short name is a prefix of it

Parameters:
normalizedName - the already normalized name to match against.
Returns:
true of false

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

normalize

public static String normalize(String str,
                               Locale locale)
Normalize by stripping punctuation and whitespace and lowercasing.

Parameters:
str - the string to normalize
Returns:
the normalized string

setCase

public static void setCase(int bookCase)
This is only used by config.

Parameters:
bookCase - The new case to use for reporting book names
Throws:
IllegalArgumentException - If the case is not between 0 and 2
See Also:
getCase()

getCase

public static int getCase()
This is only used by config

Returns:
The current case setting
See Also:
setCase(CaseType)

setCase

public static void setCase(CaseType newBookCase)
How do we report the names of the books?. These are static. This is on the assumption that we will not want to have different sections of the app using a different format. I expect this to be a good assumption, and it saves passing a Book class around everywhere. CaseType.MIXED is not allowed

Parameters:
newBookCase - The new case to use for reporting book names
Throws:
IllegalArgumentException - If the case is not between 0 and 2
See Also:
getCase()

isFullBookName

public static boolean isFullBookName()
This is only used by config

Returns:
Whether the name is long or short. Default is Full (true).
See Also:
setFullBookName(boolean)

setFullBookName

public static void setFullBookName(boolean fullName)
Set whether the name should be full or abbreviated, long or short.

Parameters:
fullName - The new case to use for reporting book names
See Also:
isFullBookName()

getDefaultCase

public static CaseType getDefaultCase()
How do we report the names of the books?.

Returns:
The current case setting
See Also:
setCase(int)

Copyright ยจ 2003-2015