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: Installer.java 1785 2008-04-03 21:11:30Z dmsmith $
21   */
22  package org.crosswire.jsword.book.install;
23  
24  import java.net.URI;
25  import java.util.List;
26  
27  import org.crosswire.jsword.book.Book;
28  import org.crosswire.jsword.book.BookList;
29  
30  /**
31   * An interface that allows us to download from a specific source of Bible data.
32   * It is important that implementor of this interface define equals() and
33   * hashcode() properly.
34   *
35   * <p>To start with I only envisage that we use Sword sourced Bible data
36   * however the rest of the system is designed to be able to use data from
37   * e-Sword, OLB, etc.</p>
38   *
39   * @see gnu.lgpl.License for license details.
40   *      The copyright to this program is held by it's authors.
41   * @author Joe Walker [joe at eireneh dot com]
42   * @author DM Smith [dmsmith555 at yahoo dot com]
43   */
44  public interface Installer extends BookList
45  {
46      /**
47       * Get the type of the Installer.
48       * @return the type of the installer
49       */
50      String getType();
51  
52      /**
53       * Accessor for the URI
54       * @return the source uri
55       */
56      String getInstallerDefinition();
57  
58      /**
59       * @param book The book meta-data to get a URI from.
60       * @return the remote uri for the BookMetaData
61       */
62      URI toRemoteURI(Book book);
63  
64      /**
65       * Get a list of BookMetaData objects that represent downloadable books.
66       * If no list has been retrieved from the remote source using reloadIndex()
67       * then we should just return an empty list and not attempt to contact the
68       * remote source. See notes on reload for more information.
69       * @see Installer#reloadBookList()
70       */
71      List getBooks();
72  
73      /**
74       * Get a Book matching the name from the local cache. Null if none is found.
75       */
76      Book getBook(String Book);
77  
78      /**
79       * Return true if the book is not installed or there is a newer
80       * version to install.
81       * @param book The book meta-data to check on.
82       * @return whether there is a newer version to install
83       */
84      int getSize(Book book);
85  
86      /**
87       * Return true if the book is not installed or there is a newer
88       * version to install.
89       * @param book The book meta-data to check on.
90       * @return whether there is a newer version to install
91       */
92      boolean isNewer(Book book);
93  
94      /**
95       * Refetch a list of names from the remote source.
96       * <b>It would make sense if the user was warned about the implications
97       * of this action. If the user lives in a country that persecutes
98       * Christians then this action might give the game away.</b>
99       */
100     void reloadBookList() throws InstallException;
101 
102     /**
103      * Download and install a book locally.
104      * The name should be one from an index list retrieved from getIndex() or
105      * reloadIndex()
106      * @param book The book to install
107      */
108     void install(Book book) throws InstallException;
109 
110     /**
111      * Download a search index for the given Book.
112      * The installation of the search index is the responsibility of the
113      * BookIndexer.
114      * @param book The book to download a search index for.
115      * @param tempDest A temporary URI for downloading to. Passed to the
116      * BookIndexer for installation.
117      */
118     void downloadSearchIndex(Book book, URI tempDest) throws InstallException;
119 }
120