ccl.util
Class Init

java.lang.Object
  |
  +--ccl.util.Init

public class Init
extends java.lang.Object

Manages the ini file and configuration stuff for an application.

Right now localisation of ini file does not work with src and classes directory separation. When the ini file is inside an archive, user can't change the ini file values. In the future there should be one application ini file that can be located like a resource and a user ini file located in the user's home directory.


Constructor Summary
protected Init()
          Used only by the Init.clone method.
  Init(Exitable pExitable_, java.lang.String[] asArg_, java.lang.String sInfoHeader_)
          The ini file will be first looked for in package/exitable.ini and if not found in package/package.ini.
  Init(Exitable pExitable_, java.lang.String[] asArg_, java.lang.String sInfoHeader_, java.lang.String sIniFileContent_)
          If sIniFileContent_ is null for the ini file will be first looked for in package/exitable.ini and if not found in package/package.ini.
 
Method Summary
 java.lang.Object clone()
          Return a copy of this object.
 java.lang.String colorToString(java.awt.Color pColor_)
           
 java.lang.String createBackupFile()
          Create a backup of the ini file.
 java.lang.String getApplicationDocPath()
          Return location of doc directory for this application.
 java.lang.String getApplicationName()
          The first char is upper case (like "Project").
 java.lang.String getApplicationPath()
           
static java.lang.String getApplicationPath(java.lang.String sApplicationName, java.lang.String sPackageName, java.lang.String sClassPath)
          Get Application Path.
 java.util.Vector getArguments()
           
 java.util.Enumeration getArgumentsElements()
           
 java.lang.String getAuthor()
           
 java.awt.Color getBackground()
           
 java.lang.String getFileFullName()
           
 java.lang.String getFileName()
          First char is upper case, the rest lower case.
 java.lang.String getFilePath()
          Deprecated.  
 java.awt.Color getForeground()
           
 java.lang.String getHelpBrokerURL()
          Return location of the help set documentation file for this application.
 java.lang.String getHelpMessage()
           
 java.lang.String getInfoHeader()
           
 java.lang.String getKeyValue(java.lang.String sKey_)
           
 java.lang.String getKeyValue(java.lang.String sSection_, java.lang.String sKey_)
           
 java.awt.Color getListBackground()
           
 java.awt.Color getListForeground()
           
 java.awt.Color getListHighlight()
           
 java.lang.String getOldFileFullName(java.lang.String string)
           
 java.util.Enumeration getOldFilesElements()
           
 int getOldFilesSize()
           
 java.util.Hashtable getOptions()
           
 java.lang.String getProjectHome()
          Returns the directory of the current projects file.
static java.lang.String getProjectSuffixKey()
           
 int getRelease()
           
 int getVersion()
           
 java.lang.String getVersionDate()
           
 java.lang.String getVersionString()
           
 java.lang.String getVersionTime()
           
 void makeThisFileOld()
          This method stores the actual file in the old file vector, no saving or anything else like removing double fils.
 void printHelpMessage()
           
 void setApplicationName(java.lang.String sApplicationName_)
          Set the application name explicitly.
 void setAuthor(java.lang.String sAuthor_)
           
 void setBackground(java.awt.Color pColor_)
           
 boolean setFileFullName(java.lang.String sFileFullName_)
          For File->New use "" or null for sFileFullName_.
 boolean setKeyValue(java.lang.String sKey_, int value_)
           
 boolean setKeyValue(java.lang.String sKey_, java.lang.String sValue_)
           
 boolean setKeyValue(java.lang.String sSection_, java.lang.String sKey_, java.lang.String sValue_)
           
 void setListBackground(java.awt.Color pColor_)
           
 void setListForeground(java.awt.Color pColor_)
           
 void setListHighlight(java.awt.Color pColor_)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Init

public Init(Exitable pExitable_,
            java.lang.String[] asArg_,
            java.lang.String sInfoHeader_,
            java.lang.String sIniFileContent_)
If sIniFileContent_ is null for the ini file will be first looked for in package/exitable.ini and if not found in package/package.ini.

Following some implementation details:

If the sIniFileContent_ parameter is set, this will be used when reading ini content.

All relative elements in the classpath will be exchanged with their absolute counter parts.

Ini file location:
1. Set by user as option.

Parameters:
pExitable_ - the controlling application object.
asArg_ - the original command line arguments forwarded from the main method.
sInfoHeader_ - an RCS Header string from the application Main class.
sIniFileContent_ - default content for an ini file.

Init

public Init(Exitable pExitable_,
            java.lang.String[] asArg_,
            java.lang.String sInfoHeader_)
