org.crosswire.jsword.book.sword
Class SwordBookMetaData

java.lang.Object
  extended by org.crosswire.jsword.book.basic.AbstractBookMetaData
      extended by org.crosswire.jsword.book.sword.SwordBookMetaData
All Implemented Interfaces:
Comparable<BookMetaData>, BookMetaData

public final class SwordBookMetaData
extends AbstractBookMetaData

Author:
DM Smith
See Also:
for license details.
The copyright to this program is held by it's authors.

Field Summary
private  ConfigEntryTable cet
           
private static PropertyMap ENCODING_JAVA
          Sword only recognizes two encodings for its modules: UTF-8 and LATIN1 Sword uses MS Windows cp1252 for Latin 1 not the standard.
private  BookCategory type
           
 
Fields inherited from interface org.crosswire.jsword.book.BookMetaData
KEY_BOOK, KEY_CATEGORY, KEY_DRIVER, KEY_FONT, KEY_INDEXSTATUS, KEY_INITIALS, KEY_LIBRARY_URI, KEY_LOCATION_URI, KEY_NAME, KEY_VERSIFICATION, KEY_XML_LANG
 
Constructor Summary
SwordBookMetaData(byte[] buffer, String internal)
          Loads a sword config from a buffer.
SwordBookMetaData(File file, String internal, URI bookRootPath)
          Loads a sword config from a given File.
 
Method Summary
private  void buildProperties()
           
 BookCategory getBookCategory()
          What category of content is this, a Bible or a reference work like a Dictionary or Commentary.
 String getBookCharset()
          Returns the Charset of the book based on the encoding attribute
 BookType getBookType()
          Returns the Book Type.
 File getConfigFile()
          Get the conf file for this SwordMetaData.
 String getConfPath()
          Deprecated. Use #getConf instead
 Filter getFilter()
          Returns the Filter based upon the SourceType.
 String getInitials()
          The initials of this book - how people familiar with this book will know it, for example "NIV", "KJV".
 KeyType getKeyType()
          How this Book organizes it's keys.
 String getName()
          The name of the book, for example "King James Version" or "Bible in Basic English" or "Greek".
 Object getProperty(ConfigEntryType entry)
          Get the string value for the property or null if it is not defined.
 String getUnlockKey()
          Gets the unlock key for the module.
 boolean hasFeature(FeatureType feature)
          Return whether the feature is supported by the book.
 boolean isEnciphered()
          Indicate whether this book is enciphered.
 boolean isLeftToRight()
          Return the orientation of the script of the Book.
 boolean isLocked()
          Indicate whether this book is enciphered and without a key.
 boolean isQuestionable()
          Indicate whether this book is questionable.
 boolean isSupported()
          Indicate whether this book is supported by JSword.
 void setLibrary(URI library)
          Set the base URI for library of this module.
 org.jdom2.Document toOSIS()
          Get an OSIS representation of information concerning this Book.
 boolean unlock(String unlockKey)
          Unlocks a book with the given key.
 
Methods inherited from class org.crosswire.jsword.book.basic.AbstractBookMetaData
compareTo, equals, getDriver, getDriverName, getIndexStatus, getLanguage, getLibrary, getLocation, getOsisID, getProperties, getProperty, hashCode, putProperty, setDriver, setIndexStatus, setLanguage, setLocation, setProperties, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ENCODING_JAVA

private static final PropertyMap ENCODING_JAVA
Sword only recognizes two encodings for its modules: UTF-8 and LATIN1 Sword uses MS Windows cp1252 for Latin 1 not the standard. Arrgh! The language strings need to be converted to Java charsets


cet

private ConfigEntryTable cet

type

private BookCategory type
Constructor Detail

SwordBookMetaData

public SwordBookMetaData(File file,
                         String internal,
                         URI bookRootPath)
                  throws IOException,
                         MissingDataFilesException
Loads a sword config from a given File.

Parameters:
file -
internal -
Throws:
IOException
MissingDataFilesException - indicates missing data files

SwordBookMetaData

public SwordBookMetaData(byte[] buffer,
                         String internal)
                  throws IOException
Loads a sword config from a buffer.

Parameters:
buffer -
internal -
Throws:
IOException
Method Detail

isQuestionable

public boolean isQuestionable()
Description copied from interface: BookMetaData
Indicate whether this book is questionable. A book may be deemed questionable if it's quality or content has not been confirmed. Since the expectation is that all books are not questionable, abstract implementations should return false and let specific implementations return true if the book is questionable.

Specified by:
isQuestionable in interface BookMetaData
Overrides:
isQuestionable in class AbstractBookMetaData
Returns:
true if the book is questionable

isSupported

