com.miami.romeo.config
Class Config

java.lang.Object
  extended bycom.miami.romeo.config.Config

public class Config
extends java.lang.Object

A Config is used to save a set of Config properties. The properties can be written out to disk in "name=value" form, and read back in.

Version:
1.2.0
Author:
Jeremy Cloud

Constructor Summary
Config()
          Constructs a new Config object that doesn't have a file associated with it.
Config(java.io.File config_file)
          Constructs a new Config object that stores it's properties in the given file.
Config(java.lang.String file_name)
          Constructs a new Config object that stores it's properties in the file with the given name.
Config(java.net.URL config_file)
          Constructs a new Config object that stores it's properties in the given file.
 
Method Summary
 void add(java.lang.String name, boolean value)
          Adds the boolean property.
 void add(java.lang.String name, double value)
          Adds the double property.
 void add(java.lang.String name, int value)
          Adds the integer property.
 void add(java.lang.String name, java.lang.String value)
          Adds a the property with the given name and value.
 java.lang.String get(java.lang.String name)
          Returns the value of the property with the given name.
 java.lang.String get(java.lang.String name, java.lang.String default_value)
          Returns the value of the property with the given name.
 boolean getBoolean(java.lang.String name)
          Returns the value of the property with the given name.
 boolean getBoolean(java.lang.String name, boolean default_value)
          Returns the value of the property with the given name.
 java.io.File getConfigFile()
           
 double getDouble(java.lang.String name)
          Returns the value of the property with the given name
 double getDouble(java.lang.String name, double default_value)
          Returns the value of the property with the given name.
 int getInt(java.lang.String name)
          Returns the value of the property with the given name
 int getInt(java.lang.String name, int default_value)
          Returns the value of the property with the given name.
 boolean load()
          Loads the property list from the Config file.
 boolean load(java.io.BufferedReader buffy)
           
 void remove(java.lang.String name)
          Removes the property with the given name.
 void removeAll()
          Removes all the properties.
 boolean save()
          Saves the property list to the config file.
 boolean save(java.io.PrintWriter out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Config

public Config(java.lang.String file_name)
Constructs a new Config object that stores it's properties in the file with the given name.


Config

public Config(java.io.File config_file)
Constructs a new Config object that stores it's properties in the given file.


Config

public Config(java.net.URL config_file)
Constructs a new Config object that stores it's properties in the given file.


Config

public Config()
Constructs a new Config object that doesn't have a file associated with it.

Method Detail

getConfigFile

public java.io.File getConfigFile()
Returns:
The config file.

add

public void add(java.lang.String name,
                java.lang.String value)
Adds a the property with the given name and value.

Parameters:
name - The name of the property.
value - The value of the property.

add

public void add(java.lang.String name,
                boolean value)
Adds the boolean property.

Parameters:
name - The name of the property.
value - The value of the property.

add

public void add(java.lang.String name,
                int value)
Adds the integer property.

Parameters:
name - The name of the property.
value - The value of the property.

add

public void add(java.lang.String name,
                double value)
Adds the double property.

Parameters:
name - The name of the property.
value - The value of the property.

get

public java.lang.String get(java.lang.String name)
Returns the value of the property with the given name. Null is returned if the named property is not found.

Parameters:
name - The name of the desired property.
Returns:
The value of the property.

get

public java.lang.String get(java.lang.String name,
                            java.lang.String default_value)
Returns the value of the property with the given name. 'default_value' is returned if the named property is not found.

Parameters:
name - The name of the desired property.
default_value - The default value of the property which is returned if the property does not have a specified value.
Returns:
The value of the property.

getBoolean

public boolean getBoolean(java.lang.String name)
Returns the value of the property with the given name. 'false' is returned if the property does not have a specified value.

Parameters:
name - The name of the desired property.
Returns:
The value of the property.

getBoolean

public boolean getBoolean(java.lang.String name,
                          boolean default_value)
Returns the value of the property with the given name.

Parameters:
name - The name of the desired property.
default_value - The default value of the property which is returned if the property does not have a specified value.
Returns:
The value of the property.

getInt

public int getInt(java.lang.String name)
Returns the value of the property with the given name. '0' is returned if the property does not have a specified value.

Parameters:
name - The name of the desired property.
Returns:
The value of the property.

getInt

public int getInt(java.lang.String name,
                  int default_value)
Returns the value of the property with the given name.

Parameters:
name - The name of the desired property.
default_value - The default value of the property which is returned if the property does not have a specified value.
Returns:
The value of the property.

getDouble

public double getDouble(java.lang.String name)
Returns the value of the property with the given name. '0' is returned if the property does not have a specified value.

Parameters:
name - The name of the desired property.
Returns:
The value of the property.

getDouble

public double getDouble(java.lang.String name,
                        double default_value)
Returns the value of the property with the given name.

Parameters:
name - The name of the desired property.
default_value - The default value of the property which is returned if the property does not have a specified value.
Returns:
The value of the property.

remove

public void remove(java.lang.String name)
Removes the property with the given name.

Parameters:
name - The name of the property to remove.

removeAll

public void removeAll()
Removes all the properties.


load

public boolean load()
Loads the property list from the Config file.

Returns:
True if the file was loaded successfully, false if the file does not exists or an error occurred reading the file.

load

public boolean load(java.io.BufferedReader buffy)
             throws java.io.IOException
Throws:
java.io.IOException

save

public boolean save()
Saves the property list to the config file.

Returns:
True if the save was successful, false othewise.

save

public boolean save(java.io.PrintWriter out)
             throws java.io.IOException
Throws:
java.io.IOException