cynosurex.io
Class ConfigureINI

java.lang.Object
  extended by cynosurex.io.ConfigureINI
All Implemented Interfaces:
cynosurex.internal.AuthorCommon, cynosurex.internal.CommonInterface, cynosurex.internal.CompanyCommon

public class ConfigureINI
extends java.lang.Object
implements cynosurex.internal.CommonInterface

Reads and writes Windows INI configuration files.


Field Summary
 
Fields inherited from interface cynosurex.internal.CommonInterface
copyright, copyrightYears, notice, program, version
 
Fields inherited from interface cynosurex.internal.AuthorCommon
author, copyrightSymbol, noticeMsg, rights
 
Fields inherited from interface cynosurex.internal.CompanyCommon
company, email, website
 
Constructor Summary
ConfigureINI(java.io.File configFile)
          Constructor.
 
Method Summary
 boolean containsParameter(java.lang.String section, java.lang.String parameter)
          Whether this object contains the configuration parameter.
 boolean containsSection(java.lang.String section)
           
 java.lang.String get(java.lang.String section, java.lang.String parameter)
          This method retrieves a value based on the specified section and parameter name.
 boolean getBoolean(java.lang.String section, java.lang.String parameter)
          This method retrieves a boolean value based on the specified section and parameter name.
 java.lang.Double getDouble(java.lang.String section, java.lang.String parameter)
          This method retrieves a double value based on the specified section and parameter name.
 java.lang.Float getFloat(java.lang.String section, java.lang.String parameter)
          This method retrieves a float value based on the specified section and parameter name.
 int getInteger(java.lang.String section, java.lang.String parameter)
          This method retrieves an integer value based on the specified section and parameter name.
 long getLong(java.lang.String section, java.lang.String parameter)
          This method retrieves a long value based on the specified section and parameter name.
 boolean isEmpty()
           
 boolean isEmpty(java.lang.String section)
           
 void put(java.lang.String section, java.lang.String parameter, java.lang.String value)
          This method puts a configuration value into this object.
 boolean read()
          Reads the configuration file.
 java.lang.String remove(java.lang.String section, java.lang.String parameter)
          This method removes a configuration value from this object.
 java.lang.String toString()
          This method returns the entire configuration in the object in a String format.
 void write()
          Writes the configuration file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigureINI

public ConfigureINI(java.io.File configFile)
Constructor.

Parameters:
configFile - The INI configuration file object.
Method Detail

containsSection

public boolean containsSection(java.lang.String section)

containsParameter

public boolean containsParameter(java.lang.String section,
                                 java.lang.String parameter)
Whether this object contains the configuration parameter.

Parameters:
section - The section to search the parameter for.
Returns:
true if this object contains the value.

get

public java.lang.String get(java.lang.String section,
                            java.lang.String parameter)
This method retrieves a value based on the specified section and parameter name.

Parameters:
section - The section name.
parameter - The parameter name.
Returns:
The value associated to the section and parameter.

getBoolean

public boolean getBoolean(java.lang.String section,
                          java.lang.String parameter)
This method retrieves a boolean value based on the specified section and parameter name. Acceptable case-insensitive string for true: "yes", "true", "1". Acceptable case-insensitive string for false: "no", "false, "0". Currently, all other string values also defaults to false.

Parameters:
section - The section name.
parameter - The parameter name.
Returns:
The boolean value associated to the section and parameter.

getDouble

public java.lang.Double getDouble(java.lang.String section,
                                  java.lang.String parameter)
This method retrieves a double value based on the specified section and parameter name.

Parameters:
section - The section name.
parameter - The parameter name.
Returns:
The float value associated to the section and parameter.

getFloat

public java.lang.Float getFloat(java.lang.String section,
                                java.lang.String parameter)
This method retrieves a float value based on the specified section and parameter name.

Parameters:
section - The section name.
parameter - The parameter name.
Returns:
The float value associated to the section and parameter.

getInteger

public int getInteger(java.lang.String section,
                      java.lang.String parameter)
This method retrieves an integer value based on the specified section and parameter name.

Parameters:
section - The section name.
parameter - The parameter name.
Returns:
The integer value associated to the section and parameter.

getLong

public long getLong(java.lang.String section,
                    java.lang.String parameter)
This method retrieves a long value based on the specified section and parameter name.

Parameters:
section - The section name.
parameter - The parameter name.
Returns:
The long value associated to the section and parameter.

isEmpty

public boolean isEmpty()

isEmpty

public boolean isEmpty(java.lang.String section)

put

public void put(java.lang.String section,
                java.lang.String parameter,
                java.lang.String value)
This method puts a configuration value into this object.

Parameters:
section - The section to place the value.
parameter - The parameter to place the value under.
value - The actual value.

read

public boolean read()
Reads the configuration file. You must call this method before attempting to retrieving any configuration parameters. Otherwise, you will fail to retrieve the configuration parameter.

Returns:
true if configuration file is read successfully. False otherwise.

remove

public java.lang.String remove(java.lang.String section,
                               java.lang.String parameter)
This method removes a configuration value from this object.

Parameters:
section - The section to look for the parameter.
parameter - The parameter to remove.
Returns:
The value that was removed.

toString

public java.lang.String toString()
This method returns the entire configuration in the object in a String format.

Overrides:
toString in class java.lang.Object

write

public void write()
Writes the configuration file.