public class FileBasedConfig extends StoredConfig
Config.ConfigEnum, Config.SectionParser<T>
Constructor and Description |
---|
FileBasedConfig(Config base,
File cfgLocation,
FS fs)
The constructor
|
FileBasedConfig(File cfgLocation,
FS fs)
Create a configuration with no default fallback.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the configuration file
|
File |
getFile()
Get location of the configuration file on disk
|
boolean |
isOutdated()
Whether the currently loaded configuration file is outdated
|
void |
load()
Load the configuration from the persistent store.
|
protected boolean |
notifyUponTransientChanges()
Determine whether to issue change events for transient changes.
|
protected byte[] |
readIncludedConfig(String relPath)
Read the included config from the specified (possibly) relative path
|
void |
save()
Save the configuration to the persistent store.
|
String |
toString() |
addChangeListener, fireConfigChangedEvent, fromText, get, getBoolean, getBoolean, getEnum, getEnum, getInt, getInt, getLong, getLong, getNames, getNames, getNames, getNames, getRefSpecs, getSections, getString, getStringList, getSubsections, getTimeUnit, isMissing, isUtf8, setBoolean, setEnum, setInt, setLong, setString, setStringList, setTypedConfigGetter, toText, uncache, unset, unsetSection
public FileBasedConfig(File cfgLocation, FS fs)
cfgLocation
- the location of the configuration file on the file systemfs
- the file system abstraction which will be necessary to perform
certain file system operations.public FileBasedConfig(Config base, File cfgLocation, FS fs)
base
- the base configuration filecfgLocation
- the location of the configuration file on the file systemfs
- the file system abstraction which will be necessary to perform
certain file system operations.protected boolean notifyUponTransientChanges()
If true
is returned (which is the default behavior),
Config.fireConfigChangedEvent()
will be called upon each change.
Subclasses that override this to return false
are
responsible for issuing Config.fireConfigChangedEvent()
calls
themselves.
notifyUponTransientChanges
in class Config
public final File getFile()
public void load() throws IOException, ConfigInvalidException
If the configuration does not exist, this configuration is cleared, and thus behaves the same as though the backing store exists, but is empty.
Load the configuration as a Git text style configuration file.
If the file does not exist, this configuration is cleared, and thus behaves the same as though the file exists, but is empty.
load
in class StoredConfig
IOException
- the configuration could not be read (but does exist).ConfigInvalidException
- the configuration is not properly formatted.public void save() throws IOException
Save the configuration as a Git text style configuration file.
Warning: Although this method uses the traditional Git file locking approach to protect against concurrent writes of the configuration file, it does not ensure that the file has not been modified since the last read, which means updates performed by other objects accessing the same backing file may be lost.
save
in class StoredConfig
IOException
- the configuration could not be written.public void clear()
clear
in class StoredConfig
public boolean isOutdated()
protected byte[] readIncludedConfig(String relPath) throws ConfigInvalidException
readIncludedConfig
in class Config
relPath
- possibly relative path to the included config, as specified in
this configConfigInvalidException
- if something went wrong while reading the configCopyright © 2019 Eclipse JGit Project. All rights reserved.