public final class SwordBookMetaData extends AbstractBookMetaData
Config file format. See also: http://sword.sourceforge.net/cgi-bin/twiki/view/Swordapi/ConfFileLayout
In addition, the SwordBookMetaData is hierarchical. The Level indicates where the file originates from. The full hierarchy could be laid out as followed:
- sword - jsword - front-endVarious rules govern where attributes are read from. The general rule is that the highest level (front-end write) will override values from the lowest common denominator (sword). Various parts of the tree may be missing as the files may not exist on disk. There are exceptions however and each method in this file documents its behavior.
The contents of the About field are in RTF.
\ is used as a continuation line.
The GNU Lesser General Public License for details.
Modifier and Type | Class and Description |
---|---|
private static class |
SwordBookMetaData.KeyFilter
KeyFilter returns true for keys that should always be present.
|
Modifier and Type | Field and Description |
---|---|
private BookCategory |
bookCat
The BookCategory for this Book
|
private String |
bookConf
The name of the conf file, such as kjv.conf.
|
private BookType |
bookType
The BookType for this Book
|
private IniSection |
configAll
The configAll IniSection holds the merged view of the SWORD config,
configJSword, and configFrontend.
|
private File |
configFile
If the module's config is tied to a file remember it so that it can be
updated.
|
private IniSection |
configFrontend
configFrontend contains the configuration for the current front-end.
|
private IniSection |
configJSword
configJSword holds shared configuration for all front-ends.
|
static Map<String,String> |
DEFAULTS |
private static PropertyMap |
ENCODING_JAVA |
private static String |
ENCODING_LATIN1 |
private static String |
ENCODING_UTF8
Sword only recognizes two encodings for its modules: UTF-8 and Latin-1
Sword uses MS Windows cp1252 for Latin 1 not the standard.
|
private boolean |
filtered
When true this BookMetaData is filtered and only partially loaded.
|
private static String[] |
HIDDEN |
private static Pattern |
HTML_PATTERN |
private boolean |
installed
Indicates whether the Book is installed or not.
|
static String |
KEY_ABBREVIATION |
static String |
KEY_ABOUT |
static String |
KEY_BLOCK_COUNT |
static String |
KEY_BLOCK_TYPE |
static String |
KEY_CASE_SENSITIVE_KEYS |
static String |
KEY_CIPHER_KEY |
static String |
KEY_COMPRESS_TYPE |
static String |
KEY_COPYRIGHT |
static String |
KEY_COPYRIGHT_CONTACT_ADDRESS |
static String |
KEY_COPYRIGHT_CONTACT_EMAIL |
static String |
KEY_COPYRIGHT_CONTACT_NAME |
static String |
KEY_COPYRIGHT_CONTACT_NOTES |
static String |
KEY_COPYRIGHT_DATE |
static String |
KEY_COPYRIGHT_HOLDER |
static String |
KEY_COPYRIGHT_NOTES |
static String |
KEY_DATA_PATH |
static String |
KEY_DESCRIPTION |
static String |
KEY_DIRECTION |
static String |
KEY_DISPLAY_LEVEL |
static String |
KEY_DISTRIBUTION_LICENSE |
static String |
KEY_DISTRIBUTION_NOTES |
static String |
KEY_DISTRIBUTION_SOURCE |
static String |
KEY_ENCODING |
static String |
KEY_FEATURE |
static String |
KEY_GLOBAL_OPTION_FILTER |
static String |
KEY_GLOSSARY_FROM |
static String |
KEY_GLOSSARY_TO |
static String |
KEY_HISTORY |
static String |
KEY_INSTALL_SIZE |
static String |
KEY_KEY_TYPE |
static String |
KEY_LCSH |
static String |
KEY_LOCAL_STRIP_FILTER |
static String |
KEY_MINIMUM_VERSION |
static String |
KEY_MOD_DRV |
static String |
KEY_OBSOLETES |
static String |
KEY_OSIS_Q_TO_TICK |
static String |
KEY_OSIS_VERSION |
static String |
KEY_PREFERRED_CSS_XHTML |
static String |
KEY_SEARCH_OPTION |
static String |
KEY_SHORT_COPYRIGHT |
static String |
KEY_SHORT_PROMO |
static String |
KEY_SIGLUM1 |
static String |
KEY_SIGLUM2 |
static String |
KEY_SIGLUM3 |
static String |
KEY_SIGLUM4 |
static String |
KEY_SIGLUM5 |
static String |
KEY_SOURCE_TYPE |
static String |
KEY_STRONGS_PADDING |
static String |
KEY_SWORD_VERSION_DATE |
static String |
KEY_TEXT_SOURCE |
static String |
KEY_UNLOCK_URL |
static String |
KEY_VERSION |
private static Filter |
keyKeepers |
private static org.slf4j.Logger |
LOGGER
The log stream
|
private static String[] |
OSIS_INFO |
private static boolean |
partialLoading |
private boolean |
questionable
True if this book is considered questionable.
|
private static String[] |
REQUIRED
These are the elements that JSword uses for control when present in a conf.
|
private static Pattern |
RTF_PATTERN |
private boolean |
supported
True if this book's config type can be used by JSword.
|
KEY_BOOK, KEY_BOOKLIST, KEY_CATEGORY, KEY_DRIVER, KEY_FONT, KEY_LANG, KEY_LANGUAGE, KEY_NAME, KEY_SCOPE, KEY_VERSIFICATION
Constructor and Description |
---|
SwordBookMetaData(byte[] buffer,
String bookConf)
Loads a sword config from a buffer gotten from mods.d.tar.gz or mods.d.zip.
|
SwordBookMetaData(File file,
URI bookRootPath)
Loads a sword config from a given File.
|
Modifier and Type | Method and Description |
---|---|
private IniSection |
addConfig(MetaDataLocator locator) |
private void |
adjustBookType() |
private void |
adjustConfig() |
private static void |
adjustHistory(IniSection config) |
private void |
adjustLanguage() |
private void |
adjustLocation() |
private void |
adjustName() |
String |
getAbbreviation()
The initials of this book - how people familiar with this book will know
it, for example "NIV", "KJV".
|
BookCategory |
getBookCategory()
What category of content is this, a Bible or a reference work like a
Dictionary or Commentary.
|
String |
getBookCharset()
With which Charset is this Book encoded?
|
BookType |
getBookType() |
File |
getConfigFile()
To maintain backwards compatibility, this always returns the Sword conf
file Get the conf file for this SwordMetaData.
|
SourceFilter |
getFilter() |
String |
getInitials()
The internal name of this book.
|
(package private) String |
getInternalName() |
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".
|
String |
getProperty(String key)
Get the property or null.
|
Set<String> |
getPropertyKeys()
Get a list of all the properties available to do with this Book.
|
String |
getUnlockKey()
Gets the unlock key for the module.
|
private Object |
getValue(String key)
Gets a particular entry value by its type
|
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.
|
private void |
loadBuffer(byte[] buffer,
Filter<String> keepers)
Load the conf from a buffer.
|
private void |
loadFile(Filter<String> keepers)
Load the conf from a file.
|
private void |
mergeConfig(IniSection config) |
static void |
normalize(Writer out,
IniSection config,
String[] order) |
void |
putProperty(String key,
String value,
boolean forFrontend)
Saves an entry to a particular configuration file.
|
void |
putProperty(String key,
String value,
MetaDataLocator metaDataLocator)
Allow specification of a specific SwordMetaDataLocator when saving a property.
|
void |
reload()
If this BookMetaData is partially loaded, reload it fully.
|
void |
reload(Filter<String> keepers) |
static void |
report(IniSection config) |
static void |
setPartialLoading(boolean partial)
Allow for partial loading of a minimum set of keys, saving time and space.
|
void |
setProperty(String key,
String value)
Store a transient property.
|
private void |
testLanguage(String key,
String lang) |
private org.jdom2.Element |
toKeyCell(OSISUtil.OSISFactory factory,
String key) |
org.jdom2.Document |
toOSIS()
Get an OSIS representation of information concerning this Book.
|
private org.jdom2.Element |
toRow(OSISUtil.OSISFactory factory,
String key) |
private org.jdom2.Element |
toRow(OSISUtil.OSISFactory factory,
String key,
String value) |
boolean |
unlock(String unlockKey)
Unlocks a book with the given key.
|
compareTo, equals, getDriver, getDriverName, getIndexStatus, getLanguage, getLibrary, getLocation, getOsisID, hashCode, putProperty, setDriver, setIndexStatus, setLanguage, setLibrary, setLocation, toString
public static final String KEY_ABBREVIATION
public static final String KEY_ABOUT
public static final String KEY_BLOCK_COUNT
public static final String KEY_BLOCK_TYPE
public static final String KEY_CASE_SENSITIVE_KEYS
public static final String KEY_CIPHER_KEY
public static final String KEY_COMPRESS_TYPE
public static final String KEY_COPYRIGHT
public static final String KEY_COPYRIGHT_CONTACT_ADDRESS
public static final String KEY_COPYRIGHT_CONTACT_EMAIL
public static final String KEY_COPYRIGHT_CONTACT_NAME
public static final String KEY_COPYRIGHT_CONTACT_NOTES
public static final String KEY_COPYRIGHT_DATE
public static final String KEY_COPYRIGHT_HOLDER
public static final String KEY_COPYRIGHT_NOTES
public static final String KEY_DATA_PATH
public static final String KEY_DESCRIPTION
public static final String KEY_DIRECTION
public static final String KEY_DISPLAY_LEVEL
public static final String KEY_DISTRIBUTION_LICENSE
public static final String KEY_DISTRIBUTION_NOTES
public static final String KEY_DISTRIBUTION_SOURCE
public static final String KEY_ENCODING
public static final String KEY_FEATURE
public static final String KEY_GLOBAL_OPTION_FILTER
public static final String KEY_SIGLUM1
public static final String KEY_SIGLUM2
public static final String KEY_SIGLUM3
public static final String KEY_SIGLUM4
public static final String KEY_SIGLUM5
public static final String KEY_GLOSSARY_FROM
public static final String KEY_GLOSSARY_TO
public static final String KEY_HISTORY
public static final String KEY_INSTALL_SIZE
public static final String KEY_KEY_TYPE
public static final String KEY_LCSH
public static final String KEY_LOCAL_STRIP_FILTER
public static final String KEY_MINIMUM_VERSION
public static final String KEY_MOD_DRV
public static final String KEY_OBSOLETES
public static final String KEY_OSIS_Q_TO_TICK
public static final String KEY_OSIS_VERSION
public static final String KEY_PREFERRED_CSS_XHTML
public static final String KEY_SEARCH_OPTION
public static final String KEY_SHORT_COPYRIGHT
public static final String KEY_SHORT_PROMO
public static final String KEY_SOURCE_TYPE
public static final String KEY_STRONGS_PADDING
public static final String KEY_SWORD_VERSION_DATE
public static final String KEY_TEXT_SOURCE
public static final String KEY_UNLOCK_URL
public static final String KEY_VERSION
private boolean installed
private boolean filtered
private String bookConf
private IniSection configAll
private IniSection configJSword
private IniSection configFrontend
private boolean supported
private BookCategory bookCat
private BookType bookType
private boolean questionable
private File configFile
private static final String[] REQUIRED
private static boolean partialLoading
private static Filter keyKeepers
private static final String[] OSIS_INFO
private static final String[] HIDDEN
private static final Pattern RTF_PATTERN
private static final Pattern HTML_PATTERN
private static final String ENCODING_UTF8
private static final String ENCODING_LATIN1
private static final PropertyMap ENCODING_JAVA
private static final org.slf4j.Logger LOGGER
public SwordBookMetaData(File file, URI bookRootPath) throws IOException, BookException
file
- the config filebookRootPath
- the root path for the bookIOException
BookException
- indicates missing data filespublic SwordBookMetaData(byte[] buffer, String bookConf) throws IOException, BookException
buffer
- bookConf
- IOException
BookException
public void reload() throws BookException
BookMetaData
reload
in interface BookMetaData
reload
in class AbstractBookMetaData
BookException
- when a problem is encountered loading the filepublic void reload(Filter<String> keepers) throws BookException
BookException
public boolean isQuestionable()
BookMetaData
isQuestionable
in interface BookMetaData
isQuestionable
in class AbstractBookMetaData
public boolean isSupported()
BookMetaData
isSupported
in interface BookMetaData
isSupported
in class AbstractBookMetaData
public boolean isEnciphered()
BookMetaData
isEnciphered
in interface BookMetaData
isEnciphered
in class AbstractBookMetaData
public boolean isLocked()
BookMetaData
isLocked
in interface BookMetaData
isLocked
in class AbstractBookMetaData
public boolean unlock(String unlockKey)
BookMetaData
unlock
in interface BookMetaData
unlock
in class AbstractBookMetaData
unlockKey
- the key to trypublic String getUnlockKey()
BookMetaData
getUnlockKey
in interface BookMetaData
getUnlockKey
in class AbstractBookMetaData
public String getName()
BookMetaData
public String getBookCharset()
BookMetaData
public KeyType getKeyType()
BookMetaData
getKeyType
in interface BookMetaData
getKeyType
in class AbstractBookMetaData
public BookType getBookType()
public SourceFilter getFilter()
public File getConfigFile()
public BookCategory getBookCategory()
BookMetaData
public org.jdom2.Document toOSIS()
BookMetaData
toOSIS
in interface BookMetaData
toOSIS
in class AbstractBookMetaData
public static void normalize(Writer out, IniSection config, String[] order)
public String getInitials()
BookMetaData
String getInternalName()
public String getAbbreviation()
BookMetaData
public boolean isLeftToRight()
BookMetaData
public boolean hasFeature(FeatureType feature)
BookMetaData
hasFeature
in interface BookMetaData
hasFeature
in class AbstractBookMetaData
feature
- the feature in questionpublic Set<String> getPropertyKeys()
BookMetaData
public String getProperty(String key)
BookMetaData
key
- the key of the property.public void setProperty(String key, String value)
BookMetaData
key
- the key of the property to setvalue
- the value of the propertypublic void putProperty(String key, String value, boolean forFrontend)
BookMetaData
key
- the entry that we are savingvalue
- the value of the entryforFrontend
- when true
save to front end storage, else in shared storagepublic void putProperty(String key, String value, MetaDataLocator metaDataLocator)
key
- the entry that we are savingvalue
- the value of the entrymetaDataLocator
- Place to save - front end storage, shared storage, or don't save(transient)public static void setPartialLoading(boolean partial)
partial
- private void loadFile(Filter<String> keepers) throws IOException
keepers
- the keys to keep. When null keep allIOException
private void loadBuffer(byte[] buffer, Filter<String> keepers) throws IOException
buffer
- the buffer to loadIOException
private IniSection addConfig(MetaDataLocator locator)
private void mergeConfig(IniSection config)
private Object getValue(String key)
key
- of the entryprivate org.jdom2.Element toRow(OSISUtil.OSISFactory factory, String key, String value)
private org.jdom2.Element toRow(OSISUtil.OSISFactory factory, String key)
private org.jdom2.Element toKeyCell(OSISUtil.OSISFactory factory, String key)
private void adjustConfig() throws BookException
BookException
private void adjustLanguage()
private void adjustBookType()
private void adjustName()
private void adjustLocation() throws BookException
BookException
private static void adjustHistory(IniSection config)
public static void report(IniSection config)