public final class CWProject extends Object
Mac OS X | ~/Library/Application Support/JSword |
Win NT/2000/XP/ME/9x | ~/Application Data/JSword (~ is all over the place, but Java figures it out) |
Unix and otherwise | ~/.jsword |
Previously the location was ~/.jsword, which is unfriendly in the Windows and Mac world. If this location is found on Mac or Windows, it will be moved to the new location, if different and possible.
Note: If the Java System property jsword.home is set and it exists and is writable then it will be used instead of the above location. This is useful for USB Drives and other portable implementations of JSword. It is recommended that this name be JSword.
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
private static String |
DIR_NETCACHE
The cache of downloaded files inside the project directory
|
private String |
frontendName
The name of the front-end application.
|
private URI |
frontendReadHome
Front-end read home, could be null if not present
|
private static String |
homeAltDirectory
The JSword user settings directory for Mac and Windows
|
private static String |
homeDirectory
The JSword user settings directory
|
private static String |
homeProperty
System property for home directory
|
private URI[] |
homes
The homes for this application: first is writable, second (if present) is
read-only and specified by the system property jsword.home.
|
private static CWProject |
instance
The filesystem resources
|
private static org.slf4j.Logger |
LOGGER
The log stream
|
private URI |
readHome
The readable home for this application, specified by the system property
jsword.home.
|
private URI |
writableFrontEndHome
Front-end home, where the app can write information to it.
|
private URI |
writeHome
The writable home for this application.
|
Modifier | Constructor and Description |
---|---|
private |
CWProject()
Prevent instantiation.
|
Modifier and Type | Method and Description |
---|---|
private void |
establishProjectHome()
Establishes the user's project directory.
|
URI |
getDeprecatedWritableProjectDir()
Get the location where the project directory used to be.
|
URI[] |
getProjectResourceDirs()
Get the locations where project resources can be found.
|
URI |
getReadableFrontendProjectDir() |
URI |
getWritableFrontendProjectDir() |
URI |
getWritableProjectDir()
Get the writable user project directory.
|
URI |
getWritableProjectSubdir(String subject,
boolean create)
A directory within the project directory.
|
URI |
getWritableURI(String subject,
String extension)
Create a the URI for a (potentially non-existent) file to which we can
write.
|
static CWProject |
instance()
Accessor for the resource singleton.
|
private URI |
migrateUserProjectDir(URI oldPath,
URI newPath)
Migrates the user's project dir, if necessary and possible.
|
private static void |
reset()
Required for reset of statics during testing
|
void |
setFrontendName(String frontendName)
Sets the name of the front-end.
|
static void |
setHome(String homeProperty,
String homeDir,
String altHomeDir)
Establish how this project finds it's resources.
|
private static final String DIR_NETCACHE
private URI[] homes
private URI writeHome
private String frontendName
private URI readHome
private URI writableFrontEndHome
private URI frontendReadHome
private static String homeProperty
private static String homeDirectory
private static String homeAltDirectory
private static CWProject instance
private static final org.slf4j.Logger LOGGER
public static CWProject instance()
private static void reset()
public static void setHome(String homeProperty, String homeDir, String altHomeDir)
homeProperty
- a property that is used as the home directory name. If this
property has a value then homeDir and altHomeDir are ignored.
Defaults to jsword.home.homeDir
- the name of the directory to be used for Unix. Typically this
is a hidden directory, that is, it begins with a '.'. Defaults
to .jswordaltHomeDir
- the name of the directory to be used for other OSes. This
should not be a hidden directory. Defaults to JSword.public void setFrontendName(String frontendName)
frontendName
- public URI getWritableFrontendProjectDir()
public URI getReadableFrontendProjectDir()
public URI getWritableProjectDir()
public URI[] getProjectResourceDirs()
public URI getDeprecatedWritableProjectDir()
public URI getWritableURI(String subject, String extension)
subject
- The name (minus the .xxx extension)extension
- The extension, prefixed with a '.' See: FileUtil
for a
list of popular extensions.public URI getWritableProjectSubdir(String subject, boolean create) throws IOException
subject
- A name for the subdirectory of the Project directory.create
- whether to create the directory if it does not existIOException
private void establishProjectHome()
Here is the lookup order:
private URI migrateUserProjectDir(URI oldPath, URI newPath)
oldPath
- the path to the old, deprecated locationnewPath
- the path to the new location