1   /**
2    * Distribution License:
3    * JSword is free software; you can redistribute it and/or modify it under
4    * the terms of the GNU Lesser General Public License, version 2.1 as published by
5    * the Free Software Foundation. This program is distributed in the hope
6    * that it will be useful, but WITHOUT ANY WARRANTY; without even the
7    * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8    * See the GNU Lesser General Public License for more details.
9    *
10   * The License is available on the internet at:
11   *       http://www.gnu.org/copyleft/lgpl.html
12   * or by writing to:
13   *      Free Software Foundation, Inc.
14   *      59 Temple Place - Suite 330
15   *      Boston, MA 02111-1307, USA
16   *
17   * Copyright: 2005
18   *     The copyright to this program is held by it's authors.
19   *
20   * ID: $Id: AbstractBookDriver.java 2099 2011-03-07 17:13:00Z dmsmith $
21   */
22  package org.crosswire.jsword.book.basic;
23  
24  import org.crosswire.jsword.JSOtherMsg;
25  import org.crosswire.jsword.book.Book;
26  import org.crosswire.jsword.book.BookDriver;
27  import org.crosswire.jsword.book.BookException;
28  
29  /**
30   * The AbstractBookDriver class implements some BibleDriver methods, making a
31   * simple read-only BibleDriver.
32   * 
33   * @see gnu.lgpl.License for license details.<br>
34   *      The copyright to this program is held by it's authors.
35   * @author Joe Walker [joe at eireneh dot com]
36   */
37  public abstract class AbstractBookDriver implements BookDriver {
38      /*
39       * (non-Javadoc)
40       * 
41       * @see org.crosswire.jsword.book.BookDriver#isWritable()
42       */
43      public boolean isWritable() {
44          return false;
45      }
46  
47      /*
48       * (non-Javadoc)
49       * 
50       * @see
51       * org.crosswire.jsword.book.BookDriver#create(org.crosswire.jsword.book
52       * .Book, org.crosswire.jsword.book.events.WorkListener)
53       */
54      public Book create(Book source) throws BookException {
55          throw new BookException(JSOtherMsg.lookupText("This Book is read-only."));
56      }
57  
58      /*
59       * (non-Javadoc)
60       * 
61       * @see
62       * org.crosswire.jsword.book.BookDriver#isDeletable(org.crosswire.jsword
63       * .book.Book)
64       */
65      public boolean isDeletable(Book dead) {
66          return false;
67      }
68  
69      /*
70       * (non-Javadoc)
71       * 
72       * @see
73       * org.crosswire.jsword.book.BookDriver#delete(org.crosswire.jsword.book
74       * .Book)
75       */
76      public void delete(Book dead) throws BookException {
77          throw new BookException(JSOtherMsg.lookupText("This Book is read-only."));
78      }
79  
80      /*
81       * (non-Javadoc)
82       * 
83       * @see org.crosswire.jsword.book.BookProvider#getFirstBook()
84       */
85      public Book getFirstBook() {
86          Book[] books = getBooks();
87          return books == null || books.length == 0 ? null : books[0];
88      }
89  }
90