The ConfigFile class is a base class representing common properties and behavior
of a configuration file. ConfigFiles are created and managed by a PlatformConfigServlet,
which gets the location and type of the config file from it's own properties file. The
name and type information are used to get the appropriate ConfigFile subclass from a
ConfigFileFactory instance.
Each configuration file contains a collection (Vector) of ConfigItems (configuration items)
that are managed within it. These configuration items are defined in a properties file.
The ConfigFile is responsible for reading the config item definitions and creating the
appropriate ConfigItem objects (see method loadProperties()).
Once the configuration items are created, the readAll() method is used to initialize
the ConfigItems with the values currently stored in the configuration file.
The ConfigItem objects are requested by the PlatformConfigServlet, which manages their
organization and presentation in the user interface. The ConfigFile is also responsible
for using the present value of it's configuration items to generate the actual
configuration file; subclasses generally override the default method for this, writeTemp(),
to implement file-specific logic.
When the PlatformConfigServlet is ready to write settings to the configuration files,
it first calls the createBackup() method to backup the current contents of the
configuration file. It then invokes writeTemp() for each ConfigFile, which writes
a temporary copy of the config file, followed by replaceFile(), which replaces the original
file with the temporary copy just created.
The configuration files may be generated in different ways. Some files (siamPort.cfg, siamEnv)
are edited in place, using regular expressions to find and replace configuration items
with their current values. Other files (system files like rc.local, hosts, etc.) are
generated using templates, with HTML-style tags that represent places where configuration
item values should be inserted. This allows the content of these files to be changed without
recompiling the configuration tool.

Field Summary

boolean

_appendUnwrittenItems
used by writeTempFindReplace() to look for
unwritten config items and append them to the file

protected java.util.Vector

_configItems
Collection of configuration items managed through this ConfigFile

boolean

_getDisplayValue
used by writeTempFindReplace() to use the display
value for config items or use mapped (itemRef) values
of configItems

getItem(java.lang.String name)
Return an configuration item with the specified name;
note that names may not be shared among config files, i.e.,
the same item may not be managed by more than one config file.

java.lang.String

getItemValue(java.lang.String name)
Get the current value of the specified ConfigItem

_mapNull

_nullMapString

_parent

PlatformConfigServlet managing this ConfigFile. The parent servlet
has a global view of all ConfigItems, allowing this ConfigFile to
gain visibility into other configuration parameter values upon which
it depends.

setParent

getItem

Return an configuration item with the specified name;
note that names may not be shared among config files, i.e.,
the same item may not be managed by more than one config file.
(though it's value may appear in more than one config file)

getItemValue

public java.lang.String getItemValue(java.lang.String name)

Get the current value of the specified ConfigItem

readAll

public java.util.Vector readAll()

Read the configuration file and assign the values read from
the file to the ConfigItems managed by this ConfigFile.

getRows

public int getRows(java.lang.String group)

Return max number of rows called for by ConfigItem's layout parameters

getCols

public int getCols(java.lang.String group)

Return max number of columns called for by ConfigItem's layout parameters

getLayoutParameter

createBackup

Backup this file to a new name, optionally overwrite the existing backup, or keep multiple copies (file.bak.mmddyy[-n])

replaceFile

public void replaceFile(java.io.File tempFile)

replaceFile replaces the configuration file with the new version
(created by a call to writeTemp()). See also backupFile().

writeTemp

public abstract java.io.File writeTemp()

Write the current value of all configuration items to a temporary file.
This default method is generally overridden by subclasses; the default
behaviour is to search each line for the configuration items using
the importRegexp. When a match is found, the exportRegexp is used to
format the line for writing, inserting the current value of the configuration
item.
Note that this assumes that only one configuration item appears
on each line (as in Java properties files). Configuration files that
contain more than one item per line should use a template and/or
override this method.

writeTemp

public java.io.File writeTemp(int method)

writeTempSimple

public java.io.File writeTempSimple()

writeTempTagReplace

public java.io.File writeTempTagReplace()

writeTempFindReplace

public java.io.File writeTempFindReplace()

there are a couple of parameters that must be set before calling this
this method:getDisplayValue and appendUnwrittenItems

updateConfigItems

protected void updateConfigItems()
throws java.lang.Exception

Update value of ConfigItems, possibly using values
of global items. Usually this is called before writing
the files using writeTemp(). Does nothing by default;

getPath

getName

public java.lang.String getName()

Return configuration file name

main

public static void main(java.lang.String[] args)

mapOutputValue

protected java.lang.String mapOutputValue(java.lang.String s)

mapOutputValue() allows subclasses a mechanism for
mapping the value of Strings used for presentation
to a different value for output(e.g. NULL->"\0").
Subclasses may override this method to provide their
own logic and values; Returns input string by default;

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.