[jsword-devel] Changes to SwordBookDriver

DM Smith jsword-devel@crosswire.org
Fri, 19 Mar 2004 13:27:02 -0500


I have been working on clean startup issues.
I have some changes to SwordBookDriver and will send a patch later when the 
Crosswire CVS server is up (right now it is down).

The changes are to solve the following problem:
In SwordBookDriver,
downloadDir is set to the value contained in configuration files. Initially 
it is null and it is set to "", since it is not given a value in the 
configuration files.

Line 70 of getBookMetaDatas and line 271 of getDefaultPaths assume that a 
path is a directory containing the directory mods.d.
Lines 284, 297, 301, 304, and 307 of getDefaultPaths assume path is the 
directory mods.d.

In getDefaultPaths line 271 does not assume that the mods.d directory 
exists, but lines 284, 297, 301, 304, and 307 test for its existence.

In SwordInstaller
In the install on lines 123ff the modules and mods.d directory are based 
upon SwordBookDriver.getDownloadDir().

The problem that needs to be solved is to establish a downloadsDir as one of 
the path locations. If none exist then the project directory needs to be 
used.

Further dirs in SwordBookMetadata should be a list of the directories that 
contain mods.d directories or could contain them.

These are the changes I have made:
1) The method getDefaultDirs returns a File[] of paths where to look for 
mods.d directories. It will contain the directory ~/.jsword and any of the 
other directories that it looked at if it contains mods.d. This also changed 
testDefaultPath.

2) dirs is set in the constructor to the array of defaultDirs

3) getDownloadDir merely returns the first element in the swordpath.

4) setDownloadDir ignores directories that have a path of "", which is the 
default case in the programs default properties. This method also maintains 
the invariant that the download dir is the first directory in the sword 
search path. I also added a debug statement if it is changed.

5) Since dirs always has a value getSwordPath merely returns it.

6) Since dirs always has a value getBookMetaDatas does not test for a null 
value.

7) setSwordPath is a total rewrite. The test of the parameter is move to a 
new method, validateSwordPath. If it passes validation then it unregisters 
the driver, sets the path and re-registers it.

The new method validateSwordPath is in charge of maintaining the new 
invariant that downloadDir is at the beginning of the path. Here is what it 
does: if the new sword path is null or empty, it establishes the value as 
the default path. If there is no change in the path the routine "fails", 
which really means that setSwordPath has nothing to do. If there is a 
change, then the current downloadd dir is either found at the beginning, 
moved to the beginning or added to the front of the list.

_________________________________________________________________
All the action. All the drama. Get NCAA hoops coverage at MSN Sports by 
ESPN. http://msn.espn.go.com/index.html?partnersite=espn