public boolean isSupported()
Description copied from interface: BookMetaData
Indicate whether this book is supported by JSword. Since the expectation is that all books are supported, abstract implementations should return true and let specific implementations return false if they cannot support the book.

Specified by:
isSupported in interface BookMetaData
Overrides:
isSupported in class AbstractBookMetaData
Returns:
true if the book is supported

isEnciphered

public boolean isEnciphered()
Description copied from interface: BookMetaData
Indicate whether this book is enciphered. Since the expectation is that most books are unenciphered, abstract implementations should return false and let specific implementations return true otherwise.

Specified by:
isEnciphered in interface BookMetaData
Overrides:
isEnciphered in class AbstractBookMetaData
Returns:
true if the book is enciphered

isLocked

public boolean isLocked()
Description copied from interface: BookMetaData
Indicate whether this book is enciphered and without a key. Since the expectation is that most books are unenciphered, abstract implementations should return false and let specific implementations return true otherwise.

Specified by:
isLocked in interface BookMetaData
Overrides:
isLocked in class AbstractBookMetaData
Returns:
true if the book is locked

unlock

public boolean unlock(String unlockKey)
Description copied from interface: BookMetaData
Unlocks a book with the given key.

Specified by:
unlock in interface BookMetaData
Overrides:
unlock in class AbstractBookMetaData
Parameters:
unlockKey - the key to try
Returns:
true if the unlock key worked.

getUnlockKey

public String getUnlockKey()
Description copied from interface: BookMetaData
Gets the unlock key for the module.

Specified by:
getUnlockKey in interface BookMetaData
Overrides:
getUnlockKey in class AbstractBookMetaData
Returns:
the unlock key, if any, null otherwise.

getName

public String getName()
Description copied from interface: BookMetaData
The name of the book, for example "King James Version" or "Bible in Basic English" or "Greek". In general it should be possible to deduce the initials from the name by removing all the non-capital letters. Although this is only a generalization. This method should not return null or a blank string.

Returns:
The name of this book

getBookCharset

public String getBookCharset()
Returns the Charset of the book based on the encoding attribute

Returns:
the charset of the book.

getKeyType

public KeyType getKeyType()
Description copied from interface: BookMetaData
How this Book organizes it's keys.

Specified by:
getKeyType in interface BookMetaData
Overrides:
getKeyType in class AbstractBookMetaData
Returns:
the organization of keys of this Book

getBookType

public BookType getBookType()
Returns the Book Type.


getFilter

public Filter getFilter()
Returns the Filter based upon the SourceType.


getConfPath

@Deprecated
public String getConfPath()
Deprecated. Use #getConf instead

Returns:
Returns the relative path of the book's conf.

getConfigFile

public File getConfigFile()
Get the conf file for this SwordMetaData.

Returns:
Returns the conf file or null if loaded from a byte buffer.

setLibrary

public void setLibrary(URI library)
                throws MissingDataFilesException
Description copied from interface: BookMetaData
Set the base URI for library of this module.

Specified by:
setLibrary in interface BookMetaData
Overrides:
setLibrary in class AbstractBookMetaData
Parameters:
library - the base URI or null if there is none
Throws:
MissingDataFilesException - indicates missing data files

getBookCategory

public BookCategory getBookCategory()
Description copied from interface: BookMetaData
What category of content is this, a Bible or a reference work like a Dictionary or Commentary.

Returns:
The category of book

toOSIS

public org.jdom2.Document toOSIS()
Description copied from interface: BookMetaData
Get an OSIS representation of information concerning this Book.

Specified by:
toOSIS in interface BookMetaData
Overrides:
toOSIS in class AbstractBookMetaData

getInitials

public String getInitials()
Description copied from interface: BookMetaData
The initials of this book - how people familiar with this book will know it, for example "NIV", "KJV".

Returns:
The book's initials

getProperty

public Object getProperty(ConfigEntryType entry)
Get the string value for the property or null if it is not defined. It is assumed that all properties gotten with this method are single line.

Parameters:
entry - the ConfigEntryType
Returns:
the property or null

isLeftToRight

public boolean isLeftToRight()
Description copied from interface: BookMetaData
Return the orientation of the script of the Book. If a book contains more than one script, it refers to the dominate script of the book. This will be used to present Arabic and Hebrew in their proper orientation. Note: some languages have multiple scripts which don't have the same directionality.

Returns:
true if the orientation for the dominate script is LeftToRight.

hasFeature

public boolean hasFeature(FeatureType feature)
Description copied from interface: BookMetaData
Return whether the feature is supported by the book.

Specified by:
hasFeature in interface BookMetaData
Overrides:
hasFeature in class AbstractBookMetaData

buildProperties

private void buildProperties()

Copyright ? 2003-2011