javazoom.jlgui.player.amp.util.ini

Class Configuration


public class Configuration
extends java.lang.Object

A Configuration is used to save a set of configuration 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

Configuration()
Constructs a new Configuration object that doesn't have a file associated with it.
Configuration(File config_file)
Constructs a new Configuration object that stores it's properties in the given file.
Configuration(String file_name)
Constructs a new Configuration object that stores it's properties in the file with the given name.
Configuration(URL config_file)
Constructs a new Configuration object that stores it's properties in the given file.

Method Summary

void
add(String name, String value)
Adds a the property with the given name and value.
void
add(String name, boolean value)
Adds the boolean property.
void
add(String name, double value)
Adds the double property.
void
add(String name, int value)
Adds the integer property.
String
get(String name)
Returns the value of the property with the given name.
String
get(String name, String default_value)
Returns the value of the property with the given name.
boolean
getBoolean(String name)
Returns the value of the property with the given name.
boolean
getBoolean(String name, boolean default_value)
Returns the value of the property with the given name.
File
getConfigFile()
double
getDouble(String name)
Returns the value of the property with the given name.
double
getDouble(String name, double default_value)
Returns the value of the property with the given name.
int
getInt(String name)
Returns the value of the property with the given name.
int
getInt(String name, int default_value)
Returns the value of the property with the given name.
boolean
isValidCRC()
boolean
load()
Loads the property list from the configuration file.
boolean
load(BufferedReader buffy)
void
remove(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(PrintWriter out)
void
storeCRC()

Constructor Details

Configuration

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

Configuration

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

Configuration

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

Configuration

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

Method Details

add

public void add(String name,
                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(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(String name,
                double value)
Adds the double property.
Parameters:
name - The name of the property.
value - The value of the property.

add

public void add(String name,
                int value)
Adds the integer property.
Parameters:
name - The name of the property.
value - The value of the property.

get

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

get

public String get(String name,
                  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:
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(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.

getBoolean

public boolean getBoolean(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.

getConfigFile

public File getConfigFile()
Returns:
The config file.

getDouble

public double getDouble(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.

getDouble

public double getDouble(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.

getInt

public int getInt(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.

getInt

public int getInt(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.

isValidCRC

public boolean isValidCRC()

load

public boolean load()
Loads the property list from the configuration 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(BufferedReader buffy)
            throws IOException

remove

public void remove(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.

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(PrintWriter out)
            throws IOException

storeCRC

public void storeCRC()

JavaZOOM 1999-2006