Top Description Fields Constructors Methods
org.eclipse.jgit.storage.file

public Class FileBasedConfig

extends StoredConfig
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.storage.file.UserConfigFile
Static Imports
java.nio.charset.StandardCharsets.UTF_8

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

Field Summary

Modifier and TypeField and Description
private final File
private AtomicBoolean
private final FS
private volatile ObjectId
private final ReentrantReadWriteLock
private volatile FileSnapshot
private boolean

Constructor Summary

AccessConstructor and Description
public
FileBasedConfig(File
the location of the configuration file on the file system
cfgLocation
,
FS
the file system abstraction which will be necessary to perform certain file system operations.
fs
)

Create a configuration with no default fallback.

public
FileBasedConfig(Config
the base configuration file
base
,
File
the location of the configuration file on the file system
cfgLocation
,
FS
the file system abstraction which will be necessary to perform certain file system operations.
fs
)

The constructor

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides org.eclipse.jgit.lib.StoredConfig.clear.

Clear the configuration file

pack-priv boolean
public final File

Returns:

location of the configuration file on disk
getFile
()

Get location of the configuration file on disk

private static ObjectId
hash(byte[] rawText)

public boolean

Returns:

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

Whether the currently loaded configuration file is outdated

public void
load()

Implements abstract org.eclipse.jgit.lib.StoredConfig.load.

Load the configuration from the persistent store.

private Boolean
protected boolean
notifyUponTransientChanges()

Overrides org.eclipse.jgit.lib.Config.notifyUponTransientChanges.

Determine whether to issue change events for transient changes.

protected byte[]
readIncludedConfig(String
possibly relative path to the included config, as specified in this config
relPath
)

Overrides org.eclipse.jgit.lib.Config.readIncludedConfig.

Read the included config from the specified (possibly) relative path

public void
save()

Implements abstract org.eclipse.jgit.lib.StoredConfig.save.

Save the configuration to the persistent store.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Field Detail

configFileback to summary
private final File configFile
existsback to summary
private AtomicBoolean exists
fsback to summary
private final FS fs
hashback to summary
private volatile ObjectId hash
lockback to summary
private final ReentrantReadWriteLock lock
snapshotback to summary
private volatile FileSnapshot snapshot
utf8Bomback to summary
private boolean utf8Bom

Constructor Detail

FileBasedConfigback to summary
public FileBasedConfig(File cfgLocation, FS fs)

Create a configuration with no default fallback.

Parameters
cfgLocation:File

the location of the configuration file on the file system

fs:FS

the file system abstraction which will be necessary to perform certain file system operations.

FileBasedConfigback to summary
public FileBasedConfig(Config base, File cfgLocation, FS fs)

The constructor

Parameters
base:Config

the base configuration file

cfgLocation:File

the location of the configuration file on the file system

fs:FS

the file system abstraction which will be necessary to perform certain file system operations.

Method Detail

clearback to summary
public void clear()

Overrides org.eclipse.jgit.lib.StoredConfig.clear.

Doc from org.eclipse.jgit.lib.Config.clear.

Clear the configuration file

Annotations
@Override
existsback to summary
pack-priv boolean exists()
getFileback to summary
public final File getFile()

Get location of the configuration file on disk

Returns:File

location of the configuration file on disk

hashback to summary
private static ObjectId hash(byte[] rawText)
isOutdatedback to summary
public boolean isOutdated()

Whether the currently loaded configuration file is outdated

Returns:boolean

returns true if the currently loaded configuration file is older than the file on disk

loadback to summary
public void load() throws IOException, ConfigInvalidException

Implements abstract org.eclipse.jgit.lib.StoredConfig.load.

Doc from org.eclipse.jgit.lib.StoredConfig.load.

Load the configuration from the persistent store.

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.

Annotations
@Override
Exceptions
IOException:
the configuration could not be read (but does exist).
ConfigInvalidException:
the configuration is not properly formatted.
loadback to summary
private Boolean load(File f) throws Exception
notifyUponTransientChangesback to summary
protected boolean notifyUponTransientChanges()

Overrides org.eclipse.jgit.lib.Config.notifyUponTransientChanges.

Doc from org.eclipse.jgit.lib.Config.notifyUponTransientChanges.

Determine whether to issue change events for transient changes.

If true is returned (which is the default behavior), fireConfigChangedEvent() will be called upon each change.

Subclasses that override this to return false are responsible for issuing fireConfigChangedEvent() calls themselves.

Returns:boolean

whether to issue change events for transient changes

Annotations
@Override
readIncludedConfigback to summary
protected byte[] readIncludedConfig(String relPath) throws ConfigInvalidException

Overrides org.eclipse.jgit.lib.Config.readIncludedConfig.

Doc from org.eclipse.jgit.lib.Config.readIncludedConfig.

Read the included config from the specified (possibly) relative path

Parameters
relPath:String

possibly relative path to the included config, as specified in this config

Returns:byte[]

the read bytes, or null if the included config should be ignored

Annotations
@Override
Exceptions
ConfigInvalidException:
if something went wrong while reading the config
Since
4.10
saveback to summary
public void save() throws IOException

Implements abstract org.eclipse.jgit.lib.StoredConfig.save.

Doc from org.eclipse.jgit.lib.StoredConfig.save.

Save the configuration to the persistent store.

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.

Annotations
@Override
Exceptions
IOException:
the configuration could not be written.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@SuppressWarnings:nls
@Override