net.sourceforge.argval.utils.impl
Class PropertyLocatedFile

java.lang.Object
  extended by net.sourceforge.argval.utils.impl.PropertyLocatedFile
All Implemented Interfaces:
LocateFile

public class PropertyLocatedFile
extends Object
implements LocateFile

This LocateFile implementation provides a way for locating an file, based on a property, or based on a default name in the current working directory, or based on a default application (configuration) directory (which contains file, with the default name). The file is located as follows:

Author:
T. Verhagen

Constructor Summary
PropertyLocatedFile(String propKeyNameFile, String configDirName, String defaultFileName, org.slf4j.Logger logger)
          Creates a LocateFile specific for an application / utility.
 
Method Summary
 File getFile()
          Returns the File instance.
 String getFileMessage()
          Returns a message about how the file was located.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyLocatedFile

public PropertyLocatedFile(String propKeyNameFile,
                           String configDirName,
                           String defaultFileName,
                           org.slf4j.Logger logger)
Creates a LocateFile specific for an application / utility.

Specify the propKeyNameFile as a property key. This key can be used to specify the location of the file to locate, as system property / environment variable. As in:

java  -Dmy-application-name.configuration.path=
   org.organisation.application.Start
The folderName is optional, use it when the application has a default configuration folder in the users home directory. Like ${user.home/.my-application-config/. The defaultFileName required, used to find load the default configuration file, from the configuration application configuration directory (${user.home}/.my-application-config/defaultFileName). Or the current working directory (${user.dir}/defaultFileName).

Parameters:
propKeyNameFile - - the system property key, for locating the configuration file (not null)
configDirName - - the applications configuration directory (when it has one) (can be null)
defaultFileName - - the default configuration file name (not null).
logger - - the logging instance (not null)
Method Detail

getFile

public File getFile()
             throws FileNotFoundException
Description copied from interface: LocateFile
Returns the File instance.

Specified by:
getFile in interface LocateFile
Returns:
The File instance.
Throws:
FileNotFoundException - Is thrown in the case the file is not found.

getFileMessage

public String getFileMessage()
Description copied from interface: LocateFile
Returns a message about how the file was located.

Specified by:
getFileMessage in interface LocateFile
Returns:
A message about how the file was located.


Copyright © 2013 Verhagen Software. All Rights Reserved.