[jsword-svn] r1809 - in trunk: 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/bridge jsword/src/main/java/org/crosswire/jsword/passage 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/ser jsword-limbo/src/main/java/org/crosswire/jsword/book/stub

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Mon Apr 21 17:48:27 MST 2008


Author: dmsmith
Date: 2008-04-21 17:48:24 -0700 (Mon, 21 Apr 2008)
New Revision: 1809

Added:
   trunk/jsword/src/main/java/org/crosswire/jsword/bridge/BibleScope.java
Modified:
   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/RemoteBook.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/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/ReadingsBook.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GenBookBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.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/book/sword/ZVerseBackend.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/DistinctPassage.java
   trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java
Log:
Added contains(key) to Book and to AbstractBackend.
Created BibleScope to determine the what verses are in or not in a Bible.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Book.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -64,6 +64,13 @@
     Iterator getOsisIterator(Key key, boolean allowEmpty) throws BookException;
 
     /**
+     * Returns <tt>true</tt> if this book contains the specified element.
+     * @param key element whose presence in this book is to be tested.
+     * @return <tt>true</tt> if this book contains the specified element.
+     */
+    boolean contains(Key key);
+
+   /**
      * Returns the raw text that getData(Key key) builds into OSIS.
      *
      * @param key The item to locate

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -140,7 +140,7 @@
      * Book?.
      * In some ways this method is more suited to BookMetaData however we do not
      * have a specialization of BookMetaData to fit AbstractPassageBook and it
-     * doesn't like any higher in the hierachy at the moment so I will leave
+     * doesn't like any higher in the hierarchy at the moment so I will leave
      * this here.
      */
     protected abstract Filter getFilter();
@@ -196,7 +196,21 @@
      */
     public final Key getGlobalKeyList()
     {
-        return keyf.getGlobalKeyList();
+        if (global == null)
+        {
+            global = keyf.createEmptyKeyList();
+            Key all = keyf.getGlobalKeyList();
+            Iterator iter = all.iterator();
+            while (iter.hasNext())
+            {
+                Key key = (Key) iter.next();
+                if (contains(key))
+                {
+                    global.addAll(key);
+                }
+            }
+        }
+        return global;
     }
 
     /* (non-Javadoc)
@@ -223,6 +237,11 @@
     }
 
     /**
+     * A cached representation of the global key list.
+     */
+    private Key global;
+
+    /**
      * Our key manager
      */
     private KeyFactory keyf = PassageKeyFactory.instance();

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/readings/ReadingsBook.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -172,6 +172,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        return false;
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
      */
     public String getRawText(Key key) throws BookException

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/AbstractBackend.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -109,6 +109,12 @@
         return null;
     }
 
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.passage.Key#contains(org.crosswire.jsword.passage.Key)
+     */
+    /* @Override */
+    public abstract boolean contains(Key key);
+
     /**
      * Get the text allotted for the given entry
      * @param key The key to fetch

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GenBookBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GenBookBackend.java	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GenBookBackend.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -121,6 +121,28 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.passage.Key#contains(org.crosswire.jsword.passage.Key)
+     */
+    /* @Override */
+    public boolean contains(Key key)
+    {
+        checkActive();
+
+        try
+        {
+            TreeNode node = find(key);
+            byte [] userData = node.getUserData();
+
+            // Some entries may be empty.
+            return (userData.length == 8);
+        }
+        catch (IOException e)
+        {
+            return false;
+        }
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.sword.AbstractBackend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
      */
     /* @Override */

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -61,6 +61,37 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.passage.Key#contains(org.crosswire.jsword.passage.Key)
+     */
+    /* @Override */
+    public boolean contains(Key key)
+    {
+        checkActive();
+
+        Verse verse = KeyUtil.getVerse(key);
+
+        try
+        {
+            int testament = SwordConstants.getTestament(verse);
+            long index = SwordConstants.getIndex(verse);
+
+            // If this is a single testament Bible, return nothing.
+            if (idxRaf[testament] == null)
+            {
+                return false;
+            }
+
+            DataIndex dataIndex = getIndex(idxRaf[testament], index);
+
+            return (dataIndex.getSize() > 0);
+        }
+        catch (IOException ex)
+        {
+            return false;
+        }
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.sword.AbstractBackend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)
      */
     /* @Override */

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBook.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -35,7 +35,7 @@
 import org.jdom.Element;
 
 /**
- * SwordBook is a base class for all sword type books.
+ * SwordBook is a base class for all verse based Sword type books.
  *
  * @see gnu.lgpl.License for license details.
  *      The copyright to this program is held by it's authors.
@@ -76,6 +76,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        return (backend != null && backend.contains(key));
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
      */
     public String getRawText(Key key) throws BookException

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordDictionary.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -93,6 +93,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        return (backend != null && backend.contains(key));
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
      */
     public String getRawText(Key key) throws BookException

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordGenBook.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -133,6 +133,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        return (backend != null && backend.contains(key));
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
      */
     public String getRawText(Key key) throws BookException

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZVerseBackend.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -231,6 +231,41 @@
         active = false;
     }
 
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.passage.Key#contains(org.crosswire.jsword.passage.Key)
+     */
+    /* @Override */
+    public boolean contains(Key key)
+    {
+        checkActive();
+        Verse verse = KeyUtil.getVerse(key);
+
+        try
+        {
+            int testament = SwordConstants.getTestament(verse);
+            long index = SwordConstants.getIndex(verse);
+
+            // If Bible does not contain the desired testament, then false
+            if (compRaf[testament] == null)
+            {
+                return false;
+            }
+
+            // 10 because the index is 10 bytes long for each verse
+            byte[] temp = SwordUtil.readRAF(compRaf[testament], index * COMP_ENTRY_SIZE, COMP_ENTRY_SIZE);
+
+            // If the Bible does not contain the desired verse, return nothing.
+            // Some Bibles have different versification, so the requested verse
+            // may not exist.
+            return (temp != null && temp.length > 0);
+        }
+        catch (IOException e)
+        {
+            return false;
+        }
+
+    }
+
     /*
      * (non-Javadoc)
      * @see org.crosswire.jsword.book.sword.AbstractBackend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String)

Added: trunk/jsword/src/main/java/org/crosswire/jsword/bridge/BibleScope.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/bridge/BibleScope.java	                        (rev 0)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/bridge/BibleScope.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -0,0 +1,146 @@
+/**
+ * Distribution License:
+ * JSword is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License, version 2.1 as published by
+ * the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * The License is available on the internet at:
+ *       http://www.gnu.org/copyleft/lgpl.html
+ * or by writing to:
+ *      Free Software Foundation, Inc.
+ *      59 Temple Place - Suite 330
+ *      Boston, MA 02111-1307, USA
+ *
+ * Copyright: 2008
+ *     The copyright to this program is held by it's authors.
+ *
+ * ID: $Id: BookIndexer.java 1466 2007-07-02 02:48:09Z dmsmith $
+ */
+package org.crosswire.jsword.bridge;
+
+import java.util.Iterator;
+
+import org.crosswire.jsword.book.Book;
+import org.crosswire.jsword.book.BookCategory;
+import org.crosswire.jsword.book.Books;
+import org.crosswire.jsword.passage.Key;
+import org.crosswire.jsword.passage.KeyFactory;
+import org.crosswire.jsword.passage.PassageKeyFactory;
+import org.crosswire.jsword.versification.BibleInfo;
+
+/**
+ * Determines the scope of the Bible.
+ * That is, the verses that are in the Bible and the verses that are not.
+ * This is based upon the KJV versification.
+ * 
+ * @see gnu.lgpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author DM Smith [dmsmith555 at yahoo dot com]
+ */
+public class BibleScope
+{
+
+    public BibleScope(Book book)
+    {
+        this.book = book;
+    }
+
+    /**
+     * Get a key containing all the verses that are in this Bible.
+     * @return verses that are in scope
+     */
+    public Key getInScope()
+    {
+        computeScope();
+        return inScope;
+    }
+
+    /**
+     * Get a key containing all the verses that are not in this Bible.
+     * @return verses that are out of scope
+     */
+    public Key getOutOfScope()
+    {
+        computeScope();
+        return outScope;
+    }
+
+    private void computeScope()
+    {
+        if (inScope == null)
+        {
+            KeyFactory keyf = PassageKeyFactory.instance();
+            Key all = keyf.getGlobalKeyList();
+            inScope = keyf.createEmptyKeyList();
+            outScope = keyf.createEmptyKeyList();
+            Iterator iter = all.iterator();
+            while (iter.hasNext())
+            {
+                Key key = (Key) iter.next();
+                if (book.contains(key))
+                {
+                    inScope.addAll(key);
+                }
+                else
+                {
+                    outScope.addAll(key);
+                }
+            }
+        }
+    }
+
+    private Book book;
+
+    /**
+     * Call with &lt;operation&gt; book.
+     * Where operation can be one of:
+     * <ul>
+     * <li>check - returns "TRUE" or "FALSE" indicating whether the index exists or not</li>
+     * <li>create - (re)create the index</li>
+     * <li>delete - delete the index if it exists</li>
+     * </ul>
+     * And book is the initials of a book, e.g. KJV.
+     * 
+     * @param args
+     */
+    public static void main(String[] args)
+    {
+        if (args.length != 1)
+        {
+            usage();
+        }
+
+        System.err.println("BibleScope " + args[0]); //$NON-NLS-1$
+
+        Book b = Books.installed().getBook(args[0]);
+        if (b == null)
+        {
+            System.err.println("Book not found"); //$NON-NLS-1$
+            System.exit(1);
+        }
+
+        if (!b.getBookCategory().equals(BookCategory.BIBLE))
+        {
+            System.err.println(b.getInitials() + " is not a Bible"); //$NON-NLS-1$
+            System.exit(1);
+        }
+
+        BibleScope scope = new BibleScope(b);
+        BibleInfo.setFullBookName(false); // use short names
+        System.out.println("Scope of KJV versification for " + b.getInitials()); //$NON-NLS-1$
+        System.out.println("In scope     = " + scope.getInScope().getName()); //$NON-NLS-1$
+        System.out.println("Out of scope = " + scope.getOutOfScope().getName()); //$NON-NLS-1$
+    }
+
+    public static void usage()
+    {
+        System.err.println("Usage: BibleScope book"); //$NON-NLS-1$
+        System.exit(1);
+    }
+
+    private Key inScope;
+    private Key outScope;
+}

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/BitwisePassage.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -64,7 +64,7 @@
      * <code>DistinctPassage v2 = new BitwisePassage(v1.toString());</code>
      * Then <code>v1.equals(v2);</code>
      * Theoretically, since there are many ways of representing a BitwisePassage as text
-     * string comparision along the lines of:
+     * string comparison along the lines of:
      * <code>v1.toString().equals(v2.toString())</code> could be false.
      * Practically since toString() is standardized this will be true however.
      * We don't need to worry about thread safety in a ctor since we don't exist yet.
@@ -389,7 +389,7 @@
          */
         public void remove() throws UnsupportedOperationException
         {
-            throw new UnsupportedOperationException();
+            store.clear(next);
         }
 
         /**

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/DistinctPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/DistinctPassage.java	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/DistinctPassage.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -90,7 +90,7 @@
 
         // I want to just do the following
         //   copy.store = (SortedSet) store.clone();
-        // However SortedSet is not Clonable so I can't
+        // However SortedSet is not Cloneable so I can't
         // Watch out for this, I'm not sure if it breaks anything.
         copy.store = new TreeSet();
         copy.store.addAll(store);

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/RocketPassage.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -50,7 +50,7 @@
      * <code>RangedPassage v2 = new RangedPassage(v1.getName());</code>
      * Then <code>v1.equals(v2);</code>
      * Theoretically, since there are many ways of representing a RangedPassage as text
-     * string comparision along the lines of:
+     * string comparison along the lines of:
      * <code>v1.getName().equals(v2.getName())</code> could be false.
      * However since getName() is standardized this will be true.
      * We don't need to worry about thread safety in a ctor since we don't exist yet.
@@ -62,13 +62,8 @@
         super(refs);
     }
 
-    /**
-     * For preformance reasons we may well want to hint to the Passage that we
-     * have done editing it for now and that it is safe to cache certain
-     * values to speed up future reads. Any action taken by this method will be
-     * undone simply by making a future edit, and the only loss in calling
-     * optimizeReads() is a loss of time if you then persist in writing to the
-     * Passage.
+    /* (non-Javadoc)
+     * @see org.crosswire.jsword.passage.AbstractPassage#optimizeReads()
      */
     public void optimizeReads()
     {

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/jdbc/JDBCBook.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -130,6 +130,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        return getRawText(key) != null;
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
      */
     public String getRawText(Key key)

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/raw/RawBook.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -281,6 +281,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        return getRawText(key) != null;
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
      */
     public String getRawText(Key key)

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/remote/RemoteBook.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -100,6 +100,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        return false;
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.Book#getRawText(org.crosswire.jsword.passage.Key)
      */
     public String getRawText(Key key) throws BookException

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/ser/SerBook.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -171,6 +171,21 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        try
+        {
+            return getRawText(key) != null;
+        }
+        catch (BookException e)
+        {
+            return false;
+        }
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
      */
     public String getRawText(Key key) 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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubBook.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -57,6 +57,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        return false;
+    }
+
+    /* (non-Javadoc)
      * @see org.crosswire.jsword.book.basic.AbstractPassageBook#getRawText(org.crosswire.jsword.passage.Key)
      */
     /* @Override */

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	2008-04-21 18:10:46 UTC (rev 1808)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/stub/StubDictionary.java	2008-04-22 00:48:24 UTC (rev 1809)
@@ -98,6 +98,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.crosswire.jsword.book.Book#contains(org.crosswire.jsword.passage.Key)
+     */
+    public boolean contains(Key key)
+    {
+        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




More information about the jsword-svn mailing list