org.crosswire.jsword.book.readings

## Class ReadingsBook

- java.lang.Object
- - org.crosswire.jsword.book.basic.AbstractBook
  - - org.crosswire.jsword.book.readings.ReadingsBook

- All Implemented Interfaces:
    Comparable<Book>, Activatable, Book, PreferredKey

      public class ReadingsBook
      extends AbstractBook
      implements PreferredKey

  A Dictionary that displays daily Readings.
  Author:
    Joe Walker
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private Key` | `global` The global key list
    `private Map<Key,String>` | `hash` The store of keys and data
    `private static org.slf4j.Logger` | `log` The log stream

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReadingsBook(ReadingsBookDriver driver, String setname, BookCategory type)` Constructor for ReadingsBook.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `contains(Key key)` Returns `true` if this book contains the specified element.
    `Key` | `createEmptyKeyList()` Fetch an empty Key to which we can add Keys.
    `Key` | `getGlobalKeyList()` Get a complete list of index entries.
    `Key` | `getKey(String name)` Someone has typed in a reference to find, but we need a Key to actually look it up.
    `List<org.jdom2.Content>` | `getOsis(Key key, RawTextToXmlProcessor processor)` Returns an empty list
    `Iterator<org.jdom2.Content>` | `getOsisIterator(Key key, boolean allowEmpty, boolean allowGenTitles)` Return an iterator that returns each key's OSIS in turn.
    `Key` | `getPreferred()` What Key would this object like us to use?
    `String` | `getRawText(Key key)` Returns an empty string (non-Javadoc)
    `Key` | `getValidKey(String name)` Get a Key for the name, if possible.
    `boolean` | `hasFeature(FeatureType feature)` Return whether the feature is supported by the book.
    `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` | `setAliasKey(Key alias, Key source)` Store an alias of one key to another.
    `void` | `setRawText(Key key, String rawData)` Store the raw text for the given key.

    - ### 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, getOsisID, getProperty, getPropertyKeys, getScope, getUnlockKey, 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`

- - ### Field Detail

    - #### global

          private Key global

      The global key list

    - #### hash

          private Map<Key,String> hash

      The store of keys and data

    - #### log

          private static final org.slf4j.Logger log

      The log stream

  - ### Constructor Detail

    - #### ReadingsBook

          public ReadingsBook(ReadingsBookDriver driver,
                      String setname,
                      BookCategory type)

      Constructor for ReadingsBook.
      Parameters:
        `driver` - the driver for this book
        `setname` - the name of this book
        `type` - the type of book

  - ### Method Detail

    - #### getPreferred

          public Key getPreferred()

      Description copied from interface: `PreferredKey`
      What Key would this object like us to use?
      Specified by:
        `getPreferred` in interface `PreferredKey`
      Returns:
        The preferredKey

    - #### 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.
      Specified by:
        `getOsisIterator` in interface `Book`
      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

    - #### contains

          public boolean contains(Key key)

      Description copied from interface: `Book`
      Returns `true` if this book contains the specified element.
      Specified by:
        `contains` in interface `Book`
      Parameters:
        `key` - element whose presence in this book is to be tested.
      Returns:
        `true` if this book contains the specified element.

    - #### getRawText

          public String getRawText(Key key)
                            throws BookException

      Returns an empty string (non-Javadoc)
      Specified by:
        `getRawText` in interface `Book`
      Parameters:
        `key` - The item to locate
      Returns:
        The found Book data
      Throws:
        `BookException` - If anything goes wrong with this method
      See Also:
        `Book.getRawText(org.crosswire.jsword.passage.Key)`

    - #### getOsis

          public List<org.jdom2.Content> getOsis(Key key,
                                        RawTextToXmlProcessor processor)
                                          throws BookException

      Returns an empty list
      Specified by:
        `getOsis` in class `AbstractBook`
      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.
      Specified by:
        `isWritable` in interface `Book`
      Returns:
        true if the book is writable

    - #### setRawText

          public void setRawText(Key key,
                        String rawData)
                          throws BookException

      Description copied from interface: `Book`
      Store the raw text for the given key. This will replace/hide any raw text that already is present. Note: it is the responsibility of the calling program to ensure that the raw text matches the character set encoding and markup of the module.
      Specified by:
        `setRawText` in interface `Book`
      Parameters:
        `key` - The item to locate
        `rawData` - The text to store
      Throws:
        `BookException` - If anything goes wrong with this method

    - #### setAliasKey

          public void setAliasKey(Key alias,
                         Key source)
                           throws BookException

      Description copied from interface: `Book`
      Store an alias of one key to another. Some Bibles do not have a verse by verse numbering system but rather meld several verses into one. Thus, any verse in the range refers to the same verse. Also it may apply to biblical commentaries that are indexed by Book, Chapter, Verse and that discuss the Bible at a verse range level. For a dictionary, it may be used for synonyms.

      It should be an exception to set an alias when that alias already has raw text. Also, it should be an exception to set an alias to an alias. However, getRawText(Key) must be able to handle alias chains.

      Specified by:
        `setAliasKey` in interface `Book`
      Parameters:
        `alias` - the key that aliases another
        `source` - the key that holds the text
      Throws:
        `BookException` - If anything goes wrong with this method

    - #### getValidKey

          public Key getValidKey(String name)

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

    - #### getKey

          public Key getKey(String name)
                     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.
      Specified by:
        `getKey` in interface `Book`
      Parameters:
        `name` - The string to translate into a Key
      Returns:
        The Key corresponding to the input text
      Throws:
        `NoSuchKeyException` - If the name can not be parsed.

    - #### getGlobalKeyList

          public Key getGlobalKeyList()

      Description copied from interface: `Book`
      Get a complete list of index entries. Create a Key that encompasses all of the known valid keys for the given context. For a dictionary this will include all of the entries in the dictionary, for a Bible this will probably include all the verses in the Bible, but a commentary may well miss some out.
      Specified by:
        `getGlobalKeyList` in interface `Book`
      Returns:
        A Key that includes all of the known Keys

    - #### createEmptyKeyList

          public 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.
      Specified by:
        `createEmptyKeyList` in interface `Book`
      Returns:
        An empty Key that can hold other Keys from this factory.

    - #### hasFeature

          public boolean hasFeature(FeatureType feature)

      Description copied from interface: `Book`
      Return whether the feature is supported by the book.
      Specified by:
        `hasFeature` in interface `Book`
      Overrides:
        `hasFeature` in class `AbstractBook`
      Parameters:
        `feature` - the type of the Feature to check
      Returns:
        whether the feature is supported