org.crosswire.jsword.book.install.sword
Class AbstractSwordInstaller

java.lang.Object
  extended by org.crosswire.jsword.book.basic.AbstractBookList
      extended by org.crosswire.jsword.book.install.sword.AbstractSwordInstaller
All Implemented Interfaces:
BookList, Installer
Direct Known Subclasses:
FtpSwordInstaller, HttpSwordInstaller

public abstract class AbstractSwordInstaller
extends AbstractBookList
implements Installer

.

Distribution Licence:
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.
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.
The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
The copyright to this program is held by it's authors.

Version:
$Id: AbstractSwordInstaller.java,v 1.11 2005/03/23 02:05:38 dmsmith Exp $
Author:
Joe Walker [joe at eireneh dot com]
See Also:
Licence

Field Summary
protected  String directory
          The directory containing modules on the host.
protected static String DOWNLOAD_PREFIX
          When we cache a download index
protected  Map entries
          A map of the entries in this download area
protected static String FILE_LIST_GZ
          The sword index file
protected  String host
          The remote hostname.
private static String LIST_DIR
          The relative path of the dir holding the index file
protected  boolean loaded
          Do we need to reload the index file
private static Logger log
          The log stream
protected static String PACKAGE_DIR
          The relative path of the dir holding the zip files
protected static String SEARCH_DIR
          The relative path of the dir holding the search index files
protected static String ZIP_SUFFIX
          The suffix of zip modules on this server
 
Constructor Summary
AbstractSwordInstaller()
           
 
Method Summary
 int compareTo(Object arg0)
           
protected abstract  void download(Job job, String dir, String file, URL dest)
          Utility to download a file from a remote site
 void downloadSearchIndex(Book book, URL localDest)
          Download a search index for the given Book.
 boolean equals(Object object)
           
protected  boolean equals(String string1, String string2)
          Quick utility to check to see if 2 (potentially null) strings are equal
 List getBooks()
          Get an iterator over all the Books of all types.
protected  URL getCachedIndexFile()
          The URL for the cached index file for this installer
 String getDirectory()
           
 String getHost()
           
private static String getTempFileExtension(String host, String directory)
          What are we using as a temp filename?
 int hashCode()
           
 void install(Book book)
          Download and install a module locally.
 boolean isNewer(Book book)
          Return true if the module is not installed or there is a newer version to install.
private  void loadCachedIndex()
          Load the cached index file into memory
 void reloadBookList()
          Refetch a list of names from the remote source.
 void setDirectory(String directory)
           
 void setHost(String host)
           
 
Methods inherited from class org.crosswire.jsword.book.basic.AbstractBookList
addBooksListener, fireBooksChanged, getBooks, removeBooksListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.crosswire.jsword.book.install.Installer
getURL, toRemoteURL
 
Methods inherited from interface org.crosswire.jsword.book.BookList
addBooksListener, getBooks, removeBooksListener
 

Field Detail

PACKAGE_DIR

protected static final String PACKAGE_DIR
The relative path of the dir holding the zip files

See Also:
Constant Field Values

LIST_DIR

private static final String LIST_DIR
The relative path of the dir holding the index file

See Also:
Constant Field Values

entries

protected Map entries
A map of the entries in this download area


host

protected String host
The remote hostname.


directory

protected String directory
The directory containing modules on the host.


loaded

protected boolean loaded
Do we need to reload the index file


FILE_LIST_GZ

protected static final String FILE_LIST_GZ
The sword index file

See Also:
Constant Field Values

ZIP_SUFFIX

protected static final String ZIP_SUFFIX
The suffix of zip modules on this server

See Also:
Constant Field Values

log

private static final Logger log
The log stream


SEARCH_DIR

protected static final String SEARCH_DIR
The relative path of the dir holding the search index files

See Also:
Constant Field Values

DOWNLOAD_PREFIX

protected static final String DOWNLOAD_PREFIX
When we cache a download index

See Also:
Constant Field Values
Constructor Detail

AbstractSwordInstaller

public AbstractSwordInstaller()
Method Detail

download

protected abstract void download(Job job,
                                 String dir,
                                 String file,
                                 URL dest)
                          throws InstallException
Utility to download a file from a remote site

Parameters:
job - The way of noting progress
dir - The directory from which to download the file
file - The file to download
Throws:
InstallException

isNewer

public boolean isNewer(Book book)
Description copied from interface: Installer
Return true if the module is not installed or there is a newer version to install.

Specified by:
isNewer in interface Installer
Parameters:
book - The book meta-data to check on.
Returns:
whether there is a newer version to install

getBooks

public List getBooks()
Description copied from interface: BookList
Get an iterator over all the Books of all types.

Specified by:
getBooks in interface BookList
Specified by:
getBooks in interface Installer
See Also:
Installer.reloadBookList()

install

public void install(Book book)
Description copied from interface: Installer
Download and install a module locally. The name should be one from an index list retrieved from getIndex() or reloadIndex()

Specified by:
install in interface Installer
Parameters:
book - The module to install

reloadBookList

public void reloadBookList()
                    throws InstallException
Description copied from interface: Installer
Refetch a list of names from the remote source. It would make sense if the user was warned about the implications of this action. If the user lives in a country that persecutes Christians then this action might give the game away.

Specified by:
reloadBookList in interface Installer
Throws:
InstallException

downloadSearchIndex

public void downloadSearchIndex(Book book,
                                URL localDest)
                         throws InstallException
Description copied from interface: Installer
Download a search index for the given Book. The installation of the search index is the responsibility of the IndexManager.

Specified by:
downloadSearchIndex in interface Installer
Parameters:
book - The book to download a search index for.
localDest - A temporary URL for downloading to. Passed to the IndexManager for installation.
Throws:
InstallException

loadCachedIndex

private void loadCachedIndex()
                      throws InstallException
Load the cached index file into memory

Throws:
InstallException

getDirectory

public String getDirectory()
Returns:
Returns the directory.

setDirectory

public void setDirectory(String directory)
Parameters:
directory - The directory to set.

getHost

public String getHost()
Returns:
Returns the host.

setHost

public void setHost(String host)
Parameters:
host - The host to set.

getCachedIndexFile

protected URL getCachedIndexFile()
                          throws InstallException
The URL for the cached index file for this installer

Throws:
InstallException

getTempFileExtension

private static String getTempFileExtension(String host,
                                           String directory)
What are we using as a temp filename?


equals

public boolean equals(Object object)
Overrides:
equals in class Object

compareTo

public int compareTo(Object arg0)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

protected boolean equals(String string1,
                         String string2)
Quick utility to check to see if 2 (potentially null) strings are equal


Copyright ? 2003-2004