[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/basic s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Wed Sep 29 15:21:26 MST 2004
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic
In directory www.crosswire.org:/tmp/cvs-serv8429/java/jsword/org/crosswire/jsword/book/basic
Modified Files:
AbstractBook.java Msg.properties Verifier.java Msg.java
Log Message:
Fixes for [JS-7] and [JS-6]
Lots of search work and re-factoring
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/Msg.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Msg.properties 15 Jun 2004 23:08:43 -0000 1.1
--- Msg.properties 29 Sep 2004 22:21:24 -0000 1.2
***************
*** 7,10 ****
--- 7,11 ----
AbstractBookDriver.DriverReadonly=This Book is read-only.
+ AbstractBookDriver.IndexFail=Failed to initialize the search index
PassageAbstractBook.FilterFail=Filtering input data failed.
Verifier.Start=Copying Bible data to new driver
Index: AbstractBook.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/AbstractBook.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** AbstractBook.java 21 Sep 2004 17:46:23 -0000 1.9
--- AbstractBook.java 29 Sep 2004 22:21:24 -0000 1.10
***************
*** 1,18 ****
package org.crosswire.jsword.book.basic;
- import java.net.URL;
-
import org.crosswire.common.activate.Lock;
import org.crosswire.common.util.ClassUtil;
- import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.Search;
! import org.crosswire.jsword.book.search.SearchEngine;
! import org.crosswire.jsword.book.search.SearchEngineFactory;
! import org.crosswire.jsword.passage.DefaultKeyList;
import org.crosswire.jsword.passage.Key;
- import org.crosswire.jsword.util.Project;
/**
--- 1,19 ----
package org.crosswire.jsword.book.basic;
import org.crosswire.common.activate.Lock;
import org.crosswire.common.util.ClassUtil;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
import org.crosswire.jsword.book.Search;
! import org.crosswire.jsword.book.search.Index;
! import org.crosswire.jsword.book.search.IndexFactory;
! import org.crosswire.jsword.book.search.Matcher;
! import org.crosswire.jsword.book.search.MatcherFactory;
! import org.crosswire.jsword.book.search.Searcher;
! import org.crosswire.jsword.book.search.SearcherFactory;
! import org.crosswire.jsword.book.search.Thesaurus;
! import org.crosswire.jsword.book.search.ThesaurusFactory;
import org.crosswire.jsword.passage.Key;
/**
***************
*** 74,106 ****
}
! /**
! * Called by our children if we need to initialise a SearchEngine
*/
! protected void initSearchEngine()
{
try
{
! URL url = Project.instance().getTempScratchSpace(getBookMetaData().getDriverName() + "-" + getBookMetaData().getInitials(), false); //$NON-NLS-1$
! searcher = SearchEngineFactory.createSearchEngine(this, url);
! }
! catch (Exception ex)
! {
! searcher = null;
! Reporter.informUser(this, ex);
! }
! }
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.Book#find(org.crosswire.jsword.book.Search)
! */
! public Key find(Search match) throws BookException
! {
! if (searcher != null)
! {
! return searcher.findKeyList(match);
}
! else
{
! return new DefaultKeyList();
}
}
--- 75,117 ----
}
! /* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.Searcher#search(org.crosswire.jsword.book.Search)
*/
! public Key find(Search search) throws BookException
{
try
{
! if (index == null)
! {
! index = IndexFactory.getIndexForBook(this);
! }
! if (thesaurus == null)
! {
! thesaurus = ThesaurusFactory.createThesaurus();
! }
!
! if (search.isBestMatch())
! {
! if (matcher == null)
! {
! matcher = MatcherFactory.createMatcher(index, thesaurus);
! }
!
! return matcher.bestMatch(search.getMatch(), search.getRestriction());
! }
! else
! {
! if (searcher == null)
! {
! searcher = SearcherFactory.createSearcher(index);
! }
!
! return searcher.search(search.getMatch(), search.getRestriction());
! }
}
! catch (InstantiationException ex)
{
! throw new BookException(Msg.INDEX_FAIL);
}
}
***************
*** 115,121 ****
/**
! * The search implementation
*/
! private SearchEngine searcher;
/**
--- 126,147 ----
/**
! * The global thesaurus
*/
! private Thesaurus thesaurus;
!
! /**
! * The search index for this book
! */
! private Index index;
!
! /**
! * How do we perform best matches
! */
! private Matcher matcher;
!
! /**
! * How do we perform searches
! */
! private Searcher searcher;
/**
Index: Verifier.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/Verifier.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** Verifier.java 16 Aug 2004 22:08:45 -0000 1.26
--- Verifier.java 29 Sep 2004 22:21:24 -0000 1.27
***************
*** 11,15 ****
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.Search;
- import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.passage.BibleInfo;
import org.crosswire.jsword.passage.Key;
--- 11,14 ----
***************
*** 197,245 ****
* Read from the given source version to generate ourselves
*/
- public void checkPassage(String starts, PrintWriter out) throws BookException
- {
- if (starts == null || starts.equals("")) //$NON-NLS-1$
- {
- checkPassage(out);
- return;
- }
-
- if (!(book1 instanceof Index))
- {
- return;
- }
-
- Job job = JobManager.createJob(Msg.VERIFY_PASSAGES.toString(), Thread.currentThread(), false);
- int count = 0;
- int percent = -1;
-
- // For every word in the word list
- Index index1 = (Index) book1;
- Iterator it = index1.getStartsWith(starts).iterator();
- while (it.hasNext())
- {
- String s = (String) it.next();
- checkSinglePassage(s, out);
-
- // Fire a progress event?
- int newpercent = 100 * count++ / GUESS_WORDS;
- if (percent != newpercent)
- {
- percent = newpercent;
- job.setProgress(percent, Msg.VERIFY_WORDS.toString());
- }
-
- // This could take a long time ...
- Thread.yield();
- if (Thread.currentThread().isInterrupted())
- {
- break;
- }
- }
- }
-
- /**
- * Read from the given source version to generate ourselves
- */
private void checkSinglePassage(String word, PrintWriter out) throws BookException
{
--- 196,199 ----
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/basic/Msg.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Msg.java 13 Jun 2004 22:12:33 -0000 1.8
--- Msg.java 29 Sep 2004 22:21:24 -0000 1.9
***************
*** 30,33 ****
--- 30,34 ----
{
static final Msg DRIVER_READONLY = new Msg("AbstractBookDriver.DriverReadonly"); //$NON-NLS-1$
+ static final Msg INDEX_FAIL = new Msg("AbstractBookDriver.IndexFail"); //$NON-NLS-1$
static final Msg FILTER_FAIL = new Msg("PassageAbstractBook.FilterFail"); //$NON-NLS-1$
static final Msg VERIFY_START = new Msg("Verifier.Start"); //$NON-NLS-1$
More information about the jsword-svn
mailing list