[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/sword s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Sun Jan 8 17:52:16 MST 2006
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword
In directory www.crosswire.org:/tmp/cvs-serv18652/java/jsword/org/crosswire/jsword/book/sword
Modified Files:
RawLDBackend.java ConfigEntryTable.java SwordBookMetaData.java
BookType.java SwordBookDriver.java
Added Files:
GenBookBackend.java
Log Message:
Fixed a release bug.
Finished the BookCategory implementation.
Index: SwordBookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookMetaData.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** SwordBookMetaData.java 2 Jan 2006 03:40:08 -0000 1.47
--- SwordBookMetaData.java 9 Jan 2006 00:52:14 -0000 1.48
***************
*** 77,80 ****
--- 77,81 ----
{
cet = new ConfigEntryTable(in, internal);
+ buildProperties();
// Element ele = cet.toOSIS();
// SAXEventProvider sep = new JDOMSAXEventProvider(new Document(ele));
***************
*** 86,102 ****
// {
// }
! if (isSupported())
! {
! buildProperties();
! }
}
! /**
! * Is this one of the supported book types?
*/
public boolean isSupported()
{
! return cet.isSupported();
}
--- 87,114 ----
// {
// }
! }
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.BookMetaData#isQuestionable()
+ */
+ public boolean isQuestionable()
+ {
+ return cet.isQuestionable();
}
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.BookMetaData#isSupported()
*/
public boolean isSupported()
{
! return cet.isSupported() && cet.getBookType().isSupported(this);
! }
!
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.BookMetaData#isEnciphered()
! */
! public boolean isEnciphered()
! {
! return cet.isEnciphered();
}
Index: BookType.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/BookType.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** BookType.java 3 Jan 2006 13:25:34 -0000 1.3
--- BookType.java 9 Jan 2006 00:52:14 -0000 1.4
***************
*** 258,262 ****
* Generic Books
*/
! public static final BookType RAW_GEN_BOOK = new BookType("RawGenBook", null) //$NON-NLS-1$ //$NON-NLS-2$
{
protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend)
--- 258,262 ----
* Generic Books
*/
! public static final BookType RAW_GEN_BOOK = new BookType("RawGenBook", BookCategory.OTHER) //$NON-NLS-1$ //$NON-NLS-2$
{
protected Book getBook(SwordBookMetaData sbmd, AbstractBackend backend)
***************
*** 267,271 ****
protected AbstractBackend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
{
! return new RawBackend(sbmd, rootPath);
}
--- 267,276 ----
protected AbstractBackend getBackend(SwordBookMetaData sbmd, File rootPath) throws BookException
{
! return new GenBookBackend(sbmd, rootPath);
! }
!
! protected boolean isBackendSupported(SwordBookMetaData sbmd)
! {
! return false;
}
--- NEW FILE: GenBookBackend.java ---
/**
* Distribution License:
* JSword is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License, version 2.1 as published by
* the Free Software Foundation. This program is distributed in the hope
* that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* The License is available on the internet at:
* http://www.gnu.org/copyleft/lgpl.html
* or by writing to:
* Free Software Foundation, Inc.
* 59 Temple Place - Suite 330
* Boston, MA 02111-1307, USA
*
* Copyright: 2005
* The copyright to this program is held by it's authors.
*
* ID: $Id: GenBookBackend.java,v 1.1 2006/01/09 00:52:14 dmsmith Exp $
*/
package org.crosswire.jsword.book.sword;
import java.io.File;
import org.crosswire.common.activate.Activator;
import org.crosswire.common.activate.Lock;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.passage.Key;
/**
* Backend for General Books. These are currently not supported.
*
* @see gnu.lgpl.License for license details.
* The copyright to this program is held by it's authors.
* @author DM Smith [dmsmith555 at yahoo dot com]
*/
public class GenBookBackend extends AbstractBackend
{
/**
* Simple ctor
*/
public GenBookBackend(SwordBookMetaData sbmd, File rootPath)
{
super(sbmd, rootPath);
}
/* (non-Javadoc)
* @see org.crosswire.common.activate.Activatable#activate(org.crosswire.common.activate.Lock)
*/
public final void activate(Lock lock)
{
active = true;
}
/* (non-Javadoc)
* @see org.crosswire.common.activate.Activatable#deactivate(org.crosswire.common.activate.Lock)
*/
public final void deactivate(Lock lock)
{
active = false;
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.sword.AbstractBackend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
*/
public String getRawText(Key key) throws BookException
{
checkActive();
return ""; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.sword.AbstractBackend#readIndex()
*/
public Key readIndex()
{
return null;
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.sword.AbstractBackend#isSupported()
*/
public boolean isSupported()
{
return false;
}
/**
* Helper method so we can quickly activate ourselves on access
*/
protected final void checkActive()
{
if (!active)
{
Activator.activate(this);
}
}
/**
* Are we active
*/
private boolean active;
}
Index: ConfigEntryTable.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/ConfigEntryTable.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** ConfigEntryTable.java 2 Jan 2006 03:40:08 -0000 1.11
--- ConfigEntryTable.java 9 Jan 2006 00:52:14 -0000 1.12
***************
*** 77,84 ****
--- 77,102 ----
* Determines whether the Sword Book's conf is supported by JSword.
*/
+ public boolean isQuestionable()
+ {
+ return questionable;
+ }
+
+ /**
+ * Determines whether the Sword Book's conf is supported by JSword.
+ */
public boolean isSupported()
{
return supported;
}
+
+ /**
+ * Determines whether the Sword Book is enciphered and without a key.
+ * @return true if enciphered
+ */
+ public boolean isEnciphered()
+ {
+ String cipher = (String) getValue(ConfigEntryType.CIPHER_KEY);
+ return cipher != null && cipher.length() == 0;
+ }
/**
* Returns an Enumeration of all the keys found in the config file.
***************
*** 477,480 ****
--- 495,503 ----
private void adjustBookType()
{
+ // The book type represents the underlying category of book.
+ // Fine tune it here.
+ BookCategory focusedCategory = BookCategory.fromString(getValue(ConfigEntryType.CATEGORY).toString());
+ questionable = focusedCategory == BookCategory.QUESTIONABLE;
+
// From the config map, extract the important bean properties
String modTypeName = (String) getValue(ConfigEntryType.MOD_DRV);
***************
*** 497,505 ****
if (basicCategory == null)
{
- // We plan to add RawGenBook at a later time. So we don't need to be reminded all the time.
- if (!modTypeName.equals("RawGenBook")) //$NON-NLS-1$
- {
- log.debug("Book not supported: " + internal + " because missing book type for BookType (" + modTypeName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
supported = false;
return;
--- 520,523 ----
***************
*** 508,513 ****
// The book type represents the underlying category of book.
// Fine tune it here.
! BookCategory focusedCategory = BookCategory.fromString(getValue(ConfigEntryType.CATEGORY).toString());
! if (focusedCategory == BookCategory.OTHER)
{
focusedCategory = getBookType().getBookCategory();
--- 526,530 ----
// The book type represents the underlying category of book.
// Fine tune it here.
! if (focusedCategory == BookCategory.OTHER || focusedCategory == BookCategory.QUESTIONABLE)
{
focusedCategory = getBookType().getBookCategory();
***************
*** 533,539 ****
private void validate()
{
! // Only locked books that have a key can be used.
! String cipher = (String) getValue(ConfigEntryType.CIPHER_KEY);
! if (cipher != null && cipher.length() == 0)
{
log.debug("Book not supported: " + internal + " because it is locked and there is no key."); //$NON-NLS-1$ //$NON-NLS-2$
--- 550,554 ----
private void validate()
{
! if (isEnciphered())
{
log.debug("Book not supported: " + internal + " because it is locked and there is no key."); //$NON-NLS-1$ //$NON-NLS-2$
***************
*** 651,654 ****
--- 666,674 ----
/**
+ * True if this book is considered questionable.
+ */
+ private boolean questionable;
+
+ /**
* True if this book's config type can be used by JSword.
*/
Index: SwordBookDriver.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/SwordBookDriver.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** SwordBookDriver.java 27 Jul 2005 23:25:45 -0000 1.45
--- SwordBookDriver.java 9 Jan 2006 00:52:14 -0000 1.46
***************
*** 100,122 ****
sbmd.setDriver(this);
! if (sbmd.isSupported())
! {
! Book book = createBook(sbmd, dirs[j]);
! valid.add(book);
! IndexManager imanager = IndexManagerFactory.getIndexManager();
! if (imanager.isIndexed(book))
! {
! sbmd.setIndexStatus(IndexStatus.DONE);
! }
! else
! {
! sbmd.setIndexStatus(IndexStatus.UNDONE);
! }
}
else
{
! String name = bookdir.substring(0, bookdir.indexOf(SwordConstants.EXTENSION_CONF));
! log.warn("Unsupported Book: " + name); //$NON-NLS-1$
}
}
--- 100,114 ----
sbmd.setDriver(this);
! Book book = createBook(sbmd, dirs[j]);
! valid.add(book);
! IndexManager imanager = IndexManagerFactory.getIndexManager();
! if (imanager.isIndexed(book))
! {
! sbmd.setIndexStatus(IndexStatus.DONE);
}
else
{
! sbmd.setIndexStatus(IndexStatus.UNDONE);
}
}
***************
*** 199,203 ****
/**
* A helper class for the FtpSwordInstaller to tell us that it has copied a
! * new Book into our install dorectory
* @param sbmd The SwordBookMetaData object for the new Book
* @param bookpath The path that we have installed to
--- 191,195 ----
/**
* A helper class for the FtpSwordInstaller to tell us that it has copied a
! * new Book into our install directory
* @param sbmd The SwordBookMetaData object for the new Book
* @param bookpath The path that we have installed to
***************
*** 206,218 ****
public static void registerNewBook(SwordBookMetaData sbmd, File bookpath) throws BookException
{
! if (sbmd.isSupported())
{
! BookDriver[] drivers = Books.installed().getDriversByClass(SwordBookDriver.class);
! for (int i = 0; i < drivers.length; i++)
! {
! SwordBookDriver sdriver = (SwordBookDriver) drivers[i];
! Book book = sdriver.createBook(sbmd, bookpath);
! Books.installed().addBook(book);
! }
}
}
--- 198,207 ----
public static void registerNewBook(SwordBookMetaData sbmd, File bookpath) throws BookException
{
! BookDriver[] drivers = Books.installed().getDriversByClass(SwordBookDriver.class);
! for (int i = 0; i < drivers.length; i++)
{
! SwordBookDriver sdriver = (SwordBookDriver) drivers[i];
! Book book = sdriver.createBook(sbmd, bookpath);
! Books.installed().addBook(book);
}
}
Index: RawLDBackend.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/sword/RawLDBackend.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** RawLDBackend.java 3 Jan 2006 13:25:34 -0000 1.24
--- RawLDBackend.java 9 Jan 2006 00:52:14 -0000 1.25
***************
*** 142,146 ****
// We use 1972 because it is a leap year.
Calendar greg = new GregorianCalendar(1972, Calendar.JANUARY, 1);
! DateFormat NAME_DF = new SimpleDateFormat("d MMMM"); //$NON-NLS-1$
int entrysize = OFFSETSIZE + datasize;
--- 142,146 ----
// We use 1972 because it is a leap year.
Calendar greg = new GregorianCalendar(1972, Calendar.JANUARY, 1);
! DateFormat nameDF = new SimpleDateFormat("d MMMM"); //$NON-NLS-1$
int entrysize = OFFSETSIZE + datasize;
***************
*** 204,208 ****
greg.set(Calendar.MONTH, Integer.parseInt(parts[0]) - 1);
greg.set(Calendar.DATE, Integer.parseInt(parts[1]));
! keytitle = NAME_DF.format(greg.getTime());
}
--- 204,208 ----
greg.set(Calendar.MONTH, Integer.parseInt(parts[0]) - 1);
greg.set(Calendar.DATE, Integer.parseInt(parts[1]));
! keytitle = nameDF.format(greg.getTime());
}
More information about the jsword-svn
mailing list