org.igfay.jfig
Class JFigLocator

java.lang.Object
  extended byorg.igfay.jfig.JFigLocator
All Implemented Interfaces:
JFigLocatorIF

public class JFigLocator
extends java.lang.Object
implements JFigLocatorIF

Author:
conrad4 Locate the intial Configuration file. Users may write their own implementation of JFigLocatorIF with their own scheme of finding the initial configuration file. Best method may be to subclass the JFig implementation. Then, initialize JFig via: getInstance(JFigLocatorIF), passing your implementation.

Field Summary
protected  java.lang.String configDirectory
           
protected  java.lang.String configFileName
           
protected  java.lang.String configLocation
           
 
Constructor Summary
JFigLocator(java.lang.String fileName)
           
 
Method Summary
 java.lang.String getConfigDirectory()
          Return the config directory.
 java.lang.String getConfigFileName()
          Return the config fileName.
 java.lang.String getConfigLocation()
          Return the config location; file or classpath If user specified LOCATION_PROPERTY on the command line, use that.
 java.lang.String getDefaultConfigFileName()
          Return a default config fileName.
 java.io.InputStream getInputStream()
          Return the config file as an InputStream
protected  java.io.InputStream getInputStreamForClasspath()
          Find the input stream in the classpath
protected  java.io.InputStream getInputStreamForFile(java.io.InputStream inputStream)
          Find the input stream in the file system.
protected  void parseInitialFileName()
          Parse the directory name if one is specified.
 void setConfigDirectory(java.lang.String value)
          Set the configDirectory.
 void setConfigFileName(java.lang.String value)
           
 void setConfigLocation(java.lang.String value)
          Set the config location; must be FILE or CLASSPATH.
 void setDefaultConfigFileName(java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configFileName

protected java.lang.String configFileName

configLocation

protected java.lang.String configLocation

configDirectory

protected java.lang.String configDirectory
Constructor Detail

JFigLocator

public JFigLocator(java.lang.String fileName)
Method Detail

getConfigLocation

public java.lang.String getConfigLocation()
                                   throws JFigException
Return the config location; file or classpath If user specified LOCATION_PROPERTY on the command line, use that. Otherwise, default to CLASSPATH.

Specified by:
getConfigLocation in interface JFigLocatorIF
Returns:
String
Throws:
JFigException

getDefaultConfigFileName

public java.lang.String getDefaultConfigFileName()
Return a default config fileName. The filename will be the project name and the machine name. This is used when no config. filename is passed as an argument.

Specified by:
getDefaultConfigFileName in interface JFigLocatorIF
Returns:

getConfigFileName

public java.lang.String getConfigFileName()
Return the config fileName. This will be the last file processed.

Specified by:
getConfigFileName in interface JFigLocatorIF

parseInitialFileName

protected void parseInitialFileName()
Parse the directory name if one is specified. This is only done on the initial file name. That way, the initial directory name is saved for use on subsequent files.


setConfigFileName

public void setConfigFileName(java.lang.String value)
Specified by:
setConfigFileName in interface JFigLocatorIF

setConfigLocation

public void setConfigLocation(java.lang.String value)
                       throws JFigException
Description copied from interface: JFigLocatorIF
Set the config location; must be FILE or CLASSPATH. If not, throw exception

Specified by:
setConfigLocation in interface JFigLocatorIF
Parameters:
value -
Throws:
JFigException
See Also:
JFigLocatorIF.setConfigLocation(java.lang.String)

setDefaultConfigFileName

public void setDefaultConfigFileName(java.lang.String value)
Specified by:
setDefaultConfigFileName in interface JFigLocatorIF
See Also:
JFigLocatorIF.setDefaultConfigFileName(java.lang.String)

getInputStream

public java.io.InputStream getInputStream()
                                   throws JFigException
Return the config file as an InputStream

Specified by:
getInputStream in interface JFigLocatorIF
Throws:
JFigException

getInputStreamForFile

protected java.io.InputStream getInputStreamForFile(java.io.InputStream inputStream)
                                             throws JFigException
Find the input stream in the file system.

Parameters:
inputStream -
Returns:
Throws:
JFigException

getInputStreamForClasspath

protected java.io.InputStream getInputStreamForClasspath()
                                                  throws JFigException
Find the input stream in the classpath

Returns:
Throws:
JFigException

getConfigDirectory

public java.lang.String getConfigDirectory()
Return the config directory. This directory is parsed from the initial config.name that is set. It is not changed by subsequent config file names. That enables subsequent file names to set their paths relative to the initial.


setConfigDirectory

public void setConfigDirectory(java.lang.String value)
Set the configDirectory. Parsed from the initial config.file name