Interface FileConfiguration
- All Superinterfaces:
Configuration
- All Known Implementing Classes:
AbstractFileConfiguration, AbstractHierarchicalFileConfiguration, AbstractHierarchicalFileConfiguration.FileConfigurationDelegate, DefaultConfigurationBuilder, HierarchicalINIConfiguration, HierarchicalXMLConfiguration, INIConfiguration, MultiFileHierarchicalConfiguration, PatternSubtreeConfigurationWrapper, PropertiesConfiguration, PropertyListConfiguration, XMLConfiguration, XMLPropertiesConfiguration, XMLPropertyListConfiguration
A persistent configuration loaded and saved to a file.
- Since:
- 1.0-rc2
- Version:
- $Id: FileConfiguration.java 1209883 2011-12-03 10:56:57Z oheger $
- Author:
- Emmanuel Bourg
-
Method Summary
Modifier and TypeMethodDescriptionReturns the base path.Return the encoding used to store the configuration file.getFile()Return the file where the configuration is stored.Return the name of the file.Return the reloading strategy.getURL()Return the URL where the configuration is stored.booleanTells if properties are automatically saved to the disk.voidload()Load the configuration from the underlying URL.voidLoad the configuration from the specified file.voidload(InputStream in) Load the configuration from the specified stream, using the encoding returned bygetEncoding().voidload(InputStream in, String encoding) Load the configuration from the specified stream, using the specified encoding.voidLoad the configuration from the specified reader.voidLocate the specified file and load the configuration.voidLoad the configuration from the specified URL.voidreload()Reload the configuration.voidsave()Save the configuration.voidSave the configuration to the specified file.voidsave(OutputStream out) Save the configuration to the specified stream, using the encoding returned bygetEncoding().voidsave(OutputStream out, String encoding) Save the configuration to the specified stream, using the specified encoding.voidSave the configuration to the specified writer.voidSave the configuration to the specified file.voidSave the configuration to the specified URL.voidsetAutoSave(boolean autoSave) Enable or disable the automatically 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.voidSet the file where the configuration is stored.voidsetFileName(String fileName) Set the name of the file.voidsetReloadingStrategy(ReloadingStrategy strategy) Set the reloading strategy.voidThe URL where the configuration is stored.Methods inherited from interface Configuration
addProperty, clear, clearProperty, containsKey, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, isEmpty, setProperty, subset
-
Method Details
-
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
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
Load the configuration from the specified file.- Parameters:
file- the loaded file- Throws:
ConfigurationException- if an error occurs during the load operation
-
load
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
Load the configuration from the specified stream, using the encoding returned bygetEncoding().- Parameters:
in- the input stream- Throws:
ConfigurationException- if an error occurs during the load operation
-
load
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 streamencoding- the encoding used.nullto use the default encoding- Throws:
ConfigurationException- if an error occurs during the load operation
-
load
Load the configuration from the specified reader.- Parameters:
in- the reader- Throws:
ConfigurationException- if an error occurs during the load operation
-
save
Save the configuration.- Throws:
ConfigurationException- if an error occurs during the save operation
-
save
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
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
Save the configuration to the specified URL.- Parameters:
url- the URL- Throws:
ConfigurationException- if an error occurs during the save operation
-
save
Save the configuration to the specified stream, using the encoding returned bygetEncoding().- Parameters:
out- the output stream- Throws:
ConfigurationException- if an error occurs during the save operation
-
save
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 streamencoding- the encoding to be used- Throws:
ConfigurationException- if an error occurs during the save operation
-
save
Save the configuration to the specified writer.- Parameters:
out- the writer- Throws:
ConfigurationException- if an error occurs during the save operation
-
getFileName
-
setFileName
Set the name of the file.- Parameters:
fileName- the name of the file
-
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 likesetFile()orsetURL()were used, the base path typically points to the parent directory of the configuration file (e.g. for the URLfile:/temp/test.propertiesthe base path will befile:/temp/). If the base path was explicitly set usingsetBasePath(), this method will return the exact value specified here without further modifications.- Returns:
- the base path
- See Also:
-
setBasePath
Sets the base path. The methodssetBasePath()andsetFileName()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 byPropertiesConfiguration), this base path will be used.- Parameters:
basePath- the base path.
-
getFile
-
setFile
-
getURL
-
setURL
-
setAutoSave
Enable or disable the automatically saving of modified properties to the disk.- Parameters:
autoSave-trueto enable,falseto disable- Since:
- 1.1
-
isAutoSave
boolean isAutoSave()Tells if properties are automatically saved to the disk.- Returns:
trueif auto-saving is enabled,falseotherwise- Since:
- 1.1
-
getReloadingStrategy
Return the reloading strategy.- Returns:
- the reloading strategy currently used
- Since:
- 1.1
-
setReloadingStrategy
Set the reloading strategy.- Parameters:
strategy- the reloading strategy to use- Since:
- 1.1
-
reload
-
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
-
setEncoding
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
-