public abstract class AbstractHierarchicalFileConfiguration extends HierarchicalConfiguration implements FileConfiguration, ConfigurationListener, ConfigurationErrorListener, FileSystemBased, Reloadable
Base class for implementing file based hierarchical configurations.
This class serves an analogous purpose as the
AbstractFileConfiguration class for non hierarchical
configurations. It behaves in exactly the same way, so please refer to the
documentation of AbstractFileConfiguration for further details.
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractHierarchicalFileConfiguration.FileConfigurationDelegate
A special implementation of the
FileConfiguration interface that is
used internally to implement the FileConfiguration methods
for hierarchical configurations. |
HierarchicalConfiguration.BuilderVisitor, HierarchicalConfiguration.Node, HierarchicalConfiguration.NodeVisitorEVENT_ADD_NODES, EVENT_CLEAR_TREE, EVENT_SUBNODE_CHANGEDEND_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN| Modifier | Constructor and Description |
|---|---|
protected |
AbstractHierarchicalFileConfiguration()
Creates a new instance of
AbstractHierarchicalFileConfiguration. |
|
AbstractHierarchicalFileConfiguration(File file)
Creates and loads the configuration from the specified file.
|
protected |
AbstractHierarchicalFileConfiguration(HierarchicalConfiguration c)
Creates a new instance of
AbstractHierarchicalFileConfiguration and copies the
content of the specified configuration into this object. |
|
AbstractHierarchicalFileConfiguration(String fileName)
Creates and loads the configuration from the specified file.
|
|
AbstractHierarchicalFileConfiguration(URL url)
Creates and loads the configuration from the specified URL.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNodes(String key,
Collection<? extends ConfigurationNode> nodes)
Directly adds sub nodes to this configuration.
|
protected void |
addPropertyDirect(String key,
Object obj)
Adds the property with the specified key.
|
void |
clearProperty(String key)
Removes the property with the given key.
|
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.
|
void |
configurationError(ConfigurationErrorEvent event)
Notifies this listener that in an observed configuration an error
occurred.
|
boolean |
containsKey(String key)
Checks if the specified key is contained in this configuration.
|
protected AbstractHierarchicalFileConfiguration.FileConfigurationDelegate |
createDelegate()
Creates the file configuration delegate, i.e.
|
protected List<ConfigurationNode> |
fetchNodeList(String key)
Fetches a list of nodes, which are selected by the specified key.
|
String |
getBasePath()
Returns 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.
|
FileSystem |
getFileSystem()
Retrieve the FileSystem being used.
|
Iterator<String> |
getKeys()
Returns an iterator with all keys defined in this configuration.
|
Iterator<String> |
getKeys(String prefix)
Returns an iterator with all keys defined in this configuration that
start with the given prefix.
|
Object |
getProperty(String key)
Fetches the specified property.
|
ReloadingStrategy |
getReloadingStrategy()
Return the reloading strategy.
|
Object |
getReloadLock()
Returns the object to synchronize on a reload.
|
URL |
getURL()
Return the URL where the configuration is stored.
|
boolean |
isAutoSave()
Tells if properties are automatically saved to the disk.
|
boolean |
isEmpty()
Checks if this 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
FileConfiguration.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 |
refresh()
Reloads the associated configuration file.
|
void |
reload()
Reload the configuration.
|
void |
resetFileSystem()
Reset the FileSystem to the default;
|
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
FileConfiguration.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 |
setAutoSave(boolean autoSave)
Enable or disable the automatically saving of modified properties to the disk.
|
void |
setBasePath(String basePath)
Sets 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 |
setFileSystem(FileSystem fileSystem)
Set the FileSystem to be used for this Configuration.
|
void |
setProperty(String key,
Object value)
Sets the value of the specified property.
|
void |
setReloadingStrategy(ReloadingStrategy strategy)
Set the reloading strategy.
|
void |
setURL(URL url)
The URL where the configuration is stored.
|
protected void |
subnodeConfigurationChanged(ConfigurationEvent event)
Reacts on changes of an associated subnode configuration.
|
clear, clearNode, clearNode, clearReferences, clone, configurationAt, configurationAt, configurationsAt, createAddPath, createNode, createSubnodeConfiguration, createSubnodeConfiguration, fetchAddNode, findLastPathNode, findPropertyNodes, getDefaultExpressionEngine, getExpressionEngine, getMaxIndex, getRoot, getRootNode, interpolatedConfiguration, nodeDefined, nodeDefined, removeNode, removeNode, setDefaultExpressionEngine, setExpressionEngine, setRoot, setRootNode, subsetaddErrorLogListener, addProperty, append, clearPropertyDirect, copy, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getList, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, getSubstitutor, interpolate, interpolate, interpolateHelper, isDelimiterParsingDisabled, isScalarValue, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setLogger, setThrowExceptionOnMissingaddConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEventsequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitload, saveaddProperty, clear, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getList, getList, getLong, getLong, getLong, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, subsetprotected AbstractHierarchicalFileConfiguration()
AbstractHierarchicalFileConfiguration.protected AbstractHierarchicalFileConfiguration(HierarchicalConfiguration c)
AbstractHierarchicalFileConfiguration and copies the
content of the specified configuration into this object.c - the configuration to copypublic AbstractHierarchicalFileConfiguration(String fileName) throws ConfigurationException
fileName - The name of the plist file to load.ConfigurationException - Error while loading the filepublic AbstractHierarchicalFileConfiguration(File file) throws ConfigurationException
file - The configuration file to load.ConfigurationException - Error while loading the filepublic AbstractHierarchicalFileConfiguration(URL url) throws ConfigurationException
url - The location of the configuration file to load.ConfigurationException - Error while loading the fileprotected 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)
HierarchicalConfigurationclearProperty 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 removedpublic void setProperty(String key, Object value)
HierarchicalConfigurationsetProperty in interface ConfigurationsetProperty in class HierarchicalConfigurationkey - the key of the property to setvalue - the new value of this propertypublic void load()
throws ConfigurationException
FileConfigurationload in interface FileConfigurationConfigurationException - if an error occurs during the load operationpublic void load(String fileName) throws ConfigurationException
FileConfigurationload in interface FileConfigurationfileName - the name of the file loadedConfigurationException - if an error occurs during the load operationpublic void load(File file) throws ConfigurationException
FileConfigurationload in interface FileConfigurationfile - the loaded fileConfigurationException - if an error occurs during the load operationpublic void load(URL url) throws ConfigurationException
FileConfigurationload in interface FileConfigurationurl - the URL of the file loadedConfigurationException - if an error occurs during the load operationpublic void load(InputStream in) throws ConfigurationException
FileConfigurationFileConfiguration.getEncoding().load in interface FileConfigurationin - the input streamConfigurationException - if an error occurs during the load operationpublic void load(InputStream in, String encoding) throws ConfigurationException
FileConfigurationload in interface FileConfigurationin - the input streamencoding - the encoding used. null to use the default encodingConfigurationException - if an error occurs during the load operationpublic void save()
throws ConfigurationException
FileConfigurationsave in interface FileConfigurationConfigurationException - if an error occurs during the save operationpublic void save(String fileName) throws ConfigurationException
FileConfigurationsave in interface FileConfigurationfileName - the name of the file to be savedConfigurationException - if an error occurs during the save operationpublic void save(File file) throws ConfigurationException
FileConfigurationsave in interface FileConfigurationfile - specifies the file to be savedConfigurationException - if an error occurs during the save operationpublic void save(URL url) throws ConfigurationException
FileConfigurationsave in interface FileConfigurationurl - the URLConfigurationException - if an error occurs during the save operationpublic void save(OutputStream out) throws ConfigurationException
FileConfigurationFileConfiguration.getEncoding().save in interface FileConfigurationout - the output streamConfigurationException - if an error occurs during the save operationpublic void save(OutputStream out, String encoding) throws ConfigurationException
FileConfigurationsave in interface FileConfigurationout - the output streamencoding - the encoding to be usedConfigurationException - if an error occurs during the save operationpublic String getFileName()
FileConfigurationgetFileName in interface FileConfigurationpublic void setFileName(String fileName)
FileConfigurationsetFileName in interface FileConfigurationfileName - the name of the filepublic String getBasePath()
FileConfigurationsetFile() 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 explicitly set
using setBasePath(), this method will return the exact
value specified here without further modifications.getBasePath in interface FileConfigurationAbstractFileConfiguration.setBasePath(String)public void setBasePath(String basePath)
FileConfigurationsetBasePath() 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.setBasePath in interface FileConfigurationbasePath - the base path.public File getFile()
FileConfigurationgetFile in interface FileConfigurationpublic void setFile(File file)
FileConfigurationsetFile in interface FileConfigurationfile - the filepublic URL getURL()
FileConfigurationgetURL in interface FileConfigurationpublic void setURL(URL url)
FileConfigurationsetURL in interface FileConfigurationurl - the URLpublic void setAutoSave(boolean autoSave)
FileConfigurationsetAutoSave in interface FileConfigurationautoSave - true to enable, false to disablepublic boolean isAutoSave()
FileConfigurationisAutoSave in interface FileConfigurationtrue if auto-saving is enabled, false otherwisepublic ReloadingStrategy getReloadingStrategy()
FileConfigurationgetReloadingStrategy in interface FileConfigurationpublic void setReloadingStrategy(ReloadingStrategy strategy)
FileConfigurationsetReloadingStrategy in interface FileConfigurationstrategy - the reloading strategy to usepublic void reload()
FileConfigurationreload in interface FileConfigurationpublic void refresh()
throws ConfigurationException
reload()
without checking the reloading strategy.ConfigurationException - if an error occurspublic String getEncoding()
FileConfigurationgetEncoding in interface FileConfigurationpublic void setEncoding(String encoding)
FileConfigurationsetEncoding in interface FileConfigurationencoding - the encoding to usepublic Object getReloadLock()
HierarchicalConfigurationgetReloadLock in interface ReloadablegetReloadLock in class HierarchicalConfigurationpublic boolean containsKey(String key)
HierarchicalConfigurationcontainsKey in interface ConfigurationcontainsKey in class HierarchicalConfigurationkey - the key to be chekcedpublic Iterator<String> getKeys()
HierarchicalConfigurationgetKeys in interface ConfigurationgetKeys in class HierarchicalConfigurationpublic Iterator<String> getKeys(String prefix)
HierarchicalConfigurationgetKeys in interface ConfigurationgetKeys in class HierarchicalConfigurationprefix - the prefix of the keys to start withConfiguration.getKeys()public Object getProperty(String key)
HierarchicalConfigurationgetProperty in interface ConfigurationgetProperty in class HierarchicalConfigurationkey - the key to be looked uppublic boolean isEmpty()
HierarchicalConfigurationisEmpty in interface ConfigurationisEmpty in class HierarchicalConfigurationpublic void addNodes(String key, Collection<? extends ConfigurationNode> nodes)
addNodes in class HierarchicalConfigurationkey - the key where the nodes are to be addednodes - a collection with the nodes to be addedprotected List<ConfigurationNode> fetchNodeList(String key)
fetchNodeList in class HierarchicalConfigurationkey - the keyprotected void subnodeConfigurationChanged(ConfigurationEvent event)
subnodeConfigurationChanged in class HierarchicalConfigurationevent - the event describing the changeprotected 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 eventpublic void configurationError(ConfigurationErrorEvent event)
ConfigurationErrorListenerThrowable object, can be obtained from the passed
in event object.configurationError in interface ConfigurationErrorListenerevent - the event object with information about the errorprotected AbstractHierarchicalFileConfiguration.FileConfigurationDelegate getDelegate()
protected void setDelegate(AbstractHierarchicalFileConfiguration.FileConfigurationDelegate delegate)
delegate - the new delegatepublic void setFileSystem(FileSystem fileSystem)
setFileSystem in interface FileSystemBasedfileSystem - The FileSystem to use.public void resetFileSystem()
resetFileSystem in interface FileSystemBasedpublic FileSystem getFileSystem()
getFileSystem in interface FileSystemBasedCopyright © 2001–2013 The Apache Software Foundation. All rights reserved.