org.crosswire.jsword.book.basic

## Class AbstractPassageBook

- java.lang.Object
- - org.crosswire.jsword.book.basic.AbstractBook
  - - org.crosswire.jsword.book.basic.AbstractPassageBook

- All Implemented Interfaces:
    Comparable<Book>, Activatable, Book
  Direct Known Subclasses:
    SwordBook

      public abstract class AbstractPassageBook
      extends AbstractBook

  An abstract implementation of Book that lets implementors just concentrate on reading book data.
  Author:
    Joe Walker
  See Also:
    `The GNU Lesser General Public License for details.
    The copyright to this program is held by its authors.`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private Set<BibleBook>` | `bibleBooks` lazy of cache of bible books contained in the Book
    `private PassageKeyFactory` | `keyf` Our key manager
    `private static org.slf4j.Logger` | `log` The log stream
    `private String` | `versification` The name of the versification or null
    `private Versification` | `versificationSystem` Versification system, created lazily, so use getter

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractPassageBook(BookMetaData bmd, Backend backend)` Construct an AbstractPassageBook given the BookMetaData and the AbstractBackend.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addOSIS(Key key, org.jdom2.Element div, List<org.jdom2.Content> osisContent)` Add the OSIS elements to the div element.
    `void` | `addOSIS(Key key, List<org.jdom2.Content> content, List<org.jdom2.Content> osisContent)` Add the OSIS elements to the content list.
    `private Set<BibleBook>` | `calculateBibleBookList()` Iterate all books checking if document contains a verse from the book
    `Key` | `createEmptyKeyList()` Fetch an empty Key to which we can add Keys.
    `private Set<BibleBook>` | `fromString(String list)`
    `Set<BibleBook>` | `getBibleBooks()` This implementation lazily inits, saves to the JSword conf file and also caches the book list for future use.
    `private Set<BibleBook>` | `getBibleBooksInternal()` Obtains the set of bible books from the internal configuration file, creating it if required.
    `protected abstract SourceFilter` | `getFilter()` What filter should be used to filter data in the format produced by this Book?.
    `Key` | `getKey(String text)` Someone has typed in a reference to find, but we need a Key to actually look it up.
    `Iterator<org.jdom2.Content>` | `getOsisIterator(Key key, boolean allowEmpty, boolean allowGenTitles)` Return an iterator that returns each key's OSIS in turn.
    `Key` | `getValidKey(String name)` Get a Key for the name, if possible.
    `Versification` | `getVersification()`
    `boolean` | `isWritable()` A Book is writable if the file system allows the underlying files to be opened for writing and if the driver for the book allows writing.
    `void` | `setDocument(Key key, BookData bdata)` For when we want to add writing functionality.
    `private String` | `toString(Set<BibleBook> books)`

    - ### Methods inherited from class org.crosswire.jsword.book.basic.AbstractBook

      `activate, addIndexStatusListener, compareTo, deactivate, equals, find, find, firePropertyChange, getAbbreviation, getBackend, getBook, getBookCategory, getBookMetaData, getDriver, getDriverName, getIndexStatus, getInitials, getLanguage, getName, getOsis, getOsisID, getProperty, getPropertyKeys, getScope, getUnlockKey, hasFeature, hashCode, isEnciphered, isLeftToRight, isLocked, isQuestionable, isSupported, match, putProperty, putProperty, removeIndexStatusListener, setBookMetaData, setIndexStatus, toOSIS, toString, unlock`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.crosswire.jsword.book.Book

      `contains, getGlobalKeyList, getRawText, setAliasKey, setRawText`

- - ### Field Detail

    - #### versification

          private String versification

      The name of the versification or null

    - #### versificationSystem

          private Versification versificationSystem

      Versification system, created lazily, so use getter

    - #### keyf

          private PassageKeyFactory keyf

      Our key manager

    - #### bibleBooks

          private volatile Set<BibleBook> bibleBooks

      lazy of cache of bible books contained in the Book

    - #### log

          private static final org.slf4j.Logger log

      The log stream

  - ### Constructor Detail

    - #### AbstractPassageBook

          public AbstractPassageBook(BookMetaData bmd,
                             Backend backend)

      Construct an AbstractPassageBook given the BookMetaData and the AbstractBackend.
      Parameters:
        `bmd` - the metadata that describes the book
        `backend` - the means by which the resource is accessed

  - ### Method Detail

    - #### getOsisIterator

          public Iterator<org.jdom2.Content> getOsisIterator(Key key,
                                                    boolean allowEmpty,
                                                    boolean allowGenTitles)
                                                      throws BookException

      Description copied from interface: `Book`
      Return an iterator that returns each key's OSIS in turn.
      Parameters:
        `key` - the Items to locate
        `allowEmpty` - indicates whether empty keys should be present.
        `allowGenTitles` - indicates whether to generate titles
      Returns:
        an iterator over the OSIS Content
      Throws:
        `BookException` - If anything goes wrong with this method

    - #### addOSIS

          public void addOSIS(Key key,
                     org.jdom2.Element div,
                     List<org.jdom2.Content> osisContent)

      Add the OSIS elements to the div element. Note, this assumes that the data is fully marked up.
      Parameters:
        `key` - The key being added
        `div` - The div element to which the key's OSIS representation is being added
        `osisContent` - The OSIS representation of the key being added.

    - #### addOSIS

          public void addOSIS(Key key,
                     List<org.jdom2.Content> content,
                     List<org.jdom2.Content> osisContent)

      Add the OSIS elements to the content list. Note, this assumes that the data is fully marked up.
      Parameters:
        `key` - The key being added
        `content` - The list to which the key's OSIS representation is being added
        `osisContent` - The OSIS representation of the key being added.

    - #### getFilter

          protected abstract SourceFilter getFilter()

      What filter should be used to filter data in the format produced by this Book?. In some ways this method is more suited to BookMetaData however we do not have a specialization of BookMetaData to fit AbstractPassageBook and it doesn't like any higher in the hierarchy at the moment so I will leave this here.

    - #### setDocument

          public void setDocument(Key key,
                         BookData bdata)
                           throws BookException

      For when we want to add writing functionality. This does not work.
      Parameters:
        `key` -
        `bdata` -
      Throws:
        `BookException`

    - #### isWritable

          public boolean isWritable()

      Description copied from interface: `Book`
      A Book is writable if the file system allows the underlying files to be opened for writing and if the driver for the book allows writing. Ultimately, all drivers should allow writing. At this time writing is not supported by drivers, so abstract implementations should return false and let specific implementations return true otherwise.
      Returns:
        true if the book is writable

    - #### createEmptyKeyList

          public final Key createEmptyKeyList()

      Description copied from interface: `Book`
      Fetch an empty Key to which we can add Keys. Not all implementations of Key are able to hold any type of Key, It isn't reasonable to expect a Key of Bible verses (=Passage) to hold a dictionary Key. So each KeyFactory must be able to create you an empty Key to which you can safely add other Keys it generates.
      Returns:
        An empty Key that can hold other Keys from this factory.

    - #### getValidKey

          public Key getValidKey(String name)

      Description copied from interface: `Book`
      Get a Key for the name, if possible. Otherwise return an empty Key.
      Parameters:
        `name` - The string to translate into a Key
      Returns:
        a valid key.

    - #### getKey

          public final Key getKey(String text)
                           throws NoSuchKeyException

      Description copied from interface: `Book`
      Someone has typed in a reference to find, but we need a Key to actually look it up. So we create a Key from the string if such a translation is possible. The returned Key may be a BranchKey if the string represents more than one Key.
      Parameters:
        `text` - The string to translate into a Key
      Returns:
        The Key corresponding to the input text
      Throws:
        `NoSuchKeyException` - If the name can not be parsed.

    - #### getVersification

          public Versification getVersification()

    - #### getBibleBooks

          public Set<BibleBook> getBibleBooks()

      This implementation lazily inits, saves to the JSword conf file and also caches the book list for future use.
      Returns:
        the list of Bible books contained in the module

    - #### getBibleBooksInternal

          private Set<BibleBook> getBibleBooksInternal()

      Obtains the set of bible books from the internal configuration file, creating it if required.
      Returns:
        the bible books relevant to this module.

    - #### fromString

          private Set<BibleBook> fromString(String list)

    - #### toString

          private String toString(Set<BibleBook> books)

    - #### calculateBibleBookList

          private Set<BibleBook> calculateBibleBookList()

      Iterate all books checking if document contains a verse from the book