org.eclipse.jgit.storage.file
Class FileBasedConfig

java.lang.Object
  extended by org.eclipse.jgit.lib.Config
      extended by org.eclipse.jgit.lib.StoredConfig
          extended by org.eclipse.jgit.storage.file.FileBasedConfig

public class FileBasedConfig
extends StoredConfig

The configuration file that is stored in the file of the file system.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jgit.lib.Config
Config.ConfigEnum, Config.SectionParser<T>
 
Constructor Summary
FileBasedConfig(Config base, File cfgLocation, FS fs)
          The constructor
FileBasedConfig(File cfgLocation, FS fs)
          Create a configuration with no default fallback.
 
Method Summary
 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()
           
 
Methods inherited from class org.eclipse.jgit.lib.Config
addChangeListener, fireConfigChangedEvent, fromText, get, getBoolean, getBoolean, getEnum, getEnum, getInt, getInt, getLong, getLong, getNames, getNames, getSections, getString, getStringList, getSubsections, setBoolean, setEnum, setInt, setLong, setString, setStringList, toText, uncache, unset, unsetSection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileBasedConfig

public FileBasedConfig(File cfgLocation,
                       FS fs)
Create a configuration with no default fallback.

Parameters:
cfgLocation - the location of the configuration file on the file system
fs - the file system abstraction which will be necessary to perform certain file system operations.

FileBasedConfig

public FileBasedConfig(Config base,
                       File cfgLocation,
                       FS fs)
The constructor

Parameters:
base - the base configuration file
cfgLocation - the location of the configuration file on the file system
fs - the file system abstraction which will be necessary to perform certain file system operations.
Method Detail

notifyUponTransientChanges

protected boolean notifyUponTransientChanges()
Description copied from class: Config
Determine whether to issue change events for transient changes.

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.

Overrides:
notifyUponTransientChanges in class Config
Returns:

getFile

public final File getFile()
Returns:
location of the configuration file on disk

load

public void load()
          throws IOException,
                 ConfigInvalidException
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.

Specified by:
load in class StoredConfig
Throws:
IOException - the file could not be read (but does exist).
ConfigInvalidException - the file is not a properly formatted configuration file.

save

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.

Specified by:
save in class StoredConfig
Throws:
IOException - the file could not be written.

clear

public void clear()
Description copied from class: Config
Clear the configuration file

Overrides:
clear in class StoredConfig

toString

public String toString()
Overrides:
toString in class Object

isOutdated

public boolean isOutdated()
Returns:
returns true if the currently loaded configuration file is older than the file on disk


Copyright © 2013. All Rights Reserved.