org.crosswire.jsword.book.sword
Class SwordBookDriver

java.lang.Object
  extended by org.crosswire.jsword.book.basic.AbstractBookDriver
      extended by org.crosswire.jsword.book.sword.SwordBookDriver
All Implemented Interfaces:
BookDriver

public class SwordBookDriver
extends AbstractBookDriver

This represents all of the SwordBibles.

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: SwordBookDriver.java,v 1.39 2005/03/23 02:05:38 dmsmith Exp $
Author:
Joe Walker [joe at eireneh dot com], DM Smith [dmsmith555 at yahoo dot com]
See Also:
Licence

Nested Class Summary
private static class SwordBookDriver.CustomFilenameFilter
          Check that the directories in the version directory really represent versions.
 
Field Summary
private static String DIR_SWORD_CONF
          Users config directory for Sword in Unix
private static String DIR_UNIX_GLOBAL_CONF
          Sword global config file
private static String DIR_WINDOWS_DEFAULT
          Default windows installation directory
private static File[] dirs
          The directory URL
private static BookDriver INSTANCE
          A shared instance of this driver.
private static Logger log
          The log stream
private static String PREFIX_GLOBALS
          File prefix for config file
private static String PROPERTY_SWORD_HOME
          System property for sword home directory
private static String PROPERTY_USER_HOME
          Java system property for users home directory
 
Constructor Summary
SwordBookDriver()
          Some basic name initialization
 
Method Summary
private  Book createBook(SwordBookMetaData sbmd, File progdir)
          Create a Book appropriate for the BookMetaData
 void delete(Book dead)
          Delete this Book from the system.
 Book[] getBooks()
          This method should only be used by Bibles at startup to register the Bibles known at start time.
private static File[] getDefaultPaths()
          Have an OS dependent guess at where Sword might be installed
static File getDownloadDir()
           
 String getDriverName()
          A short name for this BookDriver
static File[] getSwordPath()
          Accessor for the Sword directory
static BookDriver instance()
          Get the singleton instance of this driver.
 boolean isDeletable(Book dead)
          Is this book able to be deleted.
static void registerNewBook(SwordBookMetaData sbmd, File bookpath)
          A helper class for the FtpSwordInstaller to tell us that it has copied a new Book into our install dorectory
static void setDownloadDir(File downloadDir)
           
static void setSwordPath(File[] newDirs)
          Accessor for the Sword directory
private static void testDefaultPath(List reply, String path)
          Check to see if the given directory is a Sword mods.d directory and then add it to the list if it is.
private static File[] validateSwordPath(File[] files)
          validateSwordPath maintains the invariant that the download location is first in the list.
 
Methods inherited from class org.crosswire.jsword.book.basic.AbstractBookDriver
create, isWritable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIR_WINDOWS_DEFAULT

private static final String DIR_WINDOWS_DEFAULT
Default windows installation directory

See Also:
Constant Field Values

DIR_SWORD_CONF

private static final String DIR_SWORD_CONF
Users config directory for Sword in Unix

See Also:
Constant Field Values

DIR_UNIX_GLOBAL_CONF

private static final String DIR_UNIX_GLOBAL_CONF
Sword global config file

See Also:
Constant Field Values

PROPERTY_SWORD_HOME

private static final String PROPERTY_SWORD_HOME
System property for sword home directory

See Also:
Constant Field Values

PROPERTY_USER_HOME

private static final String PROPERTY_USER_HOME
Java system property for users home directory

See Also:
Constant Field Values

PREFIX_GLOBALS

private static final String PREFIX_GLOBALS
File prefix for config file

See Also:
Constant Field Values

INSTANCE

private static final BookDriver INSTANCE
A shared instance of this driver.


dirs

private static File[] dirs
The directory URL


log

private static final Logger log
The log stream

Constructor Detail

SwordBookDriver

public SwordBookDriver()
Some basic name initialization

Method Detail

getDriverName

public String getDriverName()
Description copied from interface: BookDriver
A short name for this BookDriver


getBooks

public Book[] getBooks()
Description copied from interface: BookDriver
This method should only be used by Bibles at startup to register the Bibles known at start time. Generally there will be a better way of doing whatever you want to do if you use this method.

Returns:
A list of the known Bibles

isDeletable

public boolean isDeletable(Book dead)
Description copied from interface: BookDriver
Is this book able to be deleted.

Specified by:
isDeletable in interface BookDriver
Overrides:
isDeletable in class AbstractBookDriver
Parameters:
dead - the book to be deleted
Returns:
whether the book can be deleted.

delete

public void delete(Book dead)
            throws BookException
Description copied from interface: BookDriver
Delete this Book from the system. Take care with this method for obvious reasons. For most implemenations of Book etc, this method will throw up because most will be read-only.

Specified by:
delete in interface BookDriver
Overrides:
delete in class AbstractBookDriver
Throws:
BookException - If the Book can't be deleted.

instance

public static BookDriver instance()
Get the singleton instance of this driver.

Returns:
this driver instance

registerNewBook

public static void registerNewBook(SwordBookMetaData sbmd,
                                   File bookpath)
                            throws BookException
A helper class for the FtpSwordInstaller to tell us that it has copied a new Book into our install dorectory

Parameters:
sbmd - The SwordBookMetaData object for the new Book
bookpath - The path that we have installed to
Throws:
BookException

createBook

private Book createBook(SwordBookMetaData sbmd,
                        File progdir)
                 throws BookException
Create a Book appropriate for the BookMetaData

Throws:
BookException

setSwordPath

public static void setSwordPath(File[] newDirs)
                         throws BookException
Accessor for the Sword directory

Parameters:
newDirs - The new Sword directory
Throws:
BookException

validateSwordPath

private static File[] validateSwordPath(File[] files)
validateSwordPath maintains the invariant that the download location is first in the list. If null or an empty array is passed then the defaultList is used.

Parameters:
files -
Returns:
null if the list is not to be used, otherwise it returns the list.

getSwordPath

public static File[] getSwordPath()
Accessor for the Sword directory

Returns:
The new Sword directory

getDefaultPaths

private static File[] getDefaultPaths()
Have an OS dependent guess at where Sword might be installed


testDefaultPath

private static void testDefaultPath(List reply,
                                    String path)
Check to see if the given directory is a Sword mods.d directory and then add it to the list if it is.


getDownloadDir

public static File getDownloadDir()
Returns:
Returns the download directory.

setDownloadDir

public static void setDownloadDir(File downloadDir)
Parameters:
downloadDir - The download directory to set.

Copyright ? 2003-2004