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 [dmsmith555 at yahoo dot com]
See Also:
for license details. The copyright to this program is held by it's authors.

Field Summary
private  String[] alternateNames
           
private  int bookNumber
           
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, int bookNumber, 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)
           
 String getLongName()
          Get the full name of a book (e.g.
 String getNormalizedLongName()
           
 String getNormalizedShortName()
           
 int getNumber()
          Get canonical number of a book.
 String getPreferredName()
          Get the preferred name of a book.
 String getShortName()
          Get the short name of a book (e.g.
 int hashCode()
           
 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.
 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)


bookNumber

private int bookNumber

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

Constructor Detail

BookName

public BookName(Locale locale,
                int bookNumber,
                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
bookNumber - 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

getNumber

public int getNumber()
Get canonical number of a book.

Returns:
The book number (1 to 66)

getPreferredName

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

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
  6. 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

Copyright ยจ 2003-2007