dods.util
Class iniFile

java.lang.Object
  extended by dods.util.iniFile
Direct Known Subclasses:
DODSiniFile

public class iniFile
extends java.lang.Object

This class encapsulates the old .ini file functionality that we used to see (and still do) in the Microsoft Operating Systems. This is a handy way of delivering configuration information to software at runtime. The .ini file structure is as follows:

[SectionName]
PropertyName = Property
NextPropertyName = Property2
AnotherPropertyName = Property3

[AnotherSectionName]
PropertyName = Property
NextPropertyName = Property2
AnotherPropertyName = Property3

This class opens and parses the iniFile it's constructor. If the file isn't accesible or is unparsable then the class will not contain any usable configuration information.


Constructor Summary
protected iniFile()
          We don't want this to get used so we made it protected...
  iniFile(java.lang.String fname)
          Create a iniFile object from the file named in the parameter fname.
  iniFile(java.lang.String path, java.lang.String fname)
          Create a iniFile object from the file named in the parameter fname, and found on the parameter path
  iniFile(java.lang.String path, java.lang.String fname, boolean dbg)
          Create a iniFile object from the file named in the parameter fname, and found on the parameter path
 
Method Summary
 java.lang.String getFileName()
          Get the name of the .ini file that was used to create this object.
 java.lang.String getProperty(java.lang.String propertyName)
          Get the named property from the current section.
 java.util.Enumeration getPropList(java.lang.String sectionName)
          Get the list of properties for the section sectionName.
 java.util.Enumeration getSectionList()
          Get the list of Sections of this .ini File
 void printProps(java.io.PrintStream ps)
          Prints the iniFile.
 boolean setSection(java.lang.String sectionName)
          Set the section of the iniFile that you wish to work with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

iniFile

protected iniFile()
We don't want this to get used so we made it protected...


iniFile

public iniFile(java.lang.String fname)
Create a iniFile object from the file named in the parameter fname. The object will get the append to the file name to the path returned by the call System.getProperty("user.home").

Parameters:
fname - A String containing the name of the .ini file.

iniFile

public iniFile(java.lang.String path,
               java.lang.String fname)
Create a iniFile object from the file named in the parameter fname, and found on the parameter path

Parameters:
path - A String containing the path to the .ini file.
fname - A String containing the name of the .ini file.

iniFile

public iniFile(java.lang.String path,
               java.lang.String fname,
               boolean dbg)
Create a iniFile object from the file named in the parameter fname, and found on the parameter path

Parameters:
path - A String containing the path to the .ini file.
fname - A String containing the name of the .ini file.
dbg - A boolean that toggles debugging output.
Method Detail

getFileName

public java.lang.String getFileName()
Get the name of the .ini file that was used to create this object. returns A String containing the name of the .ini file that was opened a parsed when this object was instantiated.


getPropList

public java.util.Enumeration getPropList(java.lang.String sectionName)
Get the list of properties for the section sectionName.

Parameters:
sectionName - A String containing the name of the section whose property list is desired.

getProperty

public java.lang.String getProperty(java.lang.String propertyName)
Get the named property from the current section.

Parameters:
propertyName - The name of the desired property.

getSectionList

public java.util.Enumeration getSectionList()
Get the list of Sections of this .ini File


printProps

public void printProps(java.io.PrintStream ps)
Prints the iniFile.

Parameters:
ps - The PrintStream to which to print.

setSection

public boolean setSection(java.lang.String sectionName)
Set the section of the iniFile that you wish to work with. This is persistent for the life of the object, or until it's set again.

Parameters:
sectionName - A String containing the name of the section that is desired.