com.autonomy.config
Class ConfigSection

java.lang.Object
  |
  +--com.autonomy.config.ConfigEntry
        |
        +--com.autonomy.config.ConfigSection
Direct Known Subclasses:
ConfigFile

public class ConfigSection
extends ConfigEntry

This is a section in a configuration. It may contain other sections and ConfigKeys.


Field Summary
 
Fields inherited from class com.autonomy.config.ConfigEntry
BEGIN_CLOSE, BEGIN_OPEN, COMMENT_END, COMMENT_START, CRLF, END_CLOSE, END_OPEN, IS_FILE, IS_KEY, IS_SECTION, IS_UNKNOWN, KEY_VALUE_SEPARATOR, m_nType, USE_END_TAG
 
Constructor Summary
ConfigSection()
          Creates a blank section
ConfigSection(java.lang.String sName)
          Creates a new empty section
 
Method Summary
 void delete(java.lang.String sName)
          Removes the entry with the given name
 void display()
          Builds a String containing this section as it would appear in the configuration file, and writes to standard out
 java.lang.String[] getKeyNames()
          get a list of the sub-key names
 java.util.Vector getKeyNamesVector()
          get a list of the sub-key names
 java.lang.String getName()
          Returns the name of the config section
 java.lang.String getOriginalName(java.lang.String sSection)
          Gets the name of a sub entry as it appeared in the original file
 java.lang.String[] getSectionNames()
          get a list of the sub-section names
 java.util.Vector getSectionNamesVector()
          get a list of the sub-section names
 boolean readBoolean(java.lang.String sName, boolean bDefault)
          Returns the value of a sub-entry, as a boolean
 double readDouble(java.lang.String sName, double dDefault)
          Returns the value of a sub-entry, as a double
 int readInt(java.lang.String sName, int nDefault)
          Returns the value of a sub-entry, as an int
 com.autonomy.config.ConfigKey readKey(java.lang.String sName, java.lang.String sDefault)
          Returns a sub-key
 long readLong(java.lang.String sName, long lnDefault)
          Returns the value of a sub-entry, as a long
 com.autonomy.config.ConfigSection readSection(java.lang.String sName)
          Returns a sub-section
 com.autonomy.config.ConfigSection readSectionSafely(java.lang.String sName)
          Returns a sub-section, creating it if it does not exist
 java.lang.String readString(java.lang.String sName, java.lang.String sDefault)
          Returns the value of a sub-entry, as a String
 void setKey(com.autonomy.config.ConfigKey key)
          Sets the specified key
 void setSection(com.autonomy.config.ConfigSection section)
          Puts a new sub-section into this section
 void setString(java.lang.String sName, java.lang.String sValue)
          Creates and sets a new sub-key for this section
 java.util.Hashtable toHashtable()
          Returns the config section in a hashtable
 java.lang.String toString()
          Builds a String containing this section as it would appear in the configuration file
 
Methods inherited from class com.autonomy.config.ConfigEntry
getComments, getOriginalName, getValue, setComments, stringIsValidName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigSection

public ConfigSection()
Creates a blank section


ConfigSection

public ConfigSection(java.lang.String sName)
Creates a new empty section

Parameters:
sName - Name of the new section
Method Detail

getName

public java.lang.String getName()
Returns the name of the config section

Overrides:
getName in class ConfigEntry
Returns:
Name as a string, in lower case

getSectionNamesVector

public java.util.Vector getSectionNamesVector()
get a list of the sub-section names

Returns:
Array of Strings containing the names of only the subsections of this section, ConfigKeys are ignored

getSectionNames

public java.lang.String[] getSectionNames()
get a list of the sub-section names

Returns:
Array of Strings containing the names of only the subsections of this section, ConfigKeys are ignored

getKeyNamesVector

public java.util.Vector getKeyNamesVector()
get a list of the sub-key names

Returns:
a Vector of Strings containing the names of only the subkeys of this section, ConfigSections are ignored

getKeyNames

public java.lang.String[] getKeyNames()
get a list of the sub-key names

Returns:
Array of Strings containing the names of only the subkeys of this section, ConfigSections are ignored

readSection

public com.autonomy.config.ConfigSection readSection(java.lang.String sName)
Returns a sub-section

Parameters:
sName - Name of sub-section to return
Returns:
Section with the specified name or null if the section does not exist

readSectionSafely

public com.autonomy.config.ConfigSection readSectionSafely(java.lang.String sName)
Returns a sub-section, creating it if it does not exist

Parameters:
sName - Name of sub-section to return
Returns:
Section with the specified name

readKey

public com.autonomy.config.ConfigKey readKey(java.lang.String sName,
                                             java.lang.String sDefault)
Returns a sub-key

Parameters:
sName - Name of sub-key to return
Returns:
Section with the specified name or null if it does not exist

readString

public java.lang.String readString(java.lang.String sName,
                                   java.lang.String sDefault)
Returns the value of a sub-entry, as a String

Parameters:
sName - Name of sub-key to return
sDefault - Value to use if the entry does not exist
Returns:
Value of the entry

readInt

public int readInt(java.lang.String sName,
                   int nDefault)
Returns the value of a sub-entry, as an int

Parameters:
sName - Name of sub-key to return
nDefault - Value to use if the entry does not exist
Returns:
Value of the entry

readLong

public long readLong(java.lang.String sName,
                     long lnDefault)
Returns the value of a sub-entry, as a long

Parameters:
sName - Name of sub-key to return
lnDefault - Value to use if the entry does not exist
Returns:
Value of the entry

readDouble

public double readDouble(java.lang.String sName,
                         double dDefault)
Returns the value of a sub-entry, as a double

Parameters:
sName - Name of sub-key to return
dDefault - Value to use if the entry does not exist
Returns:
Value of the entry

readBoolean

public boolean readBoolean(java.lang.String sName,
                           boolean bDefault)
Returns the value of a sub-entry, as a boolean

Parameters:
sName - Name of sub-key to return
bDefault - Value to use if the entry does not exist
Returns:
Value of the entry

setKey

public void setKey(com.autonomy.config.ConfigKey key)
Sets the specified key

Parameters:
key - ConfigKey key to add to this section

setString

public void setString(java.lang.String sName,
                      java.lang.String sValue)
Creates and sets a new sub-key for this section

Parameters:
sName - Name of sub-key
sValue - Value of sub-key

setSection

public void setSection(com.autonomy.config.ConfigSection section)
Puts a new sub-section into this section

Parameters:
section - Section to add

delete

public void delete(java.lang.String sName)
Removes the entry with the given name

Parameters:
sName - Name of entry to remove

toString

public java.lang.String toString()
Builds a String containing this section as it would appear in the configuration file

Overrides:
toString in class java.lang.Object
Returns:
This section, as a String

display

public void display()
Builds a String containing this section as it would appear in the configuration file, and writes to standard out

Returns:
This section, as a String

getOriginalName

public java.lang.String getOriginalName(java.lang.String sSection)
Gets the name of a sub entry as it appeared in the original file


toHashtable

public java.util.Hashtable toHashtable()
Returns the config section in a hashtable