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