|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A persistent configuration loaded and saved to a file.
Method Summary | |
String |
getBasePath()
Returns the base path. |
String |
getEncoding()
Return the encoding used to store the configuration file. |
File |
getFile()
Return the file where the configuration is stored. |
String |
getFileName()
Return the name of the file. |
ReloadingStrategy |
getReloadingStrategy()
Return the reloading strategy. |
URL |
getURL()
Return the URL where the configuration is stored. |
boolean |
isAutoSave()
Tells if properties are automatically saved to the disk. |
void |
load()
Load the configuration from the underlying URL. |
void |
load(File file)
Load the configuration from the specified file. |
void |
load(InputStream in)
Load the configuration from the specified stream, using the encoding returned by getEncoding() . |
void |
load(InputStream in,
String encoding)
Load the configuration from the specified stream, using the specified encoding. |
void |
load(Reader in)
Load the configuration from the specified reader. |
void |
load(String fileName)
Locate the specified file and load the configuration. |
void |
load(URL url)
Load the configuration from the specified URL. |
void |
reload()
Reload the configuration. |
void |
save()
Save the configuration. |
void |
save(File file)
Save the configuration to the specified file. |
void |
save(OutputStream out)
Save the configuration to the specified stream, using the encoding returned by getEncoding() . |
void |
save(OutputStream out,
String encoding)
Save the configuration to the specified stream, using the specified encoding. |
void |
save(String fileName)
Save the configuration to the specified file. |
void |
save(URL url)
Save the configuration to the specified URL. |
void |
save(Writer out)
Save the configuration to the specified writer. |
void |
setAutoSave(boolean autoSave)
Enable or disable the automatical saving of modified properties to the disk. |
void |
setBasePath(String basePath)
Sets the base path. |
void |
setEncoding(String encoding)
Set the encoding used to store the configuration file. |
void |
setFile(File file)
Set the file where the configuration is stored. |
void |
setFileName(String fileName)
Set the name of the file. |
void |
setReloadingStrategy(ReloadingStrategy strategy)
Set the reloading strategy. |
void |
setURL(URL url)
The URL where the configuration is stored. |
Methods inherited from interface org.apache.commons.configuration.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 Detail |
public void load() throws ConfigurationException
ConfigurationException
- if an error occurs during the load operationpublic void load(String fileName) throws ConfigurationException
fileName
- the name of the file loaded
ConfigurationException
- if an error occurs during the load operationpublic void load(File file) throws ConfigurationException
file
- the loaded file
ConfigurationException
- if an error occurs during the load operationpublic void load(URL url) throws ConfigurationException
url
- the URL of the file loaded
ConfigurationException
- if an error occurs during the load operationpublic void load(InputStream in) throws ConfigurationException
getEncoding()
.
in
- the input stream
ConfigurationException
- if an error occurs during the load operationpublic void load(InputStream in, String encoding) throws ConfigurationException
in
- the input streamencoding
- the encoding used. null
to use the default encoding
ConfigurationException
- if an error occurs during the load operationpublic void load(Reader in) throws ConfigurationException
in
- the reader
ConfigurationException
- if an error occurs during the load operationpublic void save() throws ConfigurationException
ConfigurationException
- if an error occurs during the save operationpublic void save(String fileName) throws ConfigurationException
fileName
- the name of the file to be saved
ConfigurationException
- if an error occurs during the save operationpublic void save(File file) throws ConfigurationException
file
- specifies the file to be saved
ConfigurationException
- if an error occurs during the save operationpublic void save(URL url) throws ConfigurationException
url
- the URL
ConfigurationException
- if an error occurs during the save operationpublic void save(OutputStream out) throws ConfigurationException
getEncoding()
.
out
- the output stream
ConfigurationException
- if an error occurs during the save operationpublic void save(OutputStream out, String encoding) throws ConfigurationException
out
- the output streamencoding
- the encoding to be used
ConfigurationException
- if an error occurs during the save operationpublic void save(Writer out) throws ConfigurationException
out
- the writer
ConfigurationException
- if an error occurs during the save operationpublic String getFileName()
public void setFileName(String fileName)
fileName
- the name of the filepublic String getBasePath()
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.
AbstractFileConfiguration.setBasePath(String)
public void setBasePath(String basePath)
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.
basePath
- the base path.public File getFile()
public void setFile(File file)
file
- the filepublic URL getURL()
public void setURL(URL url)
url
- the URLpublic void setAutoSave(boolean autoSave)
autoSave
- true
to enable, false
to disablepublic boolean isAutoSave()
true
if auto-saving is enabled, false
otherwisepublic ReloadingStrategy getReloadingStrategy()
public void setReloadingStrategy(ReloadingStrategy strategy)
strategy
- the reloading strategy to usepublic void reload()
public String getEncoding()
public void setEncoding(String encoding)
encoding
- the encoding to use
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |