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

public class SwordBookMetaData
extends AbstractBookMetaData

A utility class for loading and representing Sword book configs.

Config file format. See also: http://sword.sourceforge.net/cgi-bin/twiki/view/Swordapi/ConfFileLayout

The contents of the About field are in rtf.

\ is used as a continuation line.

Author:
Mark Goodwin [mark at thorubio dot org], Joe Walker [joe at eireneh dot com], Jacky Cheung, 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  ConfigEntryTable cet
           
private static Map 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 class org.crosswire.jsword.book.basic.AbstractBookMetaData
DEFAULT_LANG_CODE
 
Fields inherited from interface org.crosswire.jsword.book.BookMetaData
KEY_BOOK, KEY_CATEGORY, KEY_DRIVER, KEY_INDEXSTATUS, KEY_INITIALS, KEY_LANGUAGE, KEY_NAME
 
Constructor Summary
SwordBookMetaData(byte[] buffer, String internal)
          Loads a sword config from a buffer.
SwordBookMetaData(File file, String internal)
          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
 String getBookPath()
           
 BookType getBookType()
          Returns the Book Type.
 String getConfPath()
           
 Filter getFilter()
          Returns the sourceType.
 String getInitials()
          The initials of this book - how people familiar with this book will know it, for example "NIV", "KJV".
 String getName()
          The name of the book, for example "King James Version" or "Bible in Basic English" or "Greek".
 String 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 language 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.
 org.jdom.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, getFullName, getIndexStatus, getLanguage, getLanguage, getOsisID, getProperties, getProperty, hashCode, putProperty, setDriver, setIndexStatus, setProperties, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ENCODING_JAVA

private static final Map 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)
                  throws IOException
Loads a sword config from a given File. The returned BookMetaData object will not be associated with a Book so setBook() should be called before getBook() is expected to return anything other than null.

Parameters:
file -
internal -
Throws:
IOException

SwordBookMetaData

public SwordBookMetaData(byte[] buffer,
                         String internal)
                  throws IOException
Loads a sword config from a buffer. The returned BookMetaData object will not be associated with a Book so setBook() should be called before getBook() is expected to return anything other than null.

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.

getBookType

public BookType getBookType()
Returns the Book Type.


getFilter

public Filter getFilter()
Returns the sourceType.


getConfPath

public String getConfPath()
Returns:
Returns the relative path of the book's conf.

getBookPath

public String getBookPath()
Returns:
the relative path of the book.

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.jdom.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 String 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 language of the Book. If a book contains more than one language, it refers to the dominate language of the book. This will be used to present Arabic and Hebrew in their propper orientation.

Returns:
true if the orientation for the dominate language 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-2006