com.karlockhart.util.config.configurator
Class Configurator

java.lang.Object
  extended by com.karlockhart.util.config.configurator.Configurator
All Implemented Interfaces:
java.io.Serializable

public class Configurator
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Method Summary
 boolean getExistOrDefaultBool(java.lang.String key, boolean value)
          If the value contains the key return it and if not set the passed value.
 int getExistOrDefaultInt(java.lang.String key, int value)
          If the value contains the key return it and if not set the passed value.
 java.lang.String getExistOrDefaultStr(java.lang.String key, java.lang.String value)
          If the value contains the key return it and if not set the passed value.
static Configurator getInstance()
          This is the getInstance method of the Singleton Configurator.
 boolean getPropertyBool(java.lang.String key)
          Returns the value of the property referred to by this key.
 int getPropertyInt(java.lang.String key)
          Returns the value of the property referred to by this key.
 java.lang.String getPropertyStr(java.lang.String key)
          Returns the value of the property referred to by this key.
 boolean isBoolSet(java.lang.String key)
          Returns true if this key exists and false if it does not.
 boolean isIntSet(java.lang.String key)
          Returns true if this key exists and false if it does not.
 boolean isStrSet(java.lang.String key)
          Returns true if this key exists and false if it does not.
 void removeBoolKey(java.lang.String key)
          Deletes the property related to this key.
 void removeIntKey(java.lang.String key)
          Deletes the property related to this key.
 void removeStrKey(java.lang.String key)
          Deletes the property related to this key.
 void setPropertyBool(java.lang.String key, boolean value)
           
 void setPropertyInt(java.lang.String key, int value)
          Sets the value for the provided key.
 void setPropertyStr(java.lang.String key, java.lang.String value)
          Sets the value for the provided key.
 void writeConfiguration()
          Writes the configuration file to disk using serialization of the Configurator object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Configurator getInstance()
This is the getInstance method of the Singleton Configurator. The Configurator does not allow the user to instantiate the base object. This is the only way to access the global instance of the Configurator.


getPropertyBool

public boolean getPropertyBool(java.lang.String key)
Returns the value of the property referred to by this key. This method is for boolean properties.

Parameters:
key - The text key that refers to the property you wish to retrieve
Returns:
the value of the property referred to by the key

setPropertyBool

public void setPropertyBool(java.lang.String key,
                            boolean value)

isBoolSet

public boolean isBoolSet(java.lang.String key)
Returns true if this key exists and false if it does not. This method is for boolean properties.

Parameters:
key - The key to check for existence.

removeBoolKey

public void removeBoolKey(java.lang.String key)
Deletes the property related to this key. This method is for boolean properties.

Parameters:
key - The key whose property will be deleted.

getExistOrDefaultBool

public boolean getExistOrDefaultBool(java.lang.String key,
                                     boolean value)
If the value contains the key return it and if not set the passed value. This method is for boolean properties.

Parameters:
key - The key to check for existence.
value - The value to set if this key does not exist
Returns:
the value of the key

getPropertyInt

public int getPropertyInt(java.lang.String key)
Returns the value of the property referred to by this key. This method is for integer properties.

Parameters:
key - The text key that refers to the property you wish to retrieve
Returns:
the value of the property referred to by the key

setPropertyInt

public void setPropertyInt(java.lang.String key,
                           int value)
Sets the value for the provided key. This method is for integer properties.

Parameters:
key - The text key that the value is to be set for.
value - The value to set in the property.

isIntSet

public boolean isIntSet(java.lang.String key)
Returns true if this key exists and false if it does not. This method is for integer properties.

Parameters:
key - The key to check for existence.

removeIntKey

public void removeIntKey(java.lang.String key)
Deletes the property related to this key. This method is for integer properties.

Parameters:
key - The key whose property will be deleted.

getExistOrDefaultInt

public int getExistOrDefaultInt(java.lang.String key,
                                int value)
If the value contains the key return it and if not set the passed value. This method is for integer properties.

Parameters:
key - The key to check for existence.
value - The value to set if this key does not exist
Returns:
the value of the key

getPropertyStr

public java.lang.String getPropertyStr(java.lang.String key)
Returns the value of the property referred to by this key. This method is for string properties.

Parameters:
key - The text key that refers to the property you wish to retrieve
Returns:
the value of the property referred to by the key

setPropertyStr

public void setPropertyStr(java.lang.String key,
                           java.lang.String value)
Sets the value for the provided key. This method is for string properties.

Parameters:
key - The text key that the value is to be set for.
value - The value to set in the property.

isStrSet

public boolean isStrSet(java.lang.String key)
Returns true if this key exists and false if it does not. This method is for string properties.

Parameters:
key - The key to check for existence.

getExistOrDefaultStr

public java.lang.String getExistOrDefaultStr(java.lang.String key,
                                             java.lang.String value)
If the value contains the key return it and if not set the passed value. This method is for string properties.

Parameters:
key - The key to check for existence.
value - The value to set if this key does not exist
Returns:
the value of the key

removeStrKey

public void removeStrKey(java.lang.String key)
Deletes the property related to this key. This method is for string properties.

Parameters:
key - The key whose property will be deleted.

writeConfiguration

public void writeConfiguration()
Writes the configuration file to disk using serialization of the Configurator object.