[jsword-svn] r1333 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane biblemapper/src/main/java/org/crosswire/biblemapper/model biblemapper/src/main/java/org/crosswire/biblemapper/swing jsword/src/main/java/org/crosswire/jsword/book jsword/src/main/java/org/crosswire/jsword/book/basic jsword/src/main/java/org/crosswire/jsword/book/readings jsword/src/main/java/org/crosswire/jsword/book/sword jsword/src/main/java/org/crosswire/jsword/examples jsword/src/main/java/org/crosswire/jsword/index/lucene jsword/src/main/java/org/crosswire/jsword/passage jsword/src/test/java/org/crosswire/jsword/book jsword/src/test/java/org/crosswire/jsword/book/test jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage jsword-limbo/src/main/java/org/crosswire/jsword/book jsword-limbo/src/main/java/org/crosswire/jsword/book/basic jsword-limbo/src/main/java/org/crosswire/jsword/book/raw jsword-limbo/src/main/java/org/crosswire/jsword/book/remote jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser jsword-limbo/src/main/java/org/crosswire/jsword/book/stub jsword-limbo/src/main/java/org/crosswire/jsword/view/web
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Fri May 18 12:43:30 MST 2007
Author: dmsmith
Date: 2007-05-18 12:43:29 -0700 (Fri, 18 May 2007)
New Revision: 1333
Modified:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java
trunk/biblemapper/src/main/java/org/crosswire/biblemapper/model/LinkArray.java
trunk/biblemapper/src/main/java/org/crosswire/biblemapper/swing/CliMapper.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBBookDataDisplay.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBURLConnection.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage/PassageListCellRenderer.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/StudyTool.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/Verifier.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/raw/RawBook.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/LocalRemoter.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/RemoteBook.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser/SerIndex.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubDictionary.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/view/web/DemoServlet.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java
trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java
trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/test/Speed.java
Log:
Major refactoring: Prepatory work for parallel Bible view.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -88,7 +88,7 @@
buf.append(book.getRawText((Key) iter.next()));
}
- BookData bdata = book.getText(key);
+ BookData bdata = book.getBookData(key);
BookMetaData bmd = book.getBookMetaData();
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -119,7 +119,7 @@
try
{
- BookData bdata = book.getText(key);
+ BookData bdata = book.getBookData(key);
if (bdata == null)
{
txtView.setText(""); //$NON-NLS-1$
Modified: trunk/biblemapper/src/main/java/org/crosswire/biblemapper/model/LinkArray.java
===================================================================
--- trunk/biblemapper/src/main/java/org/crosswire/biblemapper/model/LinkArray.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/biblemapper/src/main/java/org/crosswire/biblemapper/model/LinkArray.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -32,6 +32,7 @@
import org.crosswire.common.util.Logger;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookData;
+import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.passage.NoSuchVerseException;
import org.crosswire.jsword.passage.PassageTally;
import org.crosswire.jsword.passage.Verse;
@@ -228,8 +229,8 @@
for (int v=1; v<=BibleInfo.versesInChapter(b, c); v++)
{
Verse find = new Verse(b, c, v);
- BookData bdata = book.getText(find);
- String text = bdata.getPlainText();
+ BookData bdata = book.getBookData(find);
+ String text = OSISUtil.getPlainText(bdata.getOsis());
PassageTally temp = (PassageTally) book.find(text);
temp.setOrdering(PassageTally.ORDER_TALLY);
total.addAll(temp);
Modified: trunk/biblemapper/src/main/java/org/crosswire/biblemapper/swing/CliMapper.java
===================================================================
--- trunk/biblemapper/src/main/java/org/crosswire/biblemapper/swing/CliMapper.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/biblemapper/src/main/java/org/crosswire/biblemapper/swing/CliMapper.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -30,6 +30,7 @@
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookFilters;
import org.crosswire.jsword.book.Books;
+import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.book.search.parse.IndexSearcher;
import org.crosswire.jsword.book.search.parse.PhraseParamWord;
import org.crosswire.jsword.passage.Key;
@@ -101,8 +102,8 @@
for (int v=1; v<=BibleInfo.versesInChapter(b, c); v++)
{
Verse find = new Verse(b, c, v);
- BookData bdata = book.getText(find);
- String text = bdata.getPlainText();
+ BookData bdata = book.getBookData(find);
+ String text = OSISUtil.getPlainText(bdata.getOsis());
String quote = IndexSearcher.getPreferredSyntax(PhraseParamWord.class);
text = quote + text + quote;
PassageTally temp = (PassageTally) book.find(text);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -21,6 +21,7 @@
*/
package org.crosswire.jsword.book;
+import java.util.Iterator;
import java.util.Map;
import org.crosswire.common.activate.Activatable;
@@ -54,13 +55,21 @@
void setBookMetaData(BookMetaData bmd);
/**
- * Return the text for the key in OSIS.
+ * Return an iterator that returns each key's OSIS in turn.
*
+ * $param key the Items to locate
+ * @param allowEmpty indicates whether empty keys should be present.
+ */
+ Iterator getOsisIterator(Key key, boolean allowEmpty) throws BookException;
+
+ /**
+ * Return the BookData for the key.
+ *
* @param key The item to locate
* @return The found Book data
* @throws BookException If anything goes wrong with this method
*/
- BookData getText(Key key) throws BookException;
+ BookData getBookData(Key key);
/**
* Returns the raw text that getData(Key key) builds into OSIS.
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BookData.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -21,13 +21,14 @@
*/
package org.crosswire.jsword.book;
+import java.util.Iterator;
+
import org.crosswire.common.xml.JDOMSAXEventProvider;
import org.crosswire.common.xml.SAXEventProvider;
import org.crosswire.jsword.passage.Key;
+import org.jdom.Content;
import org.jdom.Document;
import org.jdom.Element;
-import org.jdom.input.SAXHandler;
-import org.xml.sax.SAXException;
/**
* Basic section of BookData.
@@ -41,89 +42,36 @@
/**
* Ctor
*/
- public BookData(Element osis, Book book, Key key)
+ public BookData(Book book, Key key)
{
- this.osis = osis;
this.book = book;
this.key = key;
}
/**
- * Create a BibleData from a SAXEventProvider
- */
- public BookData(SAXEventProvider provider, Book book, Key key) throws SAXException
- {
- SAXHandler handler = new SAXHandler();
- provider.provideSAXEvents(handler);
- this.osis = handler.getDocument().getRootElement();
- this.book = book;
- this.key = key;
- }
-
- /**
* Accessor for the root OSIS element
*/
- public Element getOsis()
+ public Element getOsis() throws BookException
{
- return osis;
- }
+ if (osis == null)
+ {
+ osis = OSISUtil.createOsisFramework(book.getBookMetaData());
+ Element text = osis.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
+ Element div = OSISUtil.factory().createDiv();
+ text.addContent(div);
- /**
- * Return the text without any extra material.
- * @return The Book's text without markup
- */
- public String getCanonicalText()
- {
- return OSISUtil.getCanonicalText(getOsis());
- }
+ Iterator iter = book.getOsisIterator(key, false);
+ while (iter.hasNext())
+ {
+ Content content = (Content) iter.next();
+ div.addContent(content);
+ }
+ }
- /**
- * A simplified plain text version of the data in this document with all
- * the markup stripped out. This is not as simple as it seems.
- * @return The text without markup
- */
- public String getPlainText()
- {
- return OSISUtil.getPlainText(getOsis());
+ return osis;
}
/**
- * Return just the Strong's numbers.
- * @return The Book's Strong's numbers as a space separated string.
- */
- public String getStrongsNumbers()
- {
- return OSISUtil.getStrongsNumbers(getOsis());
- }
-
- /**
- * Return just the scripture references in the book.
- * @return The Book's scripture references
- */
- public String getReferences()
- {
- return OSISUtil.getReferences(getOsis());
- }
-
- /**
- * Return just the notes in the book.
- * @return The Book's notes
- */
- public String getNotes()
- {
- return OSISUtil.getNotes(getOsis());
- }
-
- /**
- * Return just the headings, both canonical and non-canonical, in the book.
- * @return The Book's headings
- */
- public String getHeadings()
- {
- return OSISUtil.getHeadings(getOsis());
- }
-
- /**
* Check that a BibleData is valid.
* Currently, this does nothing, and isn't used. it was broken when we used
* JAXB, however it wasn't much use then becuase JAXB did a lot to keep the
@@ -138,9 +86,9 @@
* Output the current data as a SAX stream.
* @return A way of posting SAX events
*/
- public SAXEventProvider getSAXEventProvider()
+ public SAXEventProvider getSAXEventProvider() throws BookException
{
- return new JDOMSAXEventProvider(new Document(osis));
+ return new JDOMSAXEventProvider(new Document(getOsis()));
}
/**
@@ -174,7 +122,7 @@
private Key key;
/**
- * The root where we read data from
+ * The complete osis container for the element
*/
private Element osis;
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -515,6 +515,14 @@
{
return new Element(OSIS_ELEMENT_HI);
}
+
+ /**
+ * Text
+ */
+ public Text createText(String text)
+ {
+ return new Text(text);
+ }
}
/**
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -28,6 +28,7 @@
import org.crosswire.common.activate.Lock;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookCategory;
+import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookDriver;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.BookMetaData;
@@ -82,6 +83,16 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
+ */
+ public BookData getBookData(Key key)
+ {
+ assert key != null;
+
+ return new BookData(this, key);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.common.activate.Activatable#deactivate(org.crosswire.common.activate.Lock)
*/
public void deactivate(Lock lock)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -21,6 +21,7 @@
*/
package org.crosswire.jsword.book.basic;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -57,18 +58,14 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
+ * @see org.crosswire.jsword.book.Book#getOsisIterator(org.crosswire.jsword.passage.Key, boolean)
*/
- public BookData getText(Key key) throws BookException
+ public Iterator getOsisIterator(Key key, boolean allowEmpty) throws BookException
{
- assert key != null;
-
+ // TODO(DMS): make the iterator be demand driven
try
{
- Element osis = OSISUtil.createOsisFramework(getBookMetaData());
- Element text = osis.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
- Element div = OSISUtil.factory().createDiv();
- text.addContent(div);
+ List content = new ArrayList();
// For all the ranges in this Passage
Passage ref = KeyUtil.getPassage(key);
@@ -84,7 +81,7 @@
{
Element title = OSISUtil.factory().createTitle();
title.addContent(range.getName());
- div.addContent(title);
+ content.add(title);
}
// For all the verses in this range
@@ -95,16 +92,15 @@
String txt = getRawText(verse);
// If the verse is empty then we shouldn't add the verse tag
- if (txt.length() > 0)
+ if (allowEmpty || txt.length() > 0)
{
List osisContent = getFilter().toOSIS(this, verse, txt);
- addOSIS(verse, div, osisContent);
-
+ addOSIS(verse, content, osisContent);
}
}
}
- return new BookData(osis, this, key);
+ return content.iterator();
}
catch (FilterException ex)
{
@@ -112,6 +108,16 @@
}
}
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
+ */
+ public BookData getBookData(Key key)
+ {
+ assert key != null;
+
+ return new BookData(this, key);
+ }
+
/**
* Add the OSIS elements to the div element. Note, this assumes that
* the data is fully marked up.
@@ -126,6 +132,19 @@
}
/**
+ * Add the OSIS elements to the div element. Note, this assumes that
+ * the data is fully marked up.
+ * @param key The key being added
+ * @param div The div element to which the key is being added
+ * @param osisContent The OSIS representation of the key being added.
+ */
+ public void addOSIS(Key key, List content, List osisContent)
+ {
+ assert key != null;
+ content.addAll(osisContent);
+ }
+
+ /**
* What filter should be used to filter data in the format produced by this
* Book?.
* In some ways this method is more suited to BookMetaData however we do not
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -21,9 +21,11 @@
*/
package org.crosswire.jsword.book.readings;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
@@ -33,7 +35,6 @@
import org.crosswire.common.util.CWClassLoader;
import org.crosswire.common.util.Logger;
import org.crosswire.jsword.book.BookCategory;
-import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.FeatureType;
import org.crosswire.jsword.book.OSISUtil;
@@ -43,7 +44,6 @@
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.KeyFactory;
import org.crosswire.jsword.passage.NoSuchKeyException;
-import org.crosswire.jsword.passage.NoSuchVerseException;
import org.crosswire.jsword.passage.Passage;
import org.crosswire.jsword.passage.PassageKeyFactory;
import org.crosswire.jsword.passage.PreferredKey;
@@ -123,64 +123,52 @@
return new ReadingsKey(greg.getTime());
}
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
- */
- public BookData getText(Key key) throws BookException
+ public Iterator getOsisIterator(Key key, boolean allowEmpty) throws BookException
{
if (!(key instanceof ReadingsKey))
{
throw new BookException(Msg.NOT_FOUND, new Object[] { key.getName() });
}
+ // TODO(DMS): make the iterator be demand driven
+ List content = new ArrayList();
+
+ Element title = OSISUtil.factory().createTitle();
+ title.addContent(key.getName());
+ content.add(title);
+
+ String readings = (String) hash.get(key);
+ if (readings == null)
+ {
+ throw new BookException(Msg.NOT_FOUND, new Object[] { key.getName() });
+ }
+
try
{
- Element osis = OSISUtil.createOsisFramework(getBookMetaData());
- Element text = osis.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
+ KeyFactory keyf = PassageKeyFactory.instance();
+ Passage ref = (Passage) keyf.getKey(readings);
- Element div = OSISUtil.factory().createDiv();
- Element title = OSISUtil.factory().createTitle();
- title.addContent(key.getName());
- div.addContent(title);
- text.addContent(div);
-
- String readings = (String) hash.get(key);
- if (readings == null)
+ Element list = OSISUtil.factory().createList();
+ content.add(list);
+ for (Iterator it = ref.rangeIterator(RestrictionType.NONE); it.hasNext(); )
{
- throw new BookException(Msg.NOT_FOUND, new Object[] { key.getName() });
- }
+ VerseRange range = (VerseRange) it.next();
- try
- {
- KeyFactory keyf = PassageKeyFactory.instance();
- Passage ref = (Passage) keyf.getKey(readings);
+ Element reading = OSISUtil.factory().createReference();
+ reading.setAttribute(OSISUtil.OSIS_ATTR_REF, range.getOsisRef());
+ reading.addContent(range.getName());
- Element list = OSISUtil.factory().createList();
- div.addContent(list);
- for (Iterator it = ref.rangeIterator(RestrictionType.NONE); it.hasNext(); )
- {
- VerseRange range = (VerseRange) it.next();
-
- Element reading = OSISUtil.factory().createReference();
- reading.setAttribute(OSISUtil.OSIS_ATTR_REF, range.getOsisRef());
- reading.addContent(range.getName());
-
- Element item = OSISUtil.factory().createItem();
- item.addContent(reading);
- list.addContent(item);
- }
+ Element item = OSISUtil.factory().createItem();
+ item.addContent(reading);
+ list.addContent(item);
}
- catch (NoSuchVerseException ex)
- {
- div.addContent(Msg.DECODE_ERROR.toString(readings));
- }
-
- return new BookData(osis, this, key);
}
catch (NoSuchKeyException ex)
{
- throw new BookException(Msg.FILTER_FAIL, ex);
+ content.add(OSISUtil.factory().createText(Msg.DECODE_ERROR.toString(readings)));
}
+
+ return content.iterator();
}
/* (non-Javadoc)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -121,6 +121,33 @@
super.addOSIS(key, everse, osisContent);
}
+ public void addOSIS(Key key, List contentList, List osisContent)
+ {
+ // See if the text is marked up with verses
+ // If it is then just add it.
+ Iterator iter = osisContent.iterator();
+ while (iter.hasNext())
+ {
+ Content content = (Content) iter.next();
+ if (content instanceof Element)
+ {
+ Element ele = (Element) content;
+ if (ele.getName().equals(OSISUtil.OSIS_ELEMENT_VERSE))
+ {
+ super.addOSIS(key, contentList, osisContent);
+ return;
+ }
+ }
+ }
+
+ // If we get here then the text is not marked up with verse
+ // In this case we add the verse markup.
+ Element everse = OSISUtil.factory().createVerse();
+ everse.setAttribute(OSISUtil.OSIS_ATTR_OSISID, key.getOsisID());
+ super.addOSIS(key, everse, osisContent);
+ contentList.add(everse);
+ }
+
/* (non-Javadoc)
* @see org.crosswire.jsword.book.Book#isWritable()
*/
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -22,6 +22,7 @@
package org.crosswire.jsword.book.sword;
import java.text.DecimalFormat;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -31,7 +32,6 @@
import org.crosswire.common.activate.Activator;
import org.crosswire.common.activate.Lock;
-import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.book.basic.AbstractBook;
@@ -111,9 +111,9 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
+ * @see org.crosswire.jsword.book.Book#getOsisIterator(org.crosswire.jsword.passage.Key, boolean)
*/
- public BookData getText(Key key) throws BookException
+ public Iterator getOsisIterator(Key key, boolean allowEmpty) throws BookException
{
checkActive();
@@ -122,21 +122,17 @@
try
{
- Element osis = OSISUtil.createOsisFramework(getBookMetaData());
- Element text = osis.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
-
- Element div = OSISUtil.factory().createDiv();
+ List content = new ArrayList();
Element title = OSISUtil.factory().createTitle();
title.addContent(key.getName());
- div.addContent(title);
- text.addContent(div);
+ content.add(title);
String txt = backend.getRawText(key);
List osisContent = sbmd.getFilter().toOSIS(this, key, txt);
- div.addContent(osisContent);
+ content.addAll(osisContent);
- return new BookData(osis, this, key);
+ return content.iterator();
}
catch (FilterException ex)
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -21,6 +21,7 @@
*/
package org.crosswire.jsword.book.sword;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -28,16 +29,13 @@
import org.crosswire.common.activate.Activator;
import org.crosswire.common.activate.Lock;
-import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
-import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.book.basic.AbstractBook;
import org.crosswire.jsword.book.filter.FilterException;
import org.crosswire.jsword.passage.DefaultKeyList;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.NoSuchKeyException;
import org.crosswire.jsword.passage.ReadOnlyKeyList;
-import org.jdom.Element;
/**
* A Sword version of Dictionary.
@@ -108,9 +106,9 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
+ * @see org.crosswire.jsword.book.Book#getOsisIterator(org.crosswire.jsword.passage.Key, boolean)
*/
- public BookData getText(Key key) throws BookException
+ public Iterator getOsisIterator(Key key, boolean allowEmpty) throws BookException
{
checkActive();
@@ -119,18 +117,14 @@
try
{
- Element osis = OSISUtil.createOsisFramework(getBookMetaData());
- Element text = osis.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
+ List content = new ArrayList();
- Element div = OSISUtil.factory().createDiv();
- text.addContent(div);
-
String txt = backend.getRawText(key);
List osisContent = sbmd.getFilter().toOSIS(this, key, txt);
- div.addContent(osisContent);
+ content.addAll(osisContent);
- return new BookData(osis, this, key);
+ return content.iterator();
}
catch (FilterException ex)
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -42,6 +42,7 @@
import org.crosswire.jsword.book.Books;
import org.crosswire.jsword.book.BooksEvent;
import org.crosswire.jsword.book.BooksListener;
+import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.index.search.DefaultSearchModifier;
import org.crosswire.jsword.index.search.DefaultSearchRequest;
import org.crosswire.jsword.passage.Key;
@@ -80,8 +81,8 @@
Book bible = books.getBook(BIBLE_NAME);
Key key = bible.getKey("Gen 1 1"); //$NON-NLS-1$
- BookData data = bible.getText(key);
- String text = data.getCanonicalText();
+ BookData data = bible.getBookData(key);
+ String text = OSISUtil.getCanonicalText(data.getOsis());
System.out.println("The plain text of Gen 1:1 is " + text); //$NON-NLS-1$
}
@@ -98,7 +99,7 @@
Book bible = Books.installed().getBook(BIBLE_NAME);
Key key = bible.getKey("Gen 1 1"); //$NON-NLS-1$
- BookData data = bible.getText(key);
+ BookData data = bible.getBookData(key);
SAXEventProvider osissep = data.getSAXEventProvider();
Converter styler = ConverterFactory.getConverter();
@@ -138,8 +139,8 @@
System.out.println("The first Key in the default dictionary is " + first); //$NON-NLS-1$
- BookData data = dict.getText(keys);
- System.out.println("And the text against that key is " + data.getPlainText()); //$NON-NLS-1$
+ BookData data = dict.getBookData(keys);
+ System.out.println("And the text against that key is " + OSISUtil.getPlainText(data.getOsis())); //$NON-NLS-1$
}
/**
@@ -224,7 +225,7 @@
while (rangeIter.hasNext())
{
Key range = (Key) rangeIter.next();
- BookData data = bible.getText(range);
+ BookData data = bible.getBookData(range);
SAXEventProvider osissep = data.getSAXEventProvider();
SAXEventProvider htmlsep = new TransformingSAXEventProvider(NetUtil.toURI(xslurl), osissep);
String text = XMLUtil.writeToString(htmlsep);
@@ -247,8 +248,8 @@
while (iter.hasNext())
{
Verse verse = (Verse) iter.next();
- BookData data = bible.getText(verse);
- System.out.println('|' + BibleInfo.getBookName(verse.getBook()) + '|' + verse.getChapter() + '|' + verse.getVerse() + '|' + data.getCanonicalText());
+ BookData data = bible.getBookData(verse);
+ System.out.println('|' + BibleInfo.getBookName(verse.getBook()) + '|' + verse.getChapter() + '|' + verse.getVerse() + '|' + OSISUtil.getCanonicalText(data.getOsis()));
}
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -78,7 +78,7 @@
while (iter.hasNext())
{
Key key = (Key) iter.next();
- BookData bdata = book.getText(key);
+ BookData bdata = book.getBookData(key);
SAXEventProvider osissep = bdata.getSAXEventProvider();
try
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -53,6 +53,7 @@
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.FeatureType;
+import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.index.AbstractIndex;
import org.crosswire.jsword.index.IndexStatus;
import org.crosswire.jsword.index.search.SearchModifier;
@@ -62,6 +63,7 @@
import org.crosswire.jsword.passage.NoSuchVerseException;
import org.crosswire.jsword.passage.PassageTally;
import org.crosswire.jsword.passage.VerseFactory;
+import org.jdom.Element;
/**
* Implement the SearchEngine using Lucene as the search engine.
@@ -347,13 +349,10 @@
int percent = 0;
String rootName = ""; //$NON-NLS-1$
String text = ""; //$NON-NLS-1$
- String strongs = ""; //$NON-NLS-1$
- String xrefs = ""; //$NON-NLS-1$
- String notes = ""; //$NON-NLS-1$
- String headings = ""; //$NON-NLS-1$
BookData data = null;
Key subkey = null;
Document doc = null;
+ Element osis = null;
int size = key.getCardinality();
int subCount = count;
for (Iterator it = key.iterator(); it.hasNext(); )
@@ -365,10 +364,12 @@
}
else
{
- data = null;
+ data = book.getBookData(subkey);
+ osis = null;
+
try
{
- data = book.getText(subkey);
+ osis = data.getOsis();
}
catch (BookException e)
{
@@ -376,55 +377,37 @@
continue;
}
- text = data.getCanonicalText();
- if (hasStrongs)
- {
- strongs = data.getStrongsNumbers();
- }
-
// Do the actual indexing
+ text = OSISUtil.getCanonicalText(osis);
if (text != null && text.length() > 0)
{
doc = new Document();
doc.add(new Field(FIELD_KEY, subkey.getOsisRef(), Field.Store.YES, Field.Index.UN_TOKENIZED));
doc.add(new Field(FIELD_BODY, new StringReader(text)));
+ }
- if (hasStrongs)
- {
- strongs = data.getStrongsNumbers();
- if (strongs != null && strongs.length() > 0)
- {
- doc.add(new Field(FIELD_STRONG, strongs, Field.Store.NO, Field.Index.TOKENIZED));
- }
- }
+ if (hasStrongs)
+ {
+ doc = addField(doc, FIELD_STRONG, OSISUtil.getStrongsNumbers(osis));
+ }
- if (hasXRefs)
- {
- xrefs = data.getReferences();
- if (xrefs != null && xrefs.length() > 0)
- {
- doc.add(new Field(FIELD_XREF, xrefs, Field.Store.NO, Field.Index.TOKENIZED));
- }
- }
+ if (hasXRefs)
+ {
+ doc = addField(doc, FIELD_XREF, OSISUtil.getReferences(osis));
+ }
- if (hasNotes)
- {
- notes = data.getNotes();
- if (notes != null && notes.length() > 0)
- {
- doc.add(new Field(FIELD_NOTE, notes, Field.Store.NO, Field.Index.TOKENIZED));
- }
- }
+ if (hasNotes)
+ {
+ doc = addField(doc, FIELD_NOTE, OSISUtil.getNotes(osis));
+ }
- if (hasHeadings)
- {
- headings = data.getHeadings();
- if (headings != null && headings.length() > 0)
- {
- doc.add(new Field(FIELD_HEADING, headings, Field.Store.NO, Field.Index.TOKENIZED));
- }
- }
+ if (hasHeadings)
+ {
+ doc = addField(doc, FIELD_HEADING, OSISUtil.getHeadings(osis));
+ }
+ if (doc != null)
+ {
writer.addDocument(doc);
}
@@ -451,6 +434,20 @@
}
}
+ private Document addField(Document theDoc, String field, String text)
+ {
+ Document doc = theDoc;
+ if (text != null && text.length() > 0)
+ {
+ if (doc == null)
+ {
+ doc = new Document();
+ }
+ doc.add(new Field(field, text, Field.Store.NO, Field.Index.TOKENIZED));
+ }
+ return doc;
+ }
+
/**
* A synchronization lock point to prevent us from doing 2 index runs at a time.
*/
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -120,14 +120,6 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.passage.AbstractPassage#rangeIterator()
- */
- public Iterator rangeIterator(RestrictionType restrict)
- {
- return new VerseRangeIterator(iterator(), restrict);
- }
-
- /* (non-Javadoc)
* @see org.crosswire.jsword.passage.Passage#contains(org.crosswire.jsword.passage.VerseBase)
*/
public boolean contains(Key obj)
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -132,7 +132,7 @@
{
Book bible = bibles[i];
Key key = bible.getKey("Gen 1:1"); //$NON-NLS-1$
- BookData data = bible.getText(key);
+ BookData data = bible.getBookData(key);
assertNotNull(data);
}
}
@@ -142,7 +142,7 @@
for (int i = 0; i < bibles.length; i++)
{
Book bible = bibles[i];
- BookData data = bible.getText(gen11[i]);
+ BookData data = bible.getBookData(gen11[i]);
assertNotNull(data);
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -134,7 +134,7 @@
{
//log.debug("reading: "+bmd.getInitials()+"/"+key.getText());
- BookData data = book.getText(key);
+ BookData data = book.getBookData(key);
if (data.getOsis() == null)
{
log.warn("No output from: "+book.getInitials()+", "+key.getName()); //$NON-NLS-1$ //$NON-NLS-2$
@@ -143,16 +143,6 @@
// This might be a useful extra test, except that a failure gives you no help at all.
//data.validate();
}
- /*
- catch (ValidationException ex)
- {
- log.warn("Validation error reading: "+book.getInitials()+", "+key.getText()+", code:"+ex.getErrorCode()+" reason: "+ex.getMessage());
- }
- */
- catch (BookException ex)
- {
- log.warn("Failed to read: "+book.getInitials()+", "+key.getName()+", reason: "+ex.getMessage(), ex); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
catch (Throwable ex)
{
log.error("Unexpected error reading: "+book.getInitials()+", "+key.getName(), ex); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/test/Speed.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/test/Speed.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/test/Speed.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -116,7 +116,7 @@
*/
private void dummyDisplay(Passage ref) throws BookException
{
- book.getText(ref);
+ book.getBookData(ref).getOsis();
}
/**
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBBookDataDisplay.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBBookDataDisplay.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBBookDataDisplay.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -86,7 +86,7 @@
// boolean direction = bmd.isLeftToRight();
// txtView.applyComponentOrientation(direction ? ComponentOrientation.LEFT_TO_RIGHT : ComponentOrientation.RIGHT_TO_LEFT);
- BookData bdata = book.getText(key);
+ BookData bdata = book.getBookData(key);
if (bdata == null)
{
// txtView.setURI();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBURLConnection.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBURLConnection.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBURLConnection.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -82,7 +82,7 @@
{
try
{
- BookData data = book.getText(key);
+ BookData data = book.getBookData(key);
BookMetaData bmd = book.getBookMetaData();
boolean direction = bmd.isLeftToRight();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage/PassageListCellRenderer.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage/PassageListCellRenderer.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage/PassageListCellRenderer.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -37,6 +37,7 @@
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookData;
+import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.passage.VerseRange;
/**
@@ -88,8 +89,8 @@
if (text == null)
{
- BookData bdata = bible.getText(range);
- String simple = bdata.getCanonicalText();
+ BookData bdata = bible.getBookData(range);
+ String simple = OSISUtil.getCanonicalText(bdata.getOsis());
text = "<html><b>" + range.getName() + "</b> " + simple; //$NON-NLS-1$ //$NON-NLS-2$
hash.put(range, text);
}
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/StudyTool.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/StudyTool.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/StudyTool.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -50,7 +50,7 @@
public Collection getTranslations(Book bible, String word) throws BookException
{
Key key = bible.find(new DefaultSearchRequest(word, null));
- BookData data = bible.getText(key);
+ BookData data = bible.getBookData(key);
Map reply = new HashMap();
@@ -106,7 +106,7 @@
public Collection getTranslations(Book bible, Strongs number) throws BookException
{
Key key = bible.find(new DefaultSearchRequest(number.getOLBName(), null));
- BookData data = bible.getText(key);
+ BookData data = bible.getBookData(key);
Map reply = new HashMap();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/Verifier.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/Verifier.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/Verifier.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -123,8 +123,8 @@
try
{
// Read the document from the first bible
- BookData text1 = book1.getText(subkey);
- BookData text2 = book2.getText(subkey);
+ BookData text1 = book1.getBookData(subkey);
+ BookData text2 = book2.getBookData(subkey);
// Check - this needs some work
if (!text1.equals(text2))
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/raw/RawBook.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/raw/RawBook.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/raw/RawBook.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -398,10 +398,7 @@
return ((WordItemsMem) wordItems).getStartsWith(word);
}
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractBible#setDocument(org.crosswire.jsword.passage.Verse, org.crosswire.jsword.book.filter.BookData)
- */
- public void setDocument(Verse verse, BookData bdata)
+ public void setDocument(Verse verse, BookData bdata) throws BookException
{
// For all of the sections
Iterator sit = bdata.getOsis().getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT).getChildren(OSISUtil.OSIS_ELEMENT_DIV).iterator();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/LocalRemoter.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/LocalRemoter.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/LocalRemoter.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -77,7 +77,7 @@
Book book = lookupBook(uid);
String refstr = method.getParameter(ParamName.PARAM_PASSAGE);
Key ref = book.getKey(refstr);
- BookData data = book.getText(ref);
+ BookData data = book.getBookData(ref);
SAXEventProvider provider = data.getSAXEventProvider();
SAXHandler handler = new SAXHandler();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/RemoteBook.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/RemoteBook.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/RemoteBook.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -21,11 +21,14 @@
*/
package org.crosswire.jsword.book.remote;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import org.crosswire.common.util.Logger;
import org.crosswire.common.xml.JDOMSAXEventProvider;
import org.crosswire.common.xml.SAXEventProvider;
import org.crosswire.jsword.book.BookCategory;
-import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.basic.AbstractBook;
import org.crosswire.jsword.book.basic.DefaultBookMetaData;
@@ -36,6 +39,7 @@
import org.crosswire.jsword.passage.Passage;
import org.crosswire.jsword.passage.PassageKeyFactory;
import org.jdom.Document;
+import org.jdom.input.SAXHandler;
import org.xml.sax.SAXException;
/**
@@ -64,9 +68,9 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Bible#getData(org.crosswire.jsword.passage.Passage)
+ * @see org.crosswire.jsword.book.Book#getOsisIterator(org.crosswire.jsword.passage.Key, boolean)
*/
- public BookData getText(Key key) throws BookException
+ public Iterator getOsisIterator(Key key, boolean allowEmpty) throws BookException
{
try
{
@@ -78,8 +82,12 @@
Document doc = remoter.execute(method);
SAXEventProvider provider = new JDOMSAXEventProvider(doc);
+ SAXHandler handler = new SAXHandler();
+ provider.provideSAXEvents(handler);
- return new BookData(provider, this, key);
+ List content = new ArrayList();
+ content.add(handler.getDocument().getRootElement());
+ return content.iterator();
}
catch (RemoterException ex)
{
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser/SerIndex.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser/SerIndex.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser/SerIndex.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -48,6 +48,7 @@
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
+import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.book.SentenceUtil;
import org.crosswire.jsword.book.search.Grammar;
import org.crosswire.jsword.book.search.Thesaurus;
@@ -273,8 +274,8 @@
}
else
{
- BookData data = book.getText(sublist);
- String text = data.getPlainText();
+ BookData data = book.getBookData(sublist);
+ String text = OSISUtil.getPlainText(data.getOsis());
String[] words = SentenceUtil.getWords(text);
for (int i = 0; i < words.length; i++)
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubDictionary.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubDictionary.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubDictionary.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -21,10 +21,11 @@
*/
package org.crosswire.jsword.book.stub;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.crosswire.jsword.book.BookCategory;
-import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.OSISUtil;
import org.crosswire.jsword.book.basic.AbstractBook;
@@ -54,28 +55,24 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
+ * @see org.crosswire.jsword.book.Book#getOsisIterator(org.crosswire.jsword.passage.Key, boolean)
*/
- public BookData getText(Key key) throws BookException
+ public Iterator getOsisIterator(Key key, boolean allowEmpty) throws BookException
{
assert key != null;
try
{
- Element osis = OSISUtil.createOsisFramework(getBookMetaData());
- Element text = osis.getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT);
-
- Element div = OSISUtil.factory().createDiv();
+ List content = new ArrayList();
+
Element title = OSISUtil.factory().createTitle();
title.addContent(key.getName());
- div.addContent(title);
- text.addContent(div);
+ content.add(title);
List osisContent = FilterFactory.getDefaultFilter().toOSIS(this, key, "stub implementation"); //$NON-NLS-1$
- div.addContent(osisContent);
+ content.add(osisContent);
- BookData bdata = new BookData(osis, this, key);
- return bdata;
+ return content.iterator();
}
catch (Exception ex)
{
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/view/web/DemoServlet.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/view/web/DemoServlet.java 2007-05-18 11:42:14 UTC (rev 1332)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/view/web/DemoServlet.java 2007-05-18 19:43:29 UTC (rev 1333)
@@ -103,7 +103,7 @@
request.setAttribute("next-overview", waiting.getOverview()); //$NON-NLS-1$
}
- BookData data = book.getText(ref);
+ BookData data = book.getBookData(ref);
SAXEventProvider osissep = data.getSAXEventProvider();
SAXEventProvider htmlsep = style.convert(osissep);
String text = XMLUtil.writeToString(htmlsep);
More information about the jsword-svn
mailing list