|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.commons.configuration.event.EventSource
org.apache.commons.configuration.AbstractConfiguration
org.apache.commons.configuration.HierarchicalConfiguration
org.apache.commons.configuration.AbstractHierarchicalFileConfiguration
Base class for implementing file based hierarchical configurations.
This class serves an analogous purpose as the
class for non hierarchical
configurations. It behaves in exactly the same way, so please refer to the
documentation of AbstractFileConfigurationAbstractFileConfiguration for further details.
| Nested Class Summary | |
protected class |
AbstractHierarchicalFileConfiguration.FileConfigurationDelegate
A special implementation of the FileConfiguration interface that is
used internally to implement the FileConfiguration methods
for hierarchical configurations. |
| Nested classes inherited from class org.apache.commons.configuration.HierarchicalConfiguration |
HierarchicalConfiguration.BuilderVisitor, HierarchicalConfiguration.CloneVisitor, HierarchicalConfiguration.DefinedKeysVisitor, HierarchicalConfiguration.DefinedVisitor, HierarchicalConfiguration.Node, HierarchicalConfiguration.NodeVisitor |
| Field Summary |
| Fields inherited from class org.apache.commons.configuration.HierarchicalConfiguration |
EVENT_ADD_NODES, EVENT_CLEAR_TREE |
| Fields inherited from class org.apache.commons.configuration.AbstractConfiguration |
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN |
| Constructor Summary | |
protected |
AbstractHierarchicalFileConfiguration()
|
|
AbstractHierarchicalFileConfiguration(File file)
Creates and loads the configuration from the specified file. |
|
AbstractHierarchicalFileConfiguration(String fileName)
Creates and loads the configuration from the specified file. |
|
AbstractHierarchicalFileConfiguration(URL url)
Creates and loads the configuration from the specified URL. |
| Method Summary | |
protected void |
addPropertyDirect(String key,
Object obj)
Adds the property with the specified key. |
void |
clearProperty(String key)
Remove a property from the configuration. |
void |
clearTree(String key)
Removes all values of the property with the given name and of keys that start with this name. |
void |
configurationChanged(ConfigurationEvent event)
Reacts on configuration change events triggered by the delegate. |
boolean |
containsKey(String key)
Check if the configuration contains the specified key. |
protected AbstractHierarchicalFileConfiguration.FileConfigurationDelegate |
createDelegate()
Creates the file configuration delegate, i.e. the object that implements functionality required by the FileConfiguration interface.
|
String |
getBasePath()
Return the base path. |
protected AbstractHierarchicalFileConfiguration.FileConfigurationDelegate |
getDelegate()
Returns the file configuration delegate. |
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. |
Iterator |
getKeys(String prefix)
Get the list of the keys contained in the configuration that match the specified prefix. |
Object |
getProperty(String key)
Gets a property from the configuration. |
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. |
boolean |
isEmpty()
Check if the configuration is empty. |
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(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 if it's a file URL. |
void |
setAutoSave(boolean autoSave)
Enable or disable the automatical saving of modified properties to the disk. |
void |
setBasePath(String basePath)
Set the base path. |
protected void |
setDelegate(AbstractHierarchicalFileConfiguration.FileConfigurationDelegate delegate)
Allows to set the file configuration delegate. |
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 |
setProperty(String key,
Object value)
Set a property, this will replace any previously set values. |
void |
setReloadingStrategy(ReloadingStrategy strategy)
Set the reloading strategy. |
void |
setURL(URL url)
The URL where the configuration is stored. |
| Methods inherited from class org.apache.commons.configuration.HierarchicalConfiguration |
addNodes, clearNode, clearNode, clone, configurationAt, configurationsAt, createAddPath, createNode, createSubnodeConfiguration, fetchAddNode, fetchNodeList, findLastPathNode, findPropertyNodes, getDefaultExpressionEngine, getExpressionEngine, getKeys, getMaxIndex, getRoot, getRootNode, nodeDefined, nodeDefined, removeNode, removeNode, setDefaultExpressionEngine, setExpressionEngine, setRoot, setRootNode, subset |
| Methods inherited from class org.apache.commons.configuration.AbstractConfiguration |
addProperty, clear, clearPropertyDirect, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getList, getList, getListDelimiter, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, interpolate, interpolate, interpolateHelper, isDelimiterParsingDisabled, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setThrowExceptionOnMissing |
| Methods inherited from class org.apache.commons.configuration.event.EventSource |
addConfigurationListener, clearConfigurationListeners, createEvent, fireEvent, getConfigurationListeners, isDetailEvents, removeConfigurationListener, setDetailEvents |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.commons.configuration.FileConfiguration |
load, save |
| Methods inherited from interface org.apache.commons.configuration.Configuration |
addProperty, clear, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, subset |
| Constructor Detail |
protected AbstractHierarchicalFileConfiguration()
public AbstractHierarchicalFileConfiguration(String fileName)
throws ConfigurationException
fileName - The name of the plist file to load.
ConfigurationException - Error while loading the file
public AbstractHierarchicalFileConfiguration(File file)
throws ConfigurationException
file - The configuration file to load.
ConfigurationException - Error while loading the file
public AbstractHierarchicalFileConfiguration(URL url)
throws ConfigurationException
url - The location of the configuration file to load.
ConfigurationException - Error while loading the file| Method Detail |
protected void addPropertyDirect(String key,
Object obj)
HierarchicalConfigurationExpressionEngine, so the passed in key
must match the requirements of this implementation.
addPropertyDirect in class HierarchicalConfigurationkey - the key of the new propertyobj - the value of the new propertypublic void clearProperty(String key)
Configuration
clearProperty in interface ConfigurationclearProperty in class HierarchicalConfigurationkey - the key of the property to be removedpublic void clearTree(String key)
HierarchicalConfigurationclearTree("foo") would remove both properties.
clearTree in class HierarchicalConfigurationkey - the key of the property to be removed
public void setProperty(String key,
Object value)
Configuration
setProperty in interface ConfigurationsetProperty in class HierarchicalConfigurationkey - the key of the property to setvalue - the new value of this property
public void load()
throws ConfigurationException
FileConfiguration
load in interface FileConfigurationConfigurationException - if an error occurs during the load operation
public void load(String fileName)
throws ConfigurationException
FileConfiguration
load in interface FileConfigurationfileName - the name of the file loaded
ConfigurationException - if an error occurs during the load operation
public void load(File file)
throws ConfigurationException
FileConfiguration
load in interface FileConfigurationfile - the loaded file
ConfigurationException - if an error occurs during the load operation
public void load(URL url)
throws ConfigurationException
FileConfiguration
load in interface FileConfigurationurl - the URL of the file loaded
ConfigurationException - if an error occurs during the load operation
public void load(InputStream in)
throws ConfigurationException
FileConfigurationFileConfiguration.getEncoding().
load in interface FileConfigurationin - the input stream
ConfigurationException - if an error occurs during the load operation
public void load(InputStream in,
String encoding)
throws ConfigurationException
FileConfiguration
load in interface FileConfigurationin - the input streamencoding - the encoding used. null to use the default encoding
ConfigurationException - if an error occurs during the load operation
public void save()
throws ConfigurationException
FileConfiguration
save in interface FileConfigurationConfigurationException - if an error occurs during the save operation
public void save(String fileName)
throws ConfigurationException
FileConfiguration
save in interface FileConfigurationfileName - the name of the file to be saved
ConfigurationException - if an error occurs during the save operation
public void save(File file)
throws ConfigurationException
FileConfiguration
save in interface FileConfigurationfile - specifies the file to be saved
ConfigurationException - if an error occurs during the save operation
public void save(URL url)
throws ConfigurationException
FileConfiguration
save in interface FileConfigurationurl - the URL
ConfigurationException - if an error occurs during the save operation
public void save(OutputStream out)
throws ConfigurationException
FileConfigurationFileConfiguration.getEncoding().
save in interface FileConfigurationout - the output stream
ConfigurationException - if an error occurs during the save operation
public void save(OutputStream out,
String encoding)
throws ConfigurationException
FileConfiguration
save in interface FileConfigurationout - the output streamencoding - the encoding to be used
ConfigurationException - if an error occurs during the save operationpublic String getFileName()
FileConfiguration
getFileName in interface FileConfigurationpublic void setFileName(String fileName)
FileConfiguration
setFileName in interface FileConfigurationfileName - the name of the filepublic String getBasePath()
FileConfiguration
getBasePath in interface FileConfigurationpublic void setBasePath(String basePath)
FileConfiguration
setBasePath in interface FileConfigurationbasePath - the base path.public File getFile()
FileConfiguration
getFile in interface FileConfigurationpublic void setFile(File file)
FileConfiguration
setFile in interface FileConfigurationfile - the filepublic URL getURL()
FileConfiguration
getURL in interface FileConfigurationpublic void setURL(URL url)
FileConfiguration
setURL in interface FileConfigurationurl - the URLpublic void setAutoSave(boolean autoSave)
FileConfiguration
setAutoSave in interface FileConfigurationautoSave - true to enable, false to disablepublic boolean isAutoSave()
FileConfiguration
isAutoSave in interface FileConfigurationtrue if auto-saving is enabled, false otherwisepublic ReloadingStrategy getReloadingStrategy()
FileConfiguration
getReloadingStrategy in interface FileConfigurationpublic void setReloadingStrategy(ReloadingStrategy strategy)
FileConfiguration
setReloadingStrategy in interface FileConfigurationstrategy - the reloading strategy to usepublic void reload()
FileConfiguration
reload in interface FileConfigurationpublic String getEncoding()
FileConfiguration
getEncoding in interface FileConfigurationpublic void setEncoding(String encoding)
FileConfiguration
setEncoding in interface FileConfigurationencoding - the encoding to usepublic boolean containsKey(String key)
Configuration
containsKey in interface ConfigurationcontainsKey in class HierarchicalConfigurationkey - the key to be chekced
public Iterator getKeys(String prefix)
Configuration
getKeys in interface ConfigurationgetKeys in class HierarchicalConfigurationprefix - the prefix of the keys to start with
public Object getProperty(String key)
ConfigurationConfiguration interface the other get methods (that
return specific data types) will internally make use of this method. On
this level variable substitution is not yet performed. The returned
object is an internal representation of the property value for the passed
in key. It is owned by the Configuration object. So a caller
should not modify this object. It cannot be guaranteed that this object
will stay constant over time (i.e. further update operations on the
configuration may change its internal state).
getProperty in interface ConfigurationgetProperty in class HierarchicalConfigurationkey - the key to be looked up
public boolean isEmpty()
Configuration
isEmpty in interface ConfigurationisEmpty in class HierarchicalConfigurationprotected AbstractHierarchicalFileConfiguration.FileConfigurationDelegate createDelegate()
FileConfiguration interface.
This base implementation will return an instance of the
FileConfigurationDelegate class. Derived classes may
override it to create a different delegate object.
public void configurationChanged(ConfigurationEvent event)
configurationChanged in interface ConfigurationListenerevent - the triggered eventprotected AbstractHierarchicalFileConfiguration.FileConfigurationDelegate getDelegate()
protected void setDelegate(AbstractHierarchicalFileConfiguration.FileConfigurationDelegate delegate)
delegate - the new delegate
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||