Class PropertiesFileConfiguration
java.lang.Object
org.apache.commons.configuration2.event.BaseEventSource
org.apache.commons.configuration2.AbstractConfiguration
org.apache.commons.configuration2.BaseConfiguration
org.apache.commons.configuration2.PropertiesConfiguration
de.aristaflow.adept2.util.configuration.PropertiesFileConfiguration
- All Implemented Interfaces:
Cloneable,Configuration,EventSource,FileBasedConfiguration,ImmutableConfiguration,FileBased,FileLocatorAware,SynchronizerSupport
This class extends a
The default for the list delimiter is
PropertiesConfiguration by the means for an underlying file as
well as optionally automatically saving the configuration in case of changes. When automatically
saving, each change will immediately lead to a save try. Saving will be suspended while the
configuration file is being loaded or already saved.The default for the list delimiter is
,.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.configuration2.PropertiesConfiguration
PropertiesConfiguration.DefaultIOFactory, PropertiesConfiguration.IOFactory, PropertiesConfiguration.JupIOFactory, PropertiesConfiguration.JupPropertiesReader, PropertiesConfiguration.JupPropertiesWriter, PropertiesConfiguration.PropertiesReader, PropertiesConfiguration.PropertiesWriter -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FileHandlerThe handler for the configuration file.protected final URLThe URL of a stream; the file handler does not have one in case of an input stream.Fields inherited from class org.apache.commons.configuration2.PropertiesConfiguration
DEFAULT_ENCODING, DEFAULT_INCLUDE_LISTENER, NOOP_INCLUDE_LISTENER -
Constructor Summary
ConstructorsConstructorDescriptionPropertiesFileConfiguration(File file, Logger autosaveLogger) Creates a new properties configuration based on the designated file and loads the configuration if the file exists.PropertiesFileConfiguration(String file, Logger autosaveLogger) Creates a new properties configuration based on the designated file and loads the configuration if the file exists.PropertiesFileConfiguration(URL url, InputStream stream) Creates a new properties configuration based on the designated URL and loads the configuration from the designated stream.PropertiesFileConfiguration(URL file, Logger autosaveLogger) Creates a new properties configuration based on the designated file and loads the configuration. -
Method Summary
Methods inherited from class org.apache.commons.configuration2.PropertiesConfiguration
clone, getFooter, getHeader, getInclude, getIncludeListener, getIncludeOptional, getIOFactory, getLayout, getLocator, initFileLocator, isIncludesAllowed, read, setFooter, setHeader, setInclude, setIncludeListener, setIncludeOptional, setIncludesAllowed, setIOFactory, setLayout, unescapeJava, unescapeJava, writeMethods inherited from class org.apache.commons.configuration2.BaseConfiguration
addPropertyDirect, clearInternal, clearPropertyDirect, containsKeyInternal, containsValueInternal, getKeysInternal, getPropertyInternal, isEmptyInternal, sizeInternalMethods inherited from class org.apache.commons.configuration2.AbstractConfiguration
addErrorLogListener, addProperty, addPropertyInternal, append, beginRead, beginWrite, clear, clearProperty, cloneInterpolator, contains, containsKey, containsValue, copy, endRead, endWrite, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getConfigurationDecoder, getConversionHandler, getDouble, getDouble, getDouble, getDuration, getDuration, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getKeys, getKeys, getKeysInternal, getKeysInternal, getList, getList, getList, getList, getListDelimiterHandler, getLogger, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, getSynchronizer, immutableSubset, initLogger, installInterpolator, interpolate, interpolate, interpolatedConfiguration, isEmpty, isScalarValue, isThrowExceptionOnMissing, lock, setConfigurationDecoder, setConversionHandler, setDefaultLookups, setInterpolator, setListDelimiterHandler, setLogger, setParentInterpolator, setPrefixLookups, setProperty, setPropertyInternal, setSynchronizer, setThrowExceptionOnMissing, size, subset, unlockMethods inherited from class org.apache.commons.configuration2.event.BaseEventSource
addEventListener, clearErrorListeners, clearEventListeners, copyEventListeners, createErrorEvent, createEvent, fireError, fireEvent, getEventListenerRegistrations, getEventListeners, isDetailEvents, removeEventListener, setDetailEventsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.configuration2.Configuration
addProperty, clear, clearProperty, getInterpolator, installInterpolator, setInterpolator, setProperty, subsetMethods inherited from interface org.apache.commons.configuration2.ImmutableConfiguration
containsKey, containsValue, entrySet, forEach, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getDouble, getDouble, getDouble, getDuration, getDuration, getEncodedString, getEncodedString, getEnum, getEnum, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getKeys, getKeys, getList, getList, getList, getList, getLong, getLong, getLong, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, immutableSubset, isEmpty, sizeMethods inherited from interface org.apache.commons.configuration2.sync.SynchronizerSupport
getSynchronizer, lock, setSynchronizer, unlock
-
Field Details
-
fileHandler
The handler for the configuration file. -
streamUrl
The URL of a stream; the file handler does not have one in case of an input stream.
-
-
Constructor Details
-
PropertiesFileConfiguration
public PropertiesFileConfiguration(String file, Logger autosaveLogger) throws ConfigurationException Creates a new properties configuration based on the designated file and loads the configuration if the file exists. If a logger is provided, changes of the configuration will be automatically saved to the underlying file, the file will be created if required. Problems when saving will be logged appropriately.- Parameters:
file- The file to base the properties configuration on.autosaveLogger- Whether to automatically save changes to the underlying file. If so, problems will be logged to this logger. Usenullto not automatically save changes.- Throws:
ConfigurationException- If loading the configuration from the designated file fails, aConfigurationExceptionwill be thrown.
-
PropertiesFileConfiguration
Creates a new properties configuration based on the designated file and loads the configuration if the file exists. If a logger is provided, changes of the configuration will be automatically saved to the underlying file, the file will be created if required. Problems when saving will be logged appropriately.- Parameters:
file- The file to base the properties configuration on.autosaveLogger- Whether to automatically save changes to the underlying file. If so, problems will be logged to this logger. Usenullto not automatically save changes.- Throws:
ConfigurationException- If loading the configuration from the designated file fails, the file cannot be read or the configuration should be automatically saved but the file cannot be written, aConfigurationExceptionwill be thrown.
-
PropertiesFileConfiguration
Creates a new properties configuration based on the designated file and loads the configuration. The file has to exist. If a logger is provided, changes of the configuration will be automatically saved to the underlying file. Problems when saving will be logged appropriately.- Parameters:
file- The file to base the properties configuration on.autosaveLogger- Whether to automatically save changes to the underlying file. If so, problems will be logged to this logger. Usenullto not automatically save changes.- Throws:
ConfigurationException- If loading the configuration from the designated file fails, aConfigurationExceptionwill be thrown. If the file cannot be read or the configuration should be automatically saved but the file cannot be written, theConfigurationExceptionwill wrap aFileNotFoundException.
-
PropertiesFileConfiguration
Creates a new properties configuration based on the designated URL and loads the configuration from the designated stream. Autosaving is not possible since the stream is not an output stream.- Parameters:
url- The URL specifying the properties file. This is merely for information purpose. If you do not have an URL usePropertiesConfigurationdirectly.stream- The input stream to read the configuration from.- Throws:
ConfigurationException- If loading the configuration from the designated file fails, aConfigurationExceptionwill be thrown.
-
-
Method Details
-
getFileUrl
Gets the URL of the underlying properties file.- Returns:
- The URL of the underlying properties file.
-
load
Loads the configuration from the underlying properties file.- Throws:
ConfigurationException- If there are problems loading the configuration from the underlying properties file, aConfigurationExceptionwill be thrown.
-
save
Saves the configuration to the underlying properties file.- Throws:
ConfigurationException- If there are problems saving the configuration to the underlying properties file, aConfigurationExceptionwill be thrown.
-