[jsword-svn] r1273 - 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/jdbc 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/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
Mon Apr 2 11:49:58 MST 2007
Author: dmsmith
Date: 2007-04-02 11:49:57 -0700 (Mon, 02 Apr 2007)
New Revision: 1273
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/jdbc/JDBCBook.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/Msg.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/Msg.properties
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/ser/BookDataCache.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/ser/SerBook.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubBook.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/basic/AbstractPassageBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/Msg.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/Msg.properties
trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.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/BibleToOsis.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/TreeKey.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/GatherAllReferences.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:
Interface changes to allow writing to Books, aka modules.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/ViewSourcePane.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -28,6 +28,7 @@
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
+import java.util.Iterator;
import javax.swing.BorderFactory;
import javax.swing.JButton;
@@ -74,10 +75,20 @@
{
try
{
- String orig = book.getRawData(key);
+ StringBuffer buf = new StringBuffer();
- BookData bdata = book.getData(key);
+ Iterator iter = key.iterator();
+ while (iter.hasNext())
+ {
+ if (buf.length() > 0)
+ {
+ buf.append('\n');
+ }
+ buf.append(book.getRawText((Key) iter.next()));
+ }
+ BookData bdata = book.getText(key);
+
BookMetaData bmd = book.getBookMetaData();
boolean direction = bmd.isLeftToRight();
@@ -100,7 +111,7 @@
ContentHandler html = new PrettySerializingContentHandler(FormatType.CLASSIC_INDENT);
htmlsep.provideSAXEvents(html);
- init(orig, osis.toString(), html.toString());
+ init(buf.toString(), osis.toString(), html.toString());
}
catch (SAXException e)
{
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/textpane/TextPaneBookDataDisplay.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -119,7 +119,7 @@
try
{
- BookData bdata = book.getData(key);
+ BookData bdata = book.getText(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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/biblemapper/src/main/java/org/crosswire/biblemapper/model/LinkArray.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -228,7 +228,7 @@
for (int v=1; v<=BibleInfo.versesInChapter(b, c); v++)
{
Verse find = new Verse(b, c, v);
- BookData bdata = book.getData(find);
+ BookData bdata = book.getText(find);
String text = bdata.getPlainText();
PassageTally temp = (PassageTally) book.find(text);
temp.setOrdering(PassageTally.ORDER_TALLY);
Modified: trunk/biblemapper/src/main/java/org/crosswire/biblemapper/swing/CliMapper.java
===================================================================
--- trunk/biblemapper/src/main/java/org/crosswire/biblemapper/swing/CliMapper.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/biblemapper/src/main/java/org/crosswire/biblemapper/swing/CliMapper.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -101,7 +101,7 @@
for (int v=1; v<=BibleInfo.versesInChapter(b, c); v++)
{
Verse find = new Verse(b, c, v);
- BookData bdata = book.getData(find);
+ BookData bdata = book.getText(find);
String text = bdata.getPlainText();
String quote = IndexSearcher.getPreferredSyntax(PhraseParamWord.class);
text = quote + text + quote;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -54,23 +54,67 @@
void setBookMetaData(BookMetaData bmd);
/**
- * Retrieval: Add to the given document some mark-up for the specified
- * Verses.
+ * Return the text for the key in OSIS.
+ *
* @param key The item to locate
* @return The found Book data
* @throws BookException If anything goes wrong with this method
*/
- BookData getData(Key key) throws BookException;
+ BookData getText(Key key) throws BookException;
/**
* Returns the raw text that getData(Key key) builds into OSIS.
+ *
* @param key The item to locate
* @return The found Book data
* @throws BookException If anything goes wrong with this method
*/
- String getRawData(Key key) throws BookException;
+ String getRawText(Key key) throws BookException;
/**
+ * A Book is writable if the file system allows the underlying files
+ * to be opened for writing and if the driver for the book allows
+ * writing. Ultimately, all drivers should allow writing.
+ * At this time writing is not supported by drivers, so
+ * abstract implementations should return false and let
+ * specific implementations return true otherwise.
+ *
+ * @return true if the book is writable
+ */
+ boolean isWritable();
+
+ /**
+ * Store the raw text for the given key. This will replace/hide any
+ * raw text that already is present. Note: it is the responsibility
+ * of the calling program to ensure that the raw text matches the
+ * character set encoding and markup of the module.
+ *
+ * @param key The item to locate
+ * @param rawData The text to store
+ * @throws BookException If anything goes wrong with this method
+ */
+ void setRawText(Key key, String rawData) throws BookException;
+
+ /**
+ * Store an alias of one key to another. Some Bibles do not have a verse by verse
+ * numbering system but rather meld several verses into one. Thus,
+ * any verse in the range refers to the same verse. Also it may apply
+ * to biblical commentaries that are indexed by Book, Chapter, Verse
+ * and that discuss the Bible at a verse range level. For a dictionary,
+ * it may be used for synonyms.
+ * <p>
+ * It should be an exception to set an alias when that alias already
+ * has raw text. Also, it should be an exception to set an alias to
+ * an alias. However, getRawText(Key) must be able to handle alias chains.
+ * </p>
+ *
+ * @param alias the key that aliases another
+ * @param source the key that holds the text
+ * @throws BookException If anything goes wrong with this method
+ */
+ void setAliasKey(Key alias, Key source) throws BookException;
+
+ /**
* Retrieval: For a given search spec find a list of references to it.
* If there are no matches then null should be returned, otherwise a valid
* Key.
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -38,7 +38,6 @@
import org.crosswire.jsword.passage.Passage;
import org.crosswire.jsword.passage.PassageKeyFactory;
import org.crosswire.jsword.passage.RestrictionType;
-import org.crosswire.jsword.passage.Verse;
import org.crosswire.jsword.passage.VerseRange;
import org.jdom.Element;
@@ -60,7 +59,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
*/
- public BookData getData(Key key) throws BookException
+ public BookData getText(Key key) throws BookException
{
assert key != null;
@@ -89,7 +88,7 @@
while (vit.hasNext())
{
Key verse = (Key) vit.next();
- String txt = getText(verse);
+ String txt = getRawText(verse);
// If the verse is empty then we shouldn't add the verse tag
if (txt.length() > 0)
@@ -133,14 +132,9 @@
protected abstract Filter getFilter();
/**
- * Read the unfiltered data for a given key
- */
- protected abstract String getText(Key key) throws BookException;
-
- /**
* For when we want to add writing functionality
*/
- public void setDocument(Verse verse, BookData bdata) throws BookException
+ public void setDocument(Key key, BookData bdata) throws BookException
{
// For all of the sections
Iterator sit = bdata.getOsis().getChild(OSISUtil.OSIS_ELEMENT_OSISTEXT).getChildren(OSISUtil.OSIS_ELEMENT_DIV).iterator();
@@ -157,7 +151,7 @@
Element overse = (Element) data;
String text = OSISUtil.getPlainText(overse);
- setText(verse, text);
+ setRawText(key, text);
}
else
{
@@ -167,10 +161,13 @@
}
}
- /**
- * Set the unparsed text for a verse to permanent storage.
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#isWritable()
*/
- protected abstract void setText(Verse verse, String text) throws BookException;
+ public boolean isWritable()
+ {
+ return false;
+ }
/* (non-Javadoc)
* @see org.crosswire.jsword.passage.KeyFactory#getEmptyKeyList()
@@ -221,39 +218,39 @@
*/
private static final Logger log = Logger.getLogger(AbstractPassageBook.class);
- /* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getRawData(org.crosswire.jsword.passage.Key)
- */
- public String getRawData(Key key) throws BookException
- {
- assert key != null;
-
- StringBuffer buffer = new StringBuffer();
-
- // For all the ranges in this Passage
- Passage ref = KeyUtil.getPassage(key);
- Iterator rit = ref.rangeIterator(RestrictionType.CHAPTER);
-
- while (rit.hasNext())
- {
- VerseRange range = (VerseRange) rit.next();
-
- // For all the verses in this range
- Iterator vit = range.iterator();
- while (vit.hasNext())
- {
- Verse verse = (Verse) vit.next();
- String txt = getText(verse);
-
- // If the verse is empty then we shouldn't add the verse
- if (txt.length() > 0)
- {
- buffer.append(txt);
- buffer.append('\n');
- }
- }
- }
-
- return buffer.toString();
- }
+// /* (non-Javadoc)
+// * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
+// */
+// public String getRawText(Key key) throws BookException
+// {
+// assert key != null;
+//
+// StringBuffer buffer = new StringBuffer();
+//
+// // For all the ranges in this Passage
+// Passage ref = KeyUtil.getPassage(key);
+// Iterator rit = ref.rangeIterator(RestrictionType.CHAPTER);
+//
+// while (rit.hasNext())
+// {
+// VerseRange range = (VerseRange) rit.next();
+//
+// // For all the verses in this range
+// Iterator vit = range.iterator();
+// while (vit.hasNext())
+// {
+// Key subkey = (Key) vit.next();
+// String txt = getRawText(subkey);
+//
+// // If the verse is empty then we shouldn't add the verse
+// if (txt.length() > 0)
+// {
+// buffer.append(txt);
+// buffer.append('\n');
+// }
+// }
+// }
+//
+// return buffer.toString();
+// }
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/Msg.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/Msg.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/Msg.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -38,6 +38,7 @@
static final Msg DECODE_ERROR = new Msg("ReadingsBook.DecodeError"); //$NON-NLS-1$
static final Msg TITLE = new Msg("ReadingsBookDriver.Title"); //$NON-NLS-1$
static final Msg PARSE_FAIL = new Msg("ReadingsKey.ParseFail"); //$NON-NLS-1$
+ static final Msg DRIVER_READONLY = new Msg("ReadingsKey.DriverReadonly"); //$NON-NLS-1$
/**
* Passthrough ctor
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/Msg.properties
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/Msg.properties 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/Msg.properties 2007-04-02 18:49:57 UTC (rev 1273)
@@ -11,3 +11,4 @@
ReadingsBook.DecodeError=Error decoding: {0}
ReadingsBookDriver.Title=Readings
ReadingsKey.ParseFail=Failed to parse {0}
+ReadingsKey.DriverReadonly=This Book is read-only.
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -127,7 +127,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
*/
- public BookData getData(Key key) throws BookException
+ public BookData getText(Key key) throws BookException
{
if (!(key instanceof ReadingsKey))
{
@@ -185,14 +185,38 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getRawData(org.crosswire.jsword.passage.Key)
+ * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
*/
- public String getRawData(Key key) throws BookException
+ public String getRawText(Key key) throws BookException
{
return ""; //$NON-NLS-1$
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#isWritable()
+ */
+ public boolean isWritable()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
+ */
+ public void setRawText(Key key, String rawData) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.KeyFactory#isValidKey(java.lang.String)
*/
public Key getValidKey(String name)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -106,5 +106,20 @@
*/
public abstract boolean isSupported();
+ /**
+ * A Backend is writable if the file system allows the underlying files
+ * to be opened for writing and if the backend has implemented
+ * writing. Ultimately, all drivers should allow writing.
+ * At this time writing is not supported by backends, so
+ * abstract implementations should return false and let
+ * specific implementations return true otherwise.
+ *
+ * @return true if the book is writable
+ */
+ public boolean isWritable()
+ {
+ return false;
+ }
+
private SwordBookMetaData bmd;
}
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -31,7 +31,6 @@
import org.crosswire.jsword.book.basic.AbstractPassageBook;
import org.crosswire.jsword.book.filter.Filter;
import org.crosswire.jsword.passage.Key;
-import org.crosswire.jsword.passage.Verse;
import org.jdom.Content;
import org.jdom.Element;
@@ -76,10 +75,10 @@
Activator.deactivate(backend);
}
- /**
- * Read the unfiltered data for a given key
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
*/
- protected String getText(Key key) throws BookException
+ public String getRawText(Key key) throws BookException
{
if (backend == null)
{
@@ -123,14 +122,30 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setText(org.crosswire.jsword.passage.Verse, java.lang.String)
+ * @see org.crosswire.jsword.book.Book#isWritable()
*/
- protected void setText(Verse verse, String text) throws BookException
+ public boolean isWritable()
{
+ return backend.isWritable();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
+ */
+ public void setRawText(Key key, String rawData) throws BookException
+ {
throw new BookException(Msg.DRIVER_READONLY);
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.basic.AbstractPassageBook#getFilter()
*/
protected Filter getFilter()
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -113,7 +113,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
*/
- public BookData getData(Key key) throws BookException
+ public BookData getText(Key key) throws BookException
{
checkActive();
@@ -145,9 +145,9 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getRawData(org.crosswire.jsword.passage.Key)
+ * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
*/
- public String getRawData(Key key) throws BookException
+ public String getRawText(Key key) throws BookException
{
checkActive();
@@ -158,6 +158,30 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#isWritable()
+ */
+ public boolean isWritable()
+ {
+ return backend.isWritable();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
+ */
+ public void setRawText(Key key, String rawData) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.KeyFactory#getGlobalKeyList()
*/
public Key getGlobalKeyList()
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -110,7 +110,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
*/
- public BookData getData(Key key) throws BookException
+ public BookData getText(Key key) throws BookException
{
checkActive();
@@ -142,9 +142,9 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getRawData(org.crosswire.jsword.passage.Key)
+ * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
*/
- public String getRawData(Key key) throws BookException
+ public String getRawText(Key key) throws BookException
{
checkActive();
@@ -155,6 +155,30 @@
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#isWritable()
+ */
+ public boolean isWritable()
+ {
+ return backend.isWritable();
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
+ */
+ public void setRawText(Key key, String rawData) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.KeyFactory#getGlobalKeyList()
*/
public Key getGlobalKeyList()
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -79,7 +79,7 @@
Book bible = books.getBook(BIBLE_NAME);
Key key = bible.getKey("Gen 1 1"); //$NON-NLS-1$
- BookData data = bible.getData(key);
+ BookData data = bible.getText(key);
String text = data.getCanonicalText();
System.out.println("The plain text of Gen 1:1 is " + text); //$NON-NLS-1$
@@ -97,7 +97,7 @@
Book bible = Books.installed().getBook(BIBLE_NAME);
Key key = bible.getKey("Gen 1 1"); //$NON-NLS-1$
- BookData data = bible.getData(key);
+ BookData data = bible.getText(key);
SAXEventProvider osissep = data.getSAXEventProvider();
Converter styler = ConverterFactory.getConverter();
@@ -137,7 +137,7 @@
System.out.println("The first Key in the default dictionary is " + first); //$NON-NLS-1$
- BookData data = dict.getData(keys);
+ BookData data = dict.getText(keys);
System.out.println("And the text against that key is " + data.getPlainText()); //$NON-NLS-1$
}
@@ -223,7 +223,7 @@
while (rangeIter.hasNext())
{
Key range = (Key) rangeIter.next();
- BookData data = bible.getData(range);
+ BookData data = bible.getText(range);
SAXEventProvider osissep = data.getSAXEventProvider();
SAXEventProvider htmlsep = new TransformingSAXEventProvider(xslurl, osissep);
String text = XMLUtil.writeToString(htmlsep);
@@ -246,7 +246,7 @@
while (iter.hasNext())
{
Verse verse = (Verse) iter.next();
- BookData data = bible.getData(verse);
+ BookData data = bible.getText(verse);
System.out.println('|' + BibleInfo.getBookName(verse.getBook()) + '|' + verse.getChapter() + '|' + verse.getVerse() + '|' + data.getCanonicalText());
}
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/BibleToOsis.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/BibleToOsis.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/BibleToOsis.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -96,7 +96,7 @@
while (iter.hasNext())
{
Verse verse = (Verse) iter.next();
- String raw = bible.getRawData(verse);
+ String raw = bible.getRawText(verse);
String osisID = verse.getOsisID();
String currentBookName = BibleInfo.getOSISName(verse.getBook());
int currentChapter = verse.getChapter();
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/DictToOsis.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -78,7 +78,7 @@
while (iter.hasNext())
{
Key key = (Key) iter.next();
- BookData bdata = book.getData(key);
+ BookData bdata = book.getText(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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -61,7 +61,6 @@
import org.crosswire.jsword.passage.NoSuchKeyException;
import org.crosswire.jsword.passage.NoSuchVerseException;
import org.crosswire.jsword.passage.PassageTally;
-import org.crosswire.jsword.passage.Verse;
import org.crosswire.jsword.passage.VerseFactory;
/**
@@ -217,10 +216,10 @@
results = tally;
for (int i = 0; i < hits.length(); i++)
{
- Verse verse = VerseFactory.fromString(hits.doc(i).get(LuceneIndex.FIELD_NAME));
+ Key key = VerseFactory.fromString(hits.doc(i).get(LuceneIndex.FIELD_NAME));
// PassageTally understands a score of 0 as the verse not participating
int score = (int) (hits.score(i) * 100 + 1);
- tally.add(verse, score);
+ tally.add(key, score);
}
tally.lowerNormalizeProtection();
tally.lowerEventSuppresionAndTest();
@@ -239,8 +238,8 @@
}
for (int i = 0; i < hits.length(); i++)
{
- Verse verse = VerseFactory.fromString(hits.doc(i).get(LuceneIndex.FIELD_NAME));
- results.addAll(verse);
+ Key key = VerseFactory.fromString(hits.doc(i).get(LuceneIndex.FIELD_NAME));
+ results.addAll(key);
}
if (passage != null)
{
@@ -361,7 +360,7 @@
data = null;
try
{
- data = book.getData(subkey);
+ data = book.getText(subkey);
}
catch (BookException e)
{
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/TreeKey.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/TreeKey.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/TreeKey.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -123,7 +123,7 @@
*/
public Iterator iterator()
{
- return children.iterator();
+ return new KeyIterator(this);
}
/* (non-Javadoc)
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -132,7 +132,7 @@
{
Book bible = bibles[i];
Key key = bible.getKey("Gen 1:1"); //$NON-NLS-1$
- BookData data = bible.getData(key);
+ BookData data = bible.getText(key);
assertNotNull(data);
}
}
@@ -142,7 +142,7 @@
for (int i = 0; i < bibles.length; i++)
{
Book bible = bibles[i];
- BookData data = bible.getData(gen11[i]);
+ BookData data = bible.getText(gen11[i]);
assertNotNull(data);
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/GatherAllReferences.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/GatherAllReferences.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/GatherAllReferences.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -140,7 +140,7 @@
String orig;
try
{
- orig = book.getRawData(key);
+ orig = book.getRawText(key);
}
catch (BookException ex)
{
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -134,7 +134,7 @@
{
//log.debug("reading: "+bmd.getInitials()+"/"+key.getText());
- BookData data = book.getData(key);
+ BookData data = book.getText(key);
if (data.getOsis() == null)
{
log.warn("No output from: "+book.getInitials()+", "+key.getName()); //$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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/test/Speed.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -116,7 +116,7 @@
*/
private void dummyDisplay(Passage ref) throws BookException
{
- book.getData(ref);
+ book.getText(ref);
}
/**
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBBookDataDisplay.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -86,7 +86,7 @@
// boolean direction = bmd.isLeftToRight();
// txtView.applyComponentOrientation(direction ? ComponentOrientation.LEFT_TO_RIGHT : ComponentOrientation.RIGHT_TO_LEFT);
- BookData bdata = book.getData(key);
+ BookData bdata = book.getText(key);
if (bdata == null)
{
// txtView.setURL();
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/display/jdtb/JDTBURLConnection.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -82,7 +82,7 @@
{
try
{
- BookData data = book.getData(key);
+ BookData data = book.getText(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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/passage/PassageListCellRenderer.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -88,7 +88,7 @@
if (text == null)
{
- BookData bdata = bible.getData(range);
+ BookData bdata = bible.getText(range);
String simple = bdata.getCanonicalText();
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/StudyTool.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -50,7 +50,7 @@
public Collection getTranslations(Book bible, String word) throws BookException
{
Key key = bible.find(new DefaultSearchRequest(word, null));
- BookData data = bible.getData(key);
+ BookData data = bible.getText(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.getData(key);
+ BookData data = bible.getText(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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/Verifier.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -123,8 +123,8 @@
try
{
// Read the document from the first bible
- BookData text1 = book1.getData(subkey);
- BookData text2 = book2.getData(subkey);
+ BookData text1 = book1.getText(subkey);
+ BookData text2 = book2.getText(subkey);
// Check - this needs some work
if (!text1.equals(text2))
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/jdbc/JDBCBook.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/jdbc/JDBCBook.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/jdbc/JDBCBook.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -130,9 +130,9 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getText(org.crosswire.jsword.passage.Verse)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
*/
- protected String getText(Key key)
+ public String getRawText(Key key)
{
String reply = ""; //$NON-NLS-1$
ResultSet rs = null;
@@ -176,14 +176,22 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setText(org.crosswire.jsword.passage.Verse, java.lang.String)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
*/
- protected void setText(Verse verse, String text) throws BookException
+ public void setRawText(Key key, String rawData) throws BookException
{
throw new BookException(Msg.DRIVER_READONLY);
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.search.Index#findWord(java.lang.String)
*/
public Key findWord(String word) throws BookException
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/raw/RawBook.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -281,9 +281,9 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getText(org.crosswire.jsword.passage.Verse)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
*/
- protected String getText(Key key)
+ public String getRawText(Key key)
{
StringBuffer retcode = new StringBuffer();
Verse verse = KeyUtil.getVerse(key);
@@ -331,14 +331,22 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setText(org.crosswire.jsword.passage.Verse, java.lang.String)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
*/
- protected void setText(Verse verse, String text) throws BookException
+ public void setRawText(Key key, String rawData) throws BookException
{
throw new BookException(Msg.DRIVER_READONLY);
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.search.Index#findWord(java.lang.String)
*/
public Key findWord(String word)
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/LocalRemoter.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -77,7 +77,7 @@
Book book = lookupBook(uid);
String refstr = method.getParameter(ParamName.PARAM_PASSAGE);
Key ref = book.getKey(refstr);
- BookData data = book.getData(ref);
+ BookData data = book.getText(ref);
SAXEventProvider provider = data.getSAXEventProvider();
SAXHandler handler = new SAXHandler();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/Msg.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/Msg.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/Msg.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -38,6 +38,7 @@
static final Msg REMOTE_NOSUPPORT = new Msg("Converter.RemoteNoSupport"); //$NON-NLS-1$
static final Msg REMOTE_FAIL = new Msg("RemoteBook.Fail"); //$NON-NLS-1$
static final Msg PARSE_FAIL = new Msg("RemoteBook.ParseFail"); //$NON-NLS-1$
+ static final Msg DRIVER_READONLY = new Msg("RemoteBook.DriverReadonly"); //$NON-NLS-1$
/**
* Passthrough ctor#
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/Msg.properties
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/Msg.properties 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/Msg.properties 2007-04-02 18:49:57 UTC (rev 1273)
@@ -11,3 +11,4 @@
Converter.RemoteNoSupport=method not supported. given: {0}
RemoteBook.Fail=Error contacting remote server.
RemoteBook.ParseFail=Failure parsing remote response.
+RemoteBook.DriverReadonly=This Book is read-only.
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/RemoteBook.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -66,7 +66,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.Bible#getData(org.crosswire.jsword.passage.Passage)
*/
- public BookData getData(Key key) throws BookException
+ public BookData getText(Key key) throws BookException
{
try
{
@@ -92,15 +92,39 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getRawData(org.crosswire.jsword.passage.Key)
+ * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
*/
- public String getRawData(Key key) throws BookException
+ public String getRawText(Key key) throws BookException
{
StringBuffer buffer = new StringBuffer();
return buffer.toString();
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#isWritable()
+ */
+ public boolean isWritable()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
+ */
+ public void setRawText(Key key, String rawData) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.Bible#findPassage(org.crosswire.jsword.book.Search)
*/
/* @Override */
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser/SerIndex.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -271,7 +271,7 @@
}
else
{
- BookData data = book.getData(sublist);
+ BookData data = book.getText(sublist);
String text = data.getPlainText();
String[] words = SentenceUtil.getWords(text);
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/ser/BookDataCache.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/ser/BookDataCache.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/ser/BookDataCache.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -36,6 +36,8 @@
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.jsword.book.BookException;
+import org.crosswire.jsword.passage.Key;
+import org.crosswire.jsword.passage.KeyUtil;
import org.crosswire.jsword.passage.Verse;
import org.crosswire.jsword.versification.BibleInfo;
@@ -177,10 +179,17 @@
/**
* Write unparsed data for a given verse
*/
- public void setText(Verse verse, String text) throws BookException
+ public void setRawText(Key key, String text) throws BookException
{
checkActive();
+ Verse verse = KeyUtil.getVerse(key);
+
+ if (verse == null)
+ {
+ throw new BookException(Msg.WRITE_ERROR);
+ }
+
try
{
// Remember where we were so we can read it back later
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/ser/SerBook.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/ser/SerBook.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/ser/SerBook.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -171,9 +171,9 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getText(org.crosswire.jsword.passage.Verse)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
*/
- protected String getText(Key key) throws BookException
+ public String getRawText(Key key) throws BookException
{
Verse verse = KeyUtil.getVerse(key);
@@ -181,14 +181,22 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setText(org.crosswire.jsword.passage.Verse, java.lang.String)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
*/
- protected void setText(Verse verse, String text) throws BookException
+ public void setRawText(Key key, String rawData) throws BookException
{
- cache.setText(verse, text);
+ cache.setRawText(key, rawData);
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.WRITE_ERROR);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.book.local.LocalURLBook#flush()
*
public void flush() throws BookException
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubBook.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubBook.java 2007-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubBook.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -28,7 +28,6 @@
import org.crosswire.jsword.book.filter.Filter;
import org.crosswire.jsword.book.filter.FilterFactory;
import org.crosswire.jsword.passage.Key;
-import org.crosswire.jsword.passage.Verse;
/**
* StubBook is a simple stub implementation of Book that is pretty much
@@ -58,20 +57,27 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getText(org.crosswire.jsword.passage.Verse)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
*/
/* @Override */
- protected String getText(Key key)
+ public String getRawText(Key key)
{
return "stub implementation"; //$NON-NLS-1$
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setText(org.crosswire.jsword.passage.Verse, java.lang.String)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
*/
- /* @Override */
- protected void setText(Verse verse, String text) throws BookException
+ public void setRawText(Key key, String rawData) throws BookException
{
throw new BookException(Msg.DRIVER_READONLY);
}
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
}
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubDictionary.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -56,7 +56,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.Book#getData(org.crosswire.jsword.passage.Key)
*/
- public BookData getData(Key key) throws BookException
+ public BookData getText(Key key) throws BookException
{
assert key != null;
@@ -84,15 +84,39 @@
}
/* (non-Javadoc)
- * @see org.crosswire.jsword.book.Book#getRawData(org.crosswire.jsword.passage.Key)
+ * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
*/
- public String getRawData(Key key) throws BookException
+ public String getRawText(Key key) throws BookException
{
StringBuffer buffer = new StringBuffer();
return buffer.toString();
}
/* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#isWritable()
+ */
+ public boolean isWritable()
+ {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.basic.AbstractPassageBook#setRawText(org.crosswire.jsword.passage.Key, java.lang.String)
+ */
+ public void setRawText(Key key, String rawData) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.jsword.book.Book#setAliasKey(org.crosswire.jsword.passage.Key, org.crosswire.jsword.passage.Key)
+ */
+ public void setAliasKey(Key alias, Key source) throws BookException
+ {
+ throw new BookException(Msg.DRIVER_READONLY);
+ }
+
+ /* (non-Javadoc)
* @see org.crosswire.jsword.passage.KeyFactory#getGlobalKeyList()
*/
public Key getGlobalKeyList()
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-04-01 01:04:13 UTC (rev 1272)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/view/web/DemoServlet.java 2007-04-02 18:49:57 UTC (rev 1273)
@@ -103,7 +103,7 @@
request.setAttribute("next-overview", waiting.getOverview()); //$NON-NLS-1$
}
- BookData data = book.getData(ref);
+ BookData data = book.getText(ref);
SAXEventProvider osissep = data.getSAXEventProvider();
SAXEventProvider htmlsep = style.convert(osissep);
String text = XMLUtil.writeToString(htmlsep);
More information about the jsword-svn
mailing list