[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Fri Mar 18 18:56:49 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book
In directory www.crosswire.org:/tmp/cvs-serv10359/java/jsword/org/crosswire/jsword/book

Modified Files:
	Books.java BookFilters.java BookList.java BookMetaData.java 
	Defaults.java Msg.java Book.java Msg.properties 
	BooksEvent.java BookFilter.java BookFilterIterator.java 
	BookDriver.java 
Added Files:
	BookSet.java 
Removed Files:
	BookMetaDataSet.java 
Log Message:
Made Book the primary interface to a module and put BookMetaData within it. All of BookMetaData is accessible through the Book interface.

--- NEW FILE: BookSet.java ---
package org.crosswire.jsword.book;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

import org.crosswire.common.util.Filter;
import org.crosswire.common.util.SortedListSet;

/**
 * BookSet represents a collection of descriptions about Books
 * which may be subsetted into other BookMetaDataSets.
 * Each set is naturally ordered.
 * 
 * <p><table border='1' cellPadding='3' cellSpacing='0'>
 * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
 *
 * Distribution Licence:<br />
 * JSword is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public License,
 * version 2 as published by the Free Software Foundation.<br />
 * 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
 * General Public License for more details.<br />
 * The License is available on the internet
 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, or by writing to:
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA<br />
 * The copyright to this program is held by it's authors.
 * </font></td></tr></table>
 * @see gnu.gpl.Licence
 * @author DM Smith [dmsmith555 at yahoo dot com]
 * @version $Id: BookSet.java,v 1.1 2005/03/19 01:56:47 dmsmith Exp $
 */
public class BookSet extends SortedListSet
{

    public BookSet()
    {
        super();
    }

    public BookSet(Collection books)
    {
        super(books);
    }

    /**
     * Gets the sorted set of all keys which can be used for groupings.
     * These are all the property keys across the BookMetaDatas in this list.
     * @return the set of all keys which can be used for grouping.
     */
    public Set getGroups()
    {
        Set results = new TreeSet();
        Iterator bookIter = iterator();
        while (bookIter.hasNext())
        {
            Book book = (Book) bookIter.next();
            results.addAll(book.getProperties().keySet());
        }
        return results;
    }

    /**
     * Get the sorted set of all values for a particular key.
     * If there is a BookMetaData that does not have a value
     * for that key, then null will be in the set. This can be use
     * to categorize books that don't have that key.
     * For example, "Language" will return all the languages
     * for this BookMetaDataList and null for which the language
     * is unknown.
     * @param key
     * @return the values for a particular key.
     */
    public Set getGroup(String key)
    {
        Set results = new TreeSet();
        Iterator bookIter = iterator();
        while (bookIter.hasNext())
        {
            Book book = (Book) bookIter.next();
            Object property = book.getProperties().get(key);
            String propertyValue = property == null ? Msg.BOOK_METADATA_SET_OTHER.toString() : property.toString();
            results.add(propertyValue);
        }
        return results;
    }

    public BookSet filter(String key, String value)
    {
        return (BookSet) filter(new GroupFilter(key, value));
    }

    /**
     * GroupFilter does the SQL traditional group by.
     */
    private static final class GroupFilter implements Filter
    {
        public GroupFilter(String aKey, String aValue)
        {
            key = aKey;
            value = aValue;
        }

        public boolean test(Object obj)
        {
            Book book = (Book) obj;
            return book.getProperties().get(key) == value;
        }
        private String key;
        private String value;
    }

    /**
     * Serialization ID
     */
    private static final long serialVersionUID = 3258688806185154867L;
}

Index: BookList.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BookList.java	8 Feb 2004 23:03:17 -0000	1.1
--- BookList.java	19 Mar 2005 01:56:47 -0000	1.2
***************
*** 35,39 ****
       * Get an iterator over all the Books of all types.
       */
!     public List getBookMetaDatas();
  
      /**
--- 35,39 ----
       * Get an iterator over all the Books of all types.
       */
!     public List getBooks();
  
      /**
***************
*** 41,45 ****
       * @see BookFilters
       */
!     public List getBookMetaDatas(BookFilter filter);
  
      /**
--- 41,45 ----
       * @see BookFilters
       */
!     public List getBooks(BookFilter filter);
  
      /**

Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Msg.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** Msg.java	25 Jan 2005 00:02:32 -0000	1.18
--- Msg.java	19 Mar 2005 01:56:47 -0000	1.19
***************
*** 48,52 ****
      static final Msg OPEN_COMMERCIAL = new Msg("Openness.Commercial"); //$NON-NLS-1$
  
!     static final Msg BOOK_METADATA_SET_OTHER = new Msg("BookMetaDataSet.Other"); //$NON-NLS-1$
  
      static final Msg STRONGS_GREEK = new Msg("Strongs.Greek"); //$NON-NLS-1$
--- 48,52 ----
      static final Msg OPEN_COMMERCIAL = new Msg("Openness.Commercial"); //$NON-NLS-1$
  
!     static final Msg BOOK_METADATA_SET_OTHER = new Msg("BookSet.Other"); //$NON-NLS-1$
  
      static final Msg STRONGS_GREEK = new Msg("Strongs.Greek"); //$NON-NLS-1$

--- BookMetaDataSet.java DELETED ---

Index: Books.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Books.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** Books.java	25 Jan 2005 00:02:32 -0000	1.38
--- Books.java	19 Mar 2005 01:56:47 -0000	1.39
***************
*** 66,72 ****
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookList#getBookMetaDatas()
       */
!     public synchronized List getBookMetaDatas()
      {
          return Collections.unmodifiableList(books);
--- 66,72 ----
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookList#getBooks()
       */
!     public synchronized List getBooks()
      {
          return Collections.unmodifiableList(books);
***************
*** 74,80 ****
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookList#getBookMetaData(java.lang.String)
       */
!     public synchronized BookMetaData getBookMetaData(String name)
      {
          // Check name first
--- 74,80 ----
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookList#getBook(java.lang.String)
       */
!     public synchronized Book getBook(String name)
      {
          // Check name first
***************
*** 82,89 ****
          for (Iterator it = books.iterator(); it.hasNext(); )
          {
!             BookMetaData bmd = (BookMetaData) it.next();
!             if (name.equals(bmd.getName()))
              {
!                 return bmd;
              }
          }
--- 82,89 ----
          for (Iterator it = books.iterator(); it.hasNext(); )
          {
!             Book book = (Book) it.next();
!             if (name.equals(book.getName()))
              {
!                 return book;
              }
          }
***************
*** 92,99 ****
          for (Iterator it = books.iterator(); it.hasNext(); )
          {
!             BookMetaData bmd = (BookMetaData) it.next();
!             if (name.equalsIgnoreCase(bmd.getName()))
              {
!                 return bmd;
              }
          }
--- 92,99 ----
          for (Iterator it = books.iterator(); it.hasNext(); )
          {
!             Book book = (Book) it.next();
!             if (name.equalsIgnoreCase(book.getName()))
              {
!                 return book;
              }
          }
***************
*** 103,110 ****
          for (Iterator it = books.iterator(); it.hasNext(); )
          {
!             BookMetaData bmd = (BookMetaData) it.next();
              if (name.equals(bmd.getInitials()))
              {
!                 return bmd;
              }
          }
--- 103,111 ----
          for (Iterator it = books.iterator(); it.hasNext(); )
          {
!             Book book = (Book) it.next();
!             BookMetaData bmd = book.getBookMetaData();
              if (name.equals(bmd.getInitials()))
              {
!                 return book;
              }
          }
***************
*** 113,120 ****
          for (Iterator it = books.iterator(); it.hasNext(); )
          {
!             BookMetaData bmd = (BookMetaData) it.next();
!             if (name.equalsIgnoreCase(bmd.getInitials()))
              {
!                 return bmd;
              }
          }
--- 114,121 ----
          for (Iterator it = books.iterator(); it.hasNext(); )
          {
!             Book book = (Book) it.next();
!             if (name.equalsIgnoreCase(book.getInitials()))
              {
!                 return book;
              }
          }
***************
*** 123,131 ****
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookList#getBookMetaDatas(org.crosswire.jsword.book.BookFilter)
       */
!     public synchronized List getBookMetaDatas(BookFilter filter)
      {
!         List temp = CollectionUtil.createList(new BookFilterIterator(getBookMetaDatas().iterator(), filter));
          return Collections.unmodifiableList(temp);
      }
--- 124,132 ----
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.BookList#getBooks(org.crosswire.jsword.book.BookFilter)
       */
!     public synchronized List getBooks(BookFilter filter)
      {
!         List temp = CollectionUtil.createList(new BookFilterIterator(getBooks().iterator(), filter));
          return Collections.unmodifiableList(temp);
      }
***************
*** 150,157 ****
       * Kick of an event sequence
       * @param source The event source
!      * @param bmd The meta-data of the changed Bible
       * @param added Is it added?
       */
!     protected synchronized void fireBooksChanged(Object source, BookMetaData bmd, boolean added)
      {
          // Guaranteed to return a non-null array
--- 151,158 ----
       * Kick of an event sequence
       * @param source The event source
!      * @param book The changed Book
       * @param added Is it added?
       */
!     protected synchronized void fireBooksChanged(Object source, Book book, boolean added)
      {
          // Guaranteed to return a non-null array
***************
*** 167,171 ****
                  if (ev == null)
                  {
!                     ev = new BooksEvent(source, bmd, added);
                  }
  
--- 168,172 ----
                  if (ev == null)
                  {
!                     ev = new BooksEvent(source, book, added);
                  }
  
***************
*** 187,197 ****
       * general consumption.
       */
!     public synchronized void addBook(BookMetaData bmd)
      {
          //log.debug("registering book: "+bmd.getName());
  
!         books.add(bmd);
  
!         fireBooksChanged(instance, bmd, true);
      }
  
--- 188,198 ----
       * general consumption.
       */
!     public synchronized void addBook(Book book)
      {
          //log.debug("registering book: "+bmd.getName());
  
!         books.add(book);
  
!         fireBooksChanged(instance, book, true);
      }
  
***************
*** 201,214 ****
       * general consumption.
       */
!     public synchronized void removeBook(BookMetaData bmd) throws BookException
      {
          //log.debug("unregistering book: "+bmd.getName());
  
!         Activator.deactivate(bmd.getBook());
  
!         boolean removed = books.remove(bmd);
          if (removed)
          {
!             fireBooksChanged(instance, bmd, true);
          }
          else
--- 202,215 ----
       * general consumption.
       */
!     public synchronized void removeBook(Book book) throws BookException
      {
          //log.debug("unregistering book: "+bmd.getName());
  
!         Activator.deactivate(book);
  
!         boolean removed = books.remove(book);
          if (removed)
          {
!             fireBooksChanged(instance, book, true);
          }
          else
***************
*** 233,240 ****
          drivers.add(driver);
  
!         BookMetaData[] bmds = driver.getBookMetaDatas();
!         for (int j = 0; j < bmds.length; j++)
          {
!             addBook(bmds[j]);
          }
  
--- 234,241 ----
          drivers.add(driver);
  
!         Book[] bookArray = driver.getBooks();
!         for (int j = 0; j < bookArray.length; j++)
          {
!             addBook(bookArray[j]);
          }
  
***************
*** 250,257 ****
          log.debug("begin un-registering driver: " + driver.getClass().getName()); //$NON-NLS-1$
  
!         BookMetaData[] bmds = driver.getBookMetaDatas();
!         for (int j = 0; j < bmds.length; j++)
          {
!             removeBook(bmds[j]);
          }
  
--- 251,258 ----
          log.debug("begin un-registering driver: " + driver.getClass().getName()); //$NON-NLS-1$
  
!         Book[] bookArray = driver.getBooks();
!         for (int j = 0; j < bookArray.length; j++)
          {
!             removeBook(bookArray[j]);
          }
  

Index: BookMetaData.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookMetaData.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** BookMetaData.java	6 Mar 2005 20:21:47 -0000	1.24
--- BookMetaData.java	19 Mar 2005 01:56:47 -0000	1.25
***************
*** 60,75 ****
  
      /**
-      * Accessor for the real Book to read data.
-      * <p>Note that constructing a Book may well consume system resources far
-      * more than the construction of a BookMetaData so you should only get a
-      * Book if you intend to use it.
-      * <p>For implementors of BookMetaData - the objects returned by 2
-      * successive calls to getBook() should be the same (i.e. return true to an
-      * == test) unless for some reason the objects are not thread safe. Since
-      * Books are read-only once setup thread safety should not be hard.
-      */
-     public Book getBook();
- 
-     /**
       * Accessor for the driver that runs this Book.
       * Note this method should only be used to delete() Books. Everything else
--- 60,63 ----

Index: Defaults.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Defaults.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** Defaults.java	6 Mar 2005 20:21:47 -0000	1.26
--- Defaults.java	19 Mar 2005 01:56:47 -0000	1.27
***************
*** 46,54 ****
       * returned from getBibleNames. (if does not need to be == however)
       * A BookException results if you get it wrong.
!      * @param bmd The version to use as default.
       */
!     public static void setBibleMetaData(BookMetaData bmd)
      {
!         bdeft = bmd;
      }
  
--- 46,54 ----
       * returned from getBibleNames. (if does not need to be == however)
       * A BookException results if you get it wrong.
!      * @param book The version to use as default.
       */
!     public static void setBible(Book book)
      {
!         bdeft = book;
      }
  
***************
*** 56,60 ****
       * UnSet the current default Bible and attempt to appoint another.
       */
!     protected static void unsetBibleMetaData()
      {
          bdeft = null;
--- 56,60 ----
       * UnSet the current default Bible and attempt to appoint another.
       */
!     protected static void unsetBible()
      {
          bdeft = null;
***************
*** 67,71 ****
       * @return the current default version
       */
!     public static BookMetaData getBibleMetaData()
      {
          return bdeft;
--- 67,71 ----
       * @return the current default version
       */
!     public static Book getBible()
      {
          return bdeft;
***************
*** 83,87 ****
          }
  
!         return bdeft.getFullName();
      }
  
--- 83,87 ----
          }
  
!         return bdeft.getBookMetaData().getFullName();
      }
  
***************
*** 91,95 ****
       * <p>This method is for use with config scripts and other things that
       * <b>need</b> to work with Strings. The preferred method is to use
!      * BookMetaData objects.
       * <p>This method is picky in that it only matches when the driver and the
       * version are the same. The user (probably) only cares about the version
--- 91,95 ----
       * <p>This method is for use with config scripts and other things that
       * <b>need</b> to work with Strings. The preferred method is to use
!      * Book objects.
       * <p>This method is picky in that it only matches when the driver and the
       * version are the same. The user (probably) only cares about the version
***************
*** 106,117 ****
          }
  
!         List lbmds = Books.installed().getBookMetaDatas(BookFilters.getBibles());
          for (Iterator it = lbmds.iterator(); it.hasNext(); )
          {
!             BookMetaData bmd = (BookMetaData) it.next();
!             String tname = bmd.getFullName();
              if (tname.equals(name))
              {
!                 setBibleMetaData(bmd);
                  return;
              }
--- 106,117 ----
          }
  
!         List lbmds = Books.installed().getBooks(BookFilters.getBibles());
          for (Iterator it = lbmds.iterator(); it.hasNext(); )
          {
!             Book book = (Book) it.next();
!             String tname = book.getBookMetaData().getFullName();
              if (tname.equals(name))
              {
!                 setBible(book);
                  return;
              }
***************
*** 131,135 ****
       * @param cmd The version to use as default.
       */
!     public static void setCommentaryMetaData(BookMetaData cmd)
      {
          cdeft = cmd;
--- 131,135 ----
       * @param cmd The version to use as default.
       */
!     public static void setCommentary(Book cmd)
      {
          cdeft = cmd;
***************
*** 139,143 ****
       * UnSet the current default Commentary and attempt to appoint another.
       */
!     protected static void unsetCommentaryMetaData()
      {
          cdeft = null;
--- 139,143 ----
       * UnSet the current default Commentary and attempt to appoint another.
       */
!     protected static void unsetCommentary()
      {
          cdeft = null;
***************
*** 150,154 ****
       * @return the current default version
       */
!     public static BookMetaData getCommentaryMetaData()
      {
          return cdeft;
--- 150,154 ----
       * @return the current default version
       */
!     public static Book getCommentary()
      {
          return cdeft;
***************
*** 168,172 ****
          }
  
!         return cdeft.getFullName();
      }
  
--- 168,172 ----
          }
  
!         return cdeft.getBookMetaData().getFullName();
      }
  
***************
*** 176,180 ****
       * <p>This method is for use with config scripts and other things that
       * <b>need</b> to work with Strings. The preferred method is to use
!      * BookMetaData objects.
       * <p>This method is picky in that it only matches when the driver and the
       * version are the same. The user (probably) only cares about the version
--- 176,180 ----
       * <p>This method is for use with config scripts and other things that
       * <b>need</b> to work with Strings. The preferred method is to use
!      * Book objects.
       * <p>This method is picky in that it only matches when the driver and the
       * version are the same. The user (probably) only cares about the version
***************
*** 191,202 ****
          }
  
!         List lbmds = Books.installed().getBookMetaDatas(BookFilters.getCommentaries());
          for (Iterator it = lbmds.iterator(); it.hasNext(); )
          {
!             BookMetaData cmd = (BookMetaData) it.next();
!             String tname = cmd.getFullName();
              if (tname.equals(name))
              {
!                 setCommentaryMetaData(cmd);
                  return;
              }
--- 191,202 ----
          }
  
!         List lbmds = Books.installed().getBooks(BookFilters.getCommentaries());
          for (Iterator it = lbmds.iterator(); it.hasNext(); )
          {
!             Book book = (Book) it.next();
!             String tname = book.getBookMetaData().getFullName();
              if (tname.equals(name))
              {
!                 setCommentary(book);
                  return;
              }
***************
*** 216,220 ****
       * @param dmd The version to use as default.
       */
!     public static void setDictionaryMetaData(BookMetaData dmd)
      {
          ddeft = dmd;
--- 216,220 ----
       * @param dmd The version to use as default.
       */
!     public static void setDictionary(Book dmd)
      {
          ddeft = dmd;
***************
*** 224,228 ****
       * UnSet the current default Dictionary and attempt to appoint another.
       */
!     protected static void unsetDictionaryMetaData()
      {
          ddeft = null;
--- 224,228 ----
       * UnSet the current default Dictionary and attempt to appoint another.
       */
!     protected static void unsetDictionary()
      {
          ddeft = null;
***************
*** 235,239 ****
       * @return the current default version
       */
!     public static BookMetaData getDictionaryMetaData()
      {
          return ddeft;
--- 235,239 ----
       * @return the current default version
       */
!     public static Book getDictionary()
      {
          return ddeft;
***************
*** 253,257 ****
          }
  
!         return ddeft.getFullName();
      }
  
--- 253,257 ----
          }
  
!         return ddeft.getBookMetaData().getFullName();
      }
  
***************
*** 261,265 ****
       * <p>This method is for use with config scripts and other things that
       * <b>need</b> to work with Strings. The preferred method is to use
!      * BookMetaData objects.
       * <p>This method is picky in that it only matches when the driver and the
       * version are the same. The user (probably) only cares about the version
--- 261,265 ----
       * <p>This method is for use with config scripts and other things that
       * <b>need</b> to work with Strings. The preferred method is to use
!      * Book objects.
       * <p>This method is picky in that it only matches when the driver and the
       * version are the same. The user (probably) only cares about the version
***************
*** 276,287 ****
          }
  
!         List lbmds = Books.installed().getBookMetaDatas(BookFilters.getDictionaries());
          for (Iterator it = lbmds.iterator(); it.hasNext(); )
          {
!             BookMetaData dmd = (BookMetaData) it.next();
!             String tname = dmd.getFullName();
              if (tname.equals(name))
              {
!                 setDictionaryMetaData(dmd);
                  return;
              }
--- 276,287 ----
          }
  
!         List lbmds = Books.installed().getBooks(BookFilters.getDictionaries());
          for (Iterator it = lbmds.iterator(); it.hasNext(); )
          {
!             Book book = (Book) it.next();
!             String tname = book.getBookMetaData().getFullName();
              if (tname.equals(name))
              {
!                 setDictionary(book);
                  return;
              }
***************
*** 301,309 ****
      protected static void checkAllPreferable()
      {
!         List bmds = Books.installed().getBookMetaDatas();
          for (Iterator it = bmds.iterator(); it.hasNext(); )
          {
!             BookMetaData bmd = (BookMetaData) it.next();
!             checkPreferable(bmd);
          }
      }
--- 301,309 ----
      protected static void checkAllPreferable()
      {
!         List bmds = Books.installed().getBooks();
          for (Iterator it = bmds.iterator(); it.hasNext(); )
          {
!             Book book = (Book) it.next();
!             checkPreferable(book);
          }
      }
***************
*** 313,331 ****
       * It should, only if there is not one.
       */
!     protected static void checkPreferable(BookMetaData bmd)
      {
!         assert bmd != null;
  
!         if (bmd.getType().equals(BookType.BIBLE) && bdeft == null)
          {
!             bdeft = bmd;
          }
!         else if (bmd.getType().equals(BookType.COMMENTARY) && cdeft == null)
          {
!             cdeft = bmd;
          }
!         else if (bmd.getType().equals(BookType.DICTIONARY) && ddeft == null)
          {
!             ddeft = bmd;
          }
      }
--- 313,331 ----
       * It should, only if there is not one.
       */
!     protected static void checkPreferable(Book book)
      {
!         assert book != null;
  
!         if (book.getType().equals(BookType.BIBLE) && bdeft == null)
          {
!             bdeft = book;
          }
!         else if (book.getType().equals(BookType.COMMENTARY) && cdeft == null)
          {
!             cdeft = book;
          }
!         else if (book.getType().equals(BookType.DICTIONARY) && ddeft == null)
          {
!             ddeft = book;
          }
      }
***************
*** 350,355 ****
          public void bookAdded(BooksEvent ev)
          {
!             BookMetaData bmd = ev.getBookMetaData();
!             checkPreferable(bmd);
          }
  
--- 350,355 ----
          public void bookAdded(BooksEvent ev)
          {
!             Book book = ev.getBook();
!             checkPreferable(book);
          }
  
***************
*** 359,378 ****
          public void bookRemoved(BooksEvent ev)
          {
!             BookMetaData bmd = ev.getBookMetaData();
  
              // Was this a default?
!             if (getBibleMetaData().equals(bmd))
              {
!                 unsetBibleMetaData();
              }
  
!             if (getCommentaryMetaData().equals(bmd))
              {
!                 unsetCommentaryMetaData();
              }
  
!             if (getDictionaryMetaData().equals(bmd))
              {
!                 unsetDictionaryMetaData();
              }
          }
--- 359,378 ----
          public void bookRemoved(BooksEvent ev)
          {
!             Book book = ev.getBook();
  
              // Was this a default?
!             if (getBible().equals(book))
              {
!                 unsetBible();
              }
  
!             if (getCommentary().equals(book))
              {
!                 unsetCommentary();
              }
  
!             if (getDictionary().equals(book))
              {
!                 unsetDictionary();
              }
          }
***************
*** 386,400 ****
       * The default Bible
       */
!     private static BookMetaData bdeft;
  
      /**
       * The default Commentary
       */
!     private static BookMetaData cdeft;
  
      /**
       * The default Dictionary
       */
!     private static BookMetaData ddeft;
  
  }
--- 386,400 ----
       * The default Bible
       */
!     private static Book bdeft;
  
      /**
       * The default Commentary
       */
!     private static Book cdeft;
  
      /**
       * The default Dictionary
       */
!     private static Book ddeft;
  
  }

Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Msg.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Msg.properties	25 Jan 2005 00:02:32 -0000	1.3
--- Msg.properties	19 Mar 2005 01:56:47 -0000	1.4
***************
*** 25,29 ****
  Openness.Commercial=Commercial
  
! BookMetaDataSet.Other=Other
  
  Strongs.Greek=Greek:
--- 25,29 ----
  Openness.Commercial=Commercial
  
! BookSet.Other=Other
  
  Strongs.Greek=Greek:

Index: BookFilter.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookFilter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** BookFilter.java	30 Aug 2003 22:14:15 -0000	1.3
--- BookFilter.java	19 Mar 2005 01:56:47 -0000	1.4
***************
*** 30,36 ****
      /**
       * Does this given book pass the tests implemented by this filter
!      * @param bmd The Book to test
       * @return boolean true if it passes, false otherwise
       */
!     public boolean test(BookMetaData bmd);
  }
--- 30,36 ----
      /**
       * Does this given book pass the tests implemented by this filter
!      * @param book The Book to test
       * @return boolean true if it passes, false otherwise
       */
!     public boolean test(Book book);
  }

Index: BookDriver.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookDriver.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** BookDriver.java	6 Feb 2004 23:35:08 -0000	1.14
--- BookDriver.java	19 Mar 2005 01:56:47 -0000	1.15
***************
*** 34,38 ****
       * @return A list of the known Bibles
       */
!     public BookMetaData[] getBookMetaDatas();
  
      /**
--- 34,38 ----
       * @return A list of the known Bibles
       */
!     public Book[] getBooks();
  
      /**
***************
*** 52,55 ****
--- 52,62 ----
  
      /**
+      * Is this book able to be deleted.
+      * @param dead the book to be deleted
+      * @return whether the book can be deleted.
+      */
+     public boolean isDeletable(Book dead);
+ 
+     /**
       * Delete this Book from the system.
       * Take care with this method for obvious reasons. For most implemenations
***************
*** 57,61 ****
       * @throws BookException If the Book can't be deleted.
       */
!     public void delete(BookMetaData dead) throws BookException;
  
      /**
--- 64,68 ----
       * @throws BookException If the Book can't be deleted.
       */
!     public void delete(Book dead) throws BookException;
  
      /**

Index: Book.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/Book.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** Book.java	9 Oct 2004 21:45:05 -0000	1.21
--- Book.java	19 Mar 2005 01:56:47 -0000	1.22
***************
*** 31,35 ****
   * @version $Id$
   */
! public interface Book extends Activatable, KeyFactory
  {
      /**
--- 31,35 ----
   * @version $Id$
   */
! public interface Book extends Activatable, KeyFactory, BookMetaData
  {
      /**
***************
*** 40,43 ****
--- 40,48 ----
  
      /**
+      * Set the meta-information for this book.
+      */
+     public void setBookMetaData(BookMetaData bmd);
+ 
+     /**
       * Retrieval: Add to the given document some mark-up for the specified
       * Verses.

Index: BookFilterIterator.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookFilterIterator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** BookFilterIterator.java	25 Jan 2005 00:02:32 -0000	1.6
--- BookFilterIterator.java	19 Mar 2005 01:56:47 -0000	1.7
***************
*** 73,84 ****
       * Find the next (if there is one)
       */
!     private BookMetaData findNext()
      {
          while (it.hasNext())
          {
!             BookMetaData bmd = (BookMetaData) it.next();
!             if (filter == null || filter.test(bmd))
              {
!                 return bmd;
              }
          }
--- 73,84 ----
       * Find the next (if there is one)
       */
!     private Book findNext()
      {
          while (it.hasNext())
          {
!             Book book = (Book) it.next();
!             if (filter == null || filter.test(book))
              {
!                 return book;
              }
          }
***************
*** 90,94 ****
       * The stored next value
       */
!     private BookMetaData next;
  
      /**
--- 90,94 ----
       * The stored next value
       */
!     private Book next;
  
      /**

Index: BookFilters.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BookFilters.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** BookFilters.java	5 Oct 2004 22:03:09 -0000	1.7
--- BookFilters.java	19 Mar 2005 01:56:47 -0000	1.8
***************
*** 53,57 ****
      private static class AllBookFilter implements BookFilter
      {
!         public boolean test(BookMetaData bmd)
          {
              return true;
--- 53,57 ----
      private static class AllBookFilter implements BookFilter
      {
!         public boolean test(Book book)
          {
              return true;
***************
*** 77,83 ****
      private static class BiblesBookFilter implements BookFilter
      {
!         public boolean test(BookMetaData bmd)
          {
!             return bmd.getType().equals(BookType.BIBLE);
          }
      }
--- 77,83 ----
      private static class BiblesBookFilter implements BookFilter
      {
!         public boolean test(Book book)
          {
!             return book.getType().equals(BookType.BIBLE);
          }
      }
***************
*** 101,107 ****
      private static class DictionariesBookFilter implements BookFilter
      {
!         public boolean test(BookMetaData bmd)
          {
!             return bmd.getType().equals(BookType.DICTIONARY);
          }
      }
--- 101,107 ----
      private static class DictionariesBookFilter implements BookFilter
      {
!         public boolean test(Book book)
          {
!             return book.getType().equals(BookType.DICTIONARY);
          }
      }
***************
*** 125,131 ****
      private static class CommentariesBookFilter implements BookFilter
      {
!         public boolean test(BookMetaData bmd)
          {
!             return bmd.getType().equals(BookType.COMMENTARY);
          }
      }
--- 125,131 ----
      private static class CommentariesBookFilter implements BookFilter
      {
!         public boolean test(Book book)
          {
!             return book.getType().equals(BookType.COMMENTARY);
          }
      }
***************
*** 138,144 ****
          return new BookFilter()
          {
!             public boolean test(BookMetaData bmd)
              {
!                 return b1.test(bmd) && b2.test(bmd);
              }
          };
--- 138,144 ----
          return new BookFilter()
          {
!             public boolean test(Book book)
              {
!                 return b1.test(book) && b2.test(book);
              }
          };
***************
*** 152,158 ****
          return new BookFilter()
          {
!             public boolean test(BookMetaData bmd)
              {
!                 return b1.test(bmd) || b2.test(bmd);
              }
          };
--- 152,158 ----
          return new BookFilter()
          {
!             public boolean test(Book book)
              {
!                 return b1.test(book) || b2.test(book);
              }
          };

Index: BooksEvent.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/BooksEvent.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** BooksEvent.java	6 Mar 2005 20:21:47 -0000	1.6
--- BooksEvent.java	19 Mar 2005 01:56:47 -0000	1.7
***************
*** 32,53 ****
      /**
       * Basic constructor
!      * @param bmd The meta-data of the changed Bible, or null if there is more than one change.
       * @param added True if the changed Bible is an addition.
       */
!     public BooksEvent(Object source, BookMetaData bmd, boolean added)
      {
          super(source);
  
!         this.bmd = bmd;
          this.added = added;
      }
  
      /**
!      * Get the name of the changed Bible
!      * @return The Bible bmd
       */
!     public BookMetaData getBookMetaData()
      {
!         return bmd;
      }
  
--- 32,53 ----
      /**
       * Basic constructor
!      * @param book The book of the changed Bible, or null if there is more than one change.
       * @param added True if the changed Bible is an addition.
       */
!     public BooksEvent(Object source, Book book, boolean added)
      {
          super(source);
  
!         this.book = book;
          this.added = added;
      }
  
      /**
!      * Get the name of the changed Book
!      * @return The Book
       */
!     public Book getBook()
      {
!         return book;
      }
  
***************
*** 68,72 ****
       * The name of the changed Bible
       */
!     private BookMetaData bmd;
  
      /**
--- 68,72 ----
       * The name of the changed Bible
       */
!     private Book book;
  
      /**



More information about the jsword-svn mailing list