The ini file will be first looked for in package/exitable.ini and if not found in package/package.ini.

Parameters:
pExitable_ - the controlling application object.
asArg_ - the original command line arguments forwarded from the main method.
sInfoHeader_ - an RCS Header string from the application Main class.

Init

protected Init()
Used only by the Init.clone method.

Method Detail

getApplicationPath

public static java.lang.String getApplicationPath(java.lang.String sApplicationName,
                                                  java.lang.String sPackageName,
                                                  java.lang.String sClassPath)
Get Application Path.


getHelpMessage

public java.lang.String getHelpMessage()

printHelpMessage

public void printHelpMessage()

setKeyValue

public boolean setKeyValue(java.lang.String sKey_,
                           int value_)
Returns:
true on error.

setKeyValue

public boolean setKeyValue(java.lang.String sKey_,
                           java.lang.String sValue_)
Returns:
true on error.

setKeyValue

public boolean setKeyValue(java.lang.String sSection_,
                           java.lang.String sKey_,
                           java.lang.String sValue_)
Returns:
true on error.

getArguments

public java.util.Vector getArguments()

getOptions

public java.util.Hashtable getOptions()

getArgumentsElements

public java.util.Enumeration getArgumentsElements()

getKeyValue

public java.lang.String getKeyValue(java.lang.String sSection_,
                                    java.lang.String sKey_)

getKeyValue

public java.lang.String getKeyValue(java.lang.String sKey_)

getInfoHeader

public java.lang.String getInfoHeader()
See Also:
getVersionString()

getBackground

public java.awt.Color getBackground()

getForeground

public java.awt.Color getForeground()

getListBackground

public java.awt.Color getListBackground()

getListForeground

public java.awt.Color getListForeground()

getListHighlight

public java.awt.Color getListHighlight()

colorToString

public java.lang.String colorToString(java.awt.Color pColor_)

setBackground

public void setBackground(java.awt.Color pColor_)

setListBackground

public void setListBackground(java.awt.Color pColor_)

setListForeground

public void setListForeground(java.awt.Color pColor_)

setListHighlight

public void setListHighlight(java.awt.Color pColor_)

setApplicationName

public void setApplicationName(java.lang.String sApplicationName_)
Set the application name explicitly. The standard name is normally the name of the main package.


getApplicationName

public java.lang.String getApplicationName()
The first char is upper case (like "Project").


getApplicationPath

public java.lang.String getApplicationPath()
Returns:
for example: "/home/clemens/src/java/jacob"

getHelpBrokerURL

public java.lang.String getHelpBrokerURL()
Return location of the help set documentation file for this application. The hs file should be located in the doc directory with name applicationname.hs.

Returns:
E.g. "file:/home/clemens/project/doc/appname.hs"

getApplicationDocPath

public java.lang.String getApplicationDocPath()
Return location of doc directory for this application.

Returns:
E.g. "file:/home/clemens/ccl/doc"

setFileFullName

public boolean setFileFullName(java.lang.String sFileFullName_)
For File->New use "" or null for sFileFullName_.

Returns:
IniFile status.

getFileName

public java.lang.String getFileName()
First char is upper case, the rest lower case. Only the name is returned, no path or file postfix information is given.

See Also:
getFileFullName(), getFilePath()

getFileFullName

public java.lang.String getFileFullName()

getFilePath

public java.lang.String getFilePath()
Deprecated.  

Returns:
File separator is '/' and the path ends with a file separator char.
See Also:
getProjectHome()

getProjectHome

public java.lang.String getProjectHome()
Returns the directory of the current projects file.


getOldFilesElements

public java.util.Enumeration getOldFilesElements()

getOldFilesSize

public int getOldFilesSize()

getOldFileFullName

public java.lang.String getOldFileFullName(java.lang.String string)

makeThisFileOld

public void makeThisFileOld()
This method stores the actual file in the old file vector, no saving or anything else like removing double fils.


getVersionString

public java.lang.String getVersionString()

getVersion

public int getVersion()

getRelease

public int getRelease()

getVersionDate

public java.lang.String getVersionDate()
Returns:
The right language is automaticly used.

getVersionTime

public java.lang.String getVersionTime()

getProjectSuffixKey

public static java.lang.String getProjectSuffixKey()

getAuthor

public java.lang.String getAuthor()

setAuthor

public void setAuthor(java.lang.String sAuthor_)

createBackupFile

public java.lang.String createBackupFile()
Create a backup of the ini file.

Returns:
Error message in case something went wrong, null otherwise.

clone

public java.lang.Object clone()
Return a copy of this object.

Overrides:
clone in class java.lang.Object