org.crosswire.jsword.book.sword
Class SwordBookPath

java.lang.Object
  extended by org.crosswire.jsword.book.sword.SwordBookPath

public class SwordBookPath
extends Object

This represents all of the Sword Books (aka modules).

Author:
Joe Walker [joe at eireneh dot com], DM Smith [dmsmith555 at yahoo dot com]
See Also:
for license details. The copyright to this program is held by it's authors.

Nested Class Summary
(package private) static class SwordBookPath.CustomFilenameFilter
          Check that the directories in the version directory really represent versions.
 
Field Summary
private static String AUGMENT_PATH
          Sword global config file's path to where mods can be found
private static File[] augmentPath
          The directory URL
private static String DATA_PATH
          Sword global config file's path to where mods can be found
private static File defaultDownloadDir
          The directory URL
private static String DIR_SWORD_CONF
          Users config directory for Sword in Unix
private static String DIR_SWORD_CONF_ALT
          Users config directory for Sword in Unix
private static String DIR_SWORD_GLOBAL_CONF
          Sword global config file locations
private static String DIR_SWORD_LIBRARY
          Library may be a sibling of DIR_WINDOWS_DEFAULT or SWORD_HOME or CWD
private static String DIR_WINDOWS_DEFAULT
          Default windows installation directory
private static Logger log
          The log stream
private static File overrideDownloadDir
          The directory URL
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
private static String SWORD_GLOBAL_CONF
          Sword global config file
 
Constructor Summary
private SwordBookPath()
          Some basic name initialization
 
Method Summary
static File[] getAugmentPath()
          Retrieve the additional locations that Sword may hold Books.
static String[] getBookList(File bookDir)
          Get a list of books in a given location.
private static File getDefaultDownloadPath()
           
private static File[] getDefaultPaths()
          Search all of the "standard" Sword locations for Books.
static File getDownloadDir()
           
static File getSwordDownloadDir()
          Get the download directory, which is either the one that the user chose or that JSword picked for the user.
static File[] getSwordPath()
          Obtain a prioritized path of Book locations.
private static boolean migrate(File oldPath, File newPath)
           
private static void migrateBookDir()
           
private static void migrateBookDir(File oldPath, File newPath)
           
private static void readSwordConf(List bookDirs, File swordConfDir)
           
private static void readSwordConf(List bookDirs, String swordConfDir)
           
static void setAugmentPath(File[] theNewDirs)
          Establish additional locations that Sword may hold books.
static void setDownloadDir(File dlDir)
           
private static void testDefaultPath(List bookDirs, File 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 void testDefaultPath(List bookDirs, 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.
 
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_LIBRARY

private static final String DIR_SWORD_LIBRARY
Library may be a sibling of DIR_WINDOWS_DEFAULT or SWORD_HOME or CWD

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_SWORD_CONF_ALT

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

See Also:
Constant Field Values

SWORD_GLOBAL_CONF

private static final String SWORD_GLOBAL_CONF
Sword global config file

See Also:
Constant Field Values

DIR_SWORD_GLOBAL_CONF

private static final String DIR_SWORD_GLOBAL_CONF
Sword global config file locations

See Also:
Constant Field Values

DATA_PATH

private static final String DATA_PATH
Sword global config file's path to where mods can be found

See Also:
Constant Field Values

AUGMENT_PATH

private static final String AUGMENT_PATH
Sword global config file's path to where mods can be found

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

augmentPath

private static File[] augmentPath
The directory URL


defaultDownloadDir

private static File defaultDownloadDir
The directory URL


overrideDownloadDir

private static File overrideDownloadDir
The directory URL


log

private static final Logger log
The log stream

Constructor Detail

SwordBookPath

private SwordBookPath()
Some basic name initialization

Method Detail

setAugmentPath

public static void setAugmentPath(File[] theNewDirs)
                           throws BookException
Establish additional locations that Sword may hold books.

Parameters:
theNewDirs - The new Sword directories
Throws:
BookException

getAugmentPath

public static File[] getAugmentPath()
Retrieve the additional locations that Sword may hold Books.

Returns:
The new Sword directory

getSwordPath

public static File[] getSwordPath()
Obtain a prioritized path of Book locations. This contains the download dir as the first location, the user's augment path and finally all the discovered standard locations.

Returns:
the array of Book locations.

getBookList

public static String[] getBookList(File bookDir)
Get a list of books in a given location.

Parameters:
bookDir - the directory in which to look
Returns:
the list of books in that location

getDefaultPaths

private static File[] getDefaultPaths()
Search all of the "standard" Sword locations for Books. Remember all the locations.


readSwordConf

private static void readSwordConf(List bookDirs,
                                  File swordConfDir)

readSwordConf

private static void readSwordConf(List bookDirs,
                                  String swordConfDir)

testDefaultPath

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

Parameters:
bookDirs - The list to add good paths
path - the path to check

testDefaultPath

private static void testDefaultPath(List bookDirs,
                                    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.

Parameters:
bookDirs - The list to add good paths
path - the path to check

getDefaultDownloadPath

private static File getDefaultDownloadPath()

migrateBookDir

private static void migrateBookDir()

migrateBookDir

private static void migrateBookDir(File oldPath,
                                   File newPath)

migrate

private static boolean migrate(File oldPath,
                               File newPath)

getSwordDownloadDir

public static File getSwordDownloadDir()
Get the download directory, which is either the one that the user chose or that JSword picked for the user.

Returns:
Returns the download directory.

getDownloadDir

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

setDownloadDir

public static void setDownloadDir(File dlDir)
Parameters:
dlDir - The download directory that the user specifies.

Copyright ยจ 2003-2007