Package io.confound.config.file
Class AbstractFileConfigurationManager
java.lang.Object
io.confound.config.AbstractConfigurationManager
io.confound.config.file.AbstractFileConfigurationManager
- All Implemented Interfaces:
io.confound.config.ConfigurationManager
- Direct Known Subclasses:
FileSystemConfigurationManager
,ResourcesConfigurationManager
public abstract class AbstractFileConfigurationManager
extends io.confound.config.AbstractConfigurationManager
A configuration manager that knows how to load a configuration by parsing some document from an input stream.
- Author:
- Garret Wilson
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractFileConfigurationManager
(Iterable<ConfigurationFileFormat> fileFormats, boolean required) Configuration file formats constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic io.confound.config.ConfigurationException
Utility factory method for creating a configuration exception indicating that no supported configuration file could be found.protected static Iterable<ConfigurationFileFormat>
Determines the default configuration file formats.Determines the file format to use for the given filename extension.getFileFormatForFilename
(CharSequence filename) Determines the file format to use for the given filename based on the registered formats and the filename extension(s).Methods inherited from class io.confound.config.AbstractConfigurationManager
isRequired
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.confound.config.ConfigurationManager
invalidate, isStale, loadConfiguration, saveConfiguration
-
Constructor Details
-
AbstractFileConfigurationManager
public AbstractFileConfigurationManager(@Nonnull Iterable<ConfigurationFileFormat> fileFormats, boolean required) Configuration file formats constructor. The provided file formats will be registered with this configuration manager.The value returned by each
ConfigurationFileFormat.getFilenameExtensions()
will be used as format identifiers. If multiple file file formats indicate the same filename extension suffix, the last file format will replace the others for that format. Otherwise the formats will be attempted in the order given.- Parameters:
fileFormats
- The specific file formats to support.required
- Whether the manager requires a configuration to be determined when loading.
-
-
Method Details
-
defaultFileFormats
Determines the default configuration file formats. This method returns those formats that have been configured as service providers for theConfigurationFileFormat
class using theServiceLoader
mechanism.- Returns:
- The default configured configuration file formats.
-
getFileFormatsByExtension
- Returns:
- The available file extensions, in no particular order, paired with the supporting file format.
-
getFileFormatForExtension
Determines the file format to use for the given filename extension.- Parameters:
id
- The filename extension suffix.- Returns:
- The configured file format for the extension, if any.
-
getFileFormatForFilename
Determines the file format to use for the given filename based on the registered formats and the filename extension(s). If the file has multiple extensions, the registered file format for the longest extension will be used.- Parameters:
filename
- The filename for which the file format should be determined.- Returns:
- The configured file format for the filename, if any.
-
createConfigurationNotFoundException
public static io.confound.config.ConfigurationException createConfigurationNotFoundException()Utility factory method for creating a configuration exception indicating that no supported configuration file could be found.- Returns:
- A new configuration exception indicating no configuration file found.
-