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() |
boolean |
isOutdated() |
void |
load()
Load the configuration as a Git text style configuration file.
|
protected boolean |
notifyUponTransientChanges()
Determine whether to issue change events for transient changes.
|
void |
save()
Save the configuration as a Git text style configuration file.
|
String |
toString() |
addChangeListener, fireConfigChangedEvent, fromText, get, getBoolean, getBoolean, getEnum, getEnum, getInt, getInt, getLong, getLong, getNames, getNames, getNames, getNames, getSections, getString, getStringList, getSubsections, setBoolean, setEnum, setInt, setLong, setString, setStringList, 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()
Config
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 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 file could not be read (but does exist).ConfigInvalidException
- the file is not a properly formatted configuration file.public void save() throws IOException
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 file could not be written.public void clear()
Config
clear
in class StoredConfig
public boolean isOutdated()
Copyright © 2016 Eclipse JGit Project. All rights reserved.