Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.jsword.util
Class Project

    java.lang.Object
      org.crosswire.jsword.util.Project

    public final class Project

extends Object

The Project class looks after the source of project files. These are per user files and as such have a different location on different operating systems. These are:

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 writeable then it will be used instead of the above location. This is useful for USB Drives and other portable implementations of JSword. I is recommended that this name be JSword.

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.`

Field Summary
`static String` | `DIR_NETCACHE` The cache of downloaded files inside the project directory
`static String` | `DIR_PROJECT` The JSword user settings directory
`static String` | `DIR_PROJECT_ALT` The JSword user settings directory for Mac and Windows
`private URI` | `home` The home for this application
`private static Project` | `instance` The filesystem resources
`private static Logger` | `log` The log stream
`private static String` | `PROPERTY_JSWORD_HOME` System property for jsword home directory

Constructor Summary
`private` | `Project()` Prevent Instansiation.

Method Summary
`URI` | `getDeprecatedUserProjectDir()` Get the location where the project dir used to be.
`URI` | `getTempScratchSpace(String subject, boolean create)` When we need a directory to write stuff to.
`URI` | `getUserProjectDir()` Establishes the user's project directory.
`URI` | `getUserProjectDir(String hiddenFolderName, String visibleFolderName)` Establishes the user's project directory.
`URI` | `getWritablePropertiesURI(String subject)` Get a the URI of a (potentially non-existant) properties file that we can write to.
`static Project` | `instance()` Accessor for the resource singleton.
`private URI` | `migrateUserProjectDir(URI oldPath, URI newPath)` Migrates the user's project dir, if necessary and possible.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DIR_NETCACHE

    public static final String DIR_NETCACHE

  The cache of downloaded files inside the project directory

  See Also:
    Constant Field Values

### DIR_PROJECT

    public static final String DIR_PROJECT

  The JSword user settings directory

  See Also:
    Constant Field Values

### DIR_PROJECT_ALT

    public static final String DIR_PROJECT_ALT

  The JSword user settings directory for Mac and Windows

  See Also:
    Constant Field Values

### PROPERTY_JSWORD_HOME

    private static final String PROPERTY_JSWORD_HOME

  System property for jsword home directory

  See Also:
    Constant Field Values

### home

    private URI home

  The home for this application

### log

    private static final Logger log

  The log stream

### instance

    private static Project instance

  The filesystem resources

Constructor Detail

### Project

    private Project()

  Prevent Instansiation.

  The biggest job is trying to work out which resource bundle to load to work out where the config and data files are stored. We construct a name from the projectname, hostname and any other info and then try to use that.

Method Detail

### instance

    public static Project instance()

  Accessor for the resource singleton.

### getUserProjectDir

    public URI getUserProjectDir(String hiddenFolderName,
                                 String visibleFolderName)

  Establishes the user's project directory.

### getUserProjectDir

    public URI getUserProjectDir()

  Establishes the user's project directory.

### getDeprecatedUserProjectDir

    public URI getDeprecatedUserProjectDir()

  Get the location where the project dir used to be.

  Returns:
    ~/.jsword

### migrateUserProjectDir

    private URI migrateUserProjectDir(URI oldPath,
                                      URI newPath)

  Migrates the user's project dir, if necessary and possible.

  Parameters:
    `oldPath` - the path to the old, deprecated location
    `newPath` - the path to the new location
  Returns:
    newPath if the migration was possible or not needed.

### getWritablePropertiesURI

    public URI getWritablePropertiesURI(String subject)

  Get a the URI of a (potentially non-existant) properties file that we can write to. This method of aquiring properties files is preferred over getResourceProperties() as this is writable and can take into account user preferences. This method makes no promise that the URI returned is valid. It is totally untested, so reading may well cause errors.

  Parameters:
    `subject` - The name (minus the .properties extension)
  Returns:
    The resource as a URI

### getTempScratchSpace

    public URI getTempScratchSpace(String subject,
                                   boolean create)
                            throws IOException

  When we need a directory to write stuff to.

  This directory should be used as a cache for something that could also be got at runtime by some other means.

  So it is not for config data, and not for program files. If someone were to delete all the files in this directory while you weren't looking then life should not stop, but should carry on albeit with a slower service.

  This method may well return null if we are running in a restricted environment, so callers of this method should be prepared for that eventuallity too.

  As a result of these limitations it could be OK to use `File` in place of `URI` (which is the norm for this project), however there doesn't seem to be a good reason to relax this rule here.

  Parameters:
    `subject` - A moniker for the area to write to. This will be converted into a directory name.
  Returns:
    A file: URI pointing at a local writable directory.
  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2007
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD