org.apache.commons.configuration

Interface FileConfiguration

public interface FileConfiguration extends Configuration

A persistent configuration loaded and saved to a file.

Since: 1.0-rc2

Version: $Revision: 492234 $, $Date: 2007-01-03 18:39:39 +0100 (Mi, 03 Jan 2007) $

Author: Emmanuel Bourg

Method Summary
StringgetBasePath()
Returns the base path.
StringgetEncoding()
Return the encoding used to store the configuration file.
FilegetFile()
Return the file where the configuration is stored.
StringgetFileName()
Return the name of the file.
ReloadingStrategygetReloadingStrategy()
Return the reloading strategy.
URLgetURL()
Return the URL where the configuration is stored.
booleanisAutoSave()
Tells if properties are automatically saved to the disk.
voidload()
Load the configuration from the underlying URL.
voidload(String fileName)
Locate the specified file and load the configuration.
voidload(File file)
Load the configuration from the specified file.
voidload(URL url)
Load the configuration from the specified URL.
voidload(InputStream in)
Load the configuration from the specified stream, using the encoding returned by getEncoding.
voidload(InputStream in, String encoding)
Load the configuration from the specified stream, using the specified encoding.
voidload(Reader in)
Load the configuration from the specified reader.
voidreload()
Reload the configuration.
voidsave()
Save the configuration.
voidsave(String fileName)
Save the configuration to the specified file.
voidsave(File file)
Save the configuration to the specified file.
voidsave(URL url)
Save the configuration to the specified URL if it's a file URL.
voidsave(OutputStream out)
Save the configuration to the specified stream, using the encoding returned by getEncoding.
voidsave(OutputStream out, String encoding)
Save the configuration to the specified stream, using the specified encoding.
voidsave(Writer out)
Save the configuration to the specified writer.
voidsetAutoSave(boolean autoSave)
Enable or disable the automatical saving of modified properties to the disk.
voidsetBasePath(String basePath)
Sets the base path.
voidsetEncoding(String encoding)
Set the encoding used to store the configuration file.
voidsetFile(File file)
Set the file where the configuration is stored.
voidsetFileName(String fileName)
Set the name of the file.
voidsetReloadingStrategy(ReloadingStrategy strategy)
Set the reloading strategy.
voidsetURL(URL url)
The URL where the configuration is stored.

Method Detail

getBasePath

public String getBasePath()
Returns the base path. One way to specify the location of a configuration source is by setting its base path and its file name. This method returns this base path. The concrete value returned by this method depends on the way the location of the configuration file was set. If methods like setFile() or setURL() were used, the base path typically points to the parent directory of the configuration file (e.g. for the URL file:/temp/test.properties the base path will be file:/temp/). If the base path was explictly set using setBasePath(), this method will return the exact value specified here without further modifications.

Returns: the base path

See Also: setBasePath

getEncoding

public String getEncoding()
Return the encoding used to store the configuration file. If the value is null the default encoding is used.

Returns: the current encoding

Since: 1.1

getFile

public File getFile()
Return the file where the configuration is stored.

Returns: the configuration file

getFileName

public String getFileName()
Return the name of the file.

Returns: the file name

getReloadingStrategy

public ReloadingStrategy getReloadingStrategy()
Return the reloading strategy.

Returns: the reloading strategy currently used

Since: 1.1

getURL

public URL getURL()
Return the URL where the configuration is stored.

Returns: the URL of the configuration

isAutoSave

public boolean isAutoSave()
Tells if properties are automatically saved to the disk.

Returns: true if auto-saving is enabled, false otherwise

Since: 1.1

load

public void load()
Load the configuration from the underlying URL. If the URL is not specified, it attempts to locate the specified file name.

Throws: ConfigurationException if an error occurs during the load operation

load

public void load(String fileName)
Locate the specified file and load the configuration.

Parameters: fileName the name of the file loaded

Throws: ConfigurationException if an error occurs during the load operation

load

public void load(File file)
Load the configuration from the specified file.

Parameters: file the loaded file

Throws: ConfigurationException if an error occurs during the load operation

load

public void load(URL url)
Load the configuration from the specified URL.

Parameters: url the URL of the file loaded

Throws: ConfigurationException if an error occurs during the load operation

load

public void load(InputStream in)
Load the configuration from the specified stream, using the encoding returned by getEncoding.

Parameters: in the input stream

Throws: ConfigurationException if an error occurs during the load operation

load

public void load(InputStream in, String encoding)
Load the configuration from the specified stream, using the specified encoding. If the encoding is null the default encoding is used.

Parameters: in the input stream encoding the encoding used. null to use the default encoding

Throws: ConfigurationException if an error occurs during the load operation

load

public void load(Reader in)
Load the configuration from the specified reader.

Parameters: in the reader

Throws: ConfigurationException if an error occurs during the load operation

reload

public void reload()
Reload the configuration.

Since: 1.1

save

public void save()
Save the configuration.

Throws: ConfigurationException if an error occurs during the save operation

save

public void save(String fileName)
Save the configuration to the specified file.

Parameters: fileName the name of the file to be saved

Throws: ConfigurationException if an error occurs during the save operation

save

public void save(File file)
Save the configuration to the specified file.

Parameters: file specifies the file to be saved

Throws: ConfigurationException if an error occurs during the save operation

save

public void save(URL url)
Save the configuration to the specified URL if it's a file URL.

Parameters: url the URL

Throws: ConfigurationException if an error occurs during the save operation

save

public void save(OutputStream out)
Save the configuration to the specified stream, using the encoding returned by getEncoding.

Parameters: out the output stream

Throws: ConfigurationException if an error occurs during the save operation

save

public void save(OutputStream out, String encoding)
Save the configuration to the specified stream, using the specified encoding. If the encoding is null the default encoding is used.

Parameters: out the output stream encoding the encoding to be used

Throws: ConfigurationException if an error occurs during the save operation

save

public void save(Writer out)
Save the configuration to the specified writer.

Parameters: out the writer

Throws: ConfigurationException if an error occurs during the save operation

setAutoSave

public void setAutoSave(boolean autoSave)
Enable or disable the automatical saving of modified properties to the disk.

Parameters: autoSave true to enable, false to disable

Since: 1.1

setBasePath

public void setBasePath(String basePath)
Sets the base path. The methods setBasePath() and setFileName() can be used together to specify the location of the configuration file to be loaded. If relative file names are to be resolved (e.g. for the include files supported by PropertiesConfiguration), this base path will be used.

Parameters: basePath the base path.

setEncoding

public void setEncoding(String encoding)
Set the encoding used to store the configuration file. Set the encoding to null to use the default encoding.

Parameters: encoding the encoding to use

Since: 1.1

setFile

public void setFile(File file)
Set the file where the configuration is stored.

Parameters: file the file

setFileName

public void setFileName(String fileName)
Set the name of the file.

Parameters: fileName the name of the file

setReloadingStrategy

public void setReloadingStrategy(ReloadingStrategy strategy)
Set the reloading strategy.

Parameters: strategy the reloading strategy to use

Since: 1.1

setURL

public void setURL(URL url)
The URL where the configuration is stored.

Parameters: url the URL