Top Description Inners Fields Constructors Methods
org.eclipse.jgit.lib

public Class FileModeCache

extends Object
Class Inheritance
Imports
java.io.File, .IOException, java.nio.file.InvalidPathException, .LinkOption, .Path, java.nio.file.attribute.BasicFileAttributeView, .BasicFileAttributes, java.util.HashMap, .Map, org.eclipse.jgit.annotations.NonNull, org.eclipse.jgit.util.FS, .FileUtils

A hierarchical cache of FileModes per git path.
Since
6.6.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
FileModeCache.CacheItem

An item from a FileModeCache, recording information about a git path (known from context).

Field Summary

Modifier and TypeField and Description
private final Repository
private final FileModeCache.CacheItem

Constructor Summary

AccessConstructor and Description
public
FileModeCache(Repository
Repository this cache is for
repo
)

Creates a new FileModeCache for a Repository.

Method Summary

Modifier and TypeMethod and Description
private FileModeCache.CacheItem

Returns:

the CacheItem for the path
add
(String
to cache the FileMode for
gitPath
,
FileMode
FileMode to cache
finalMode
)

Records the given FileMode for the given git path in the cache.

private void
deleteSymlinkParent(FS fs, String gitPath, File workingTree)

public Repository

Returns:

the Repository this FileModeCache was created for
getRepository
()

Retrieves the Repository.

public FileModeCache.CacheItem

Returns:

the CacheItem
getRoot
()

Obtains the CacheItem for the working tree root.

public FileModeCache.CacheItem

Returns:

A CacheItem describing the directory, which is guaranteed to exist
safeCreateDirectory
(String
of a file to be written
gitPath
,
File
directory in which the file shall be placed, assumed to be the parent of the gitPath
dir
,
boolean
whether to remove a file that already at that name
makeSpace
)

Ensures the given directory dir with the given git path exists.

public void
safeCreateParentDirectory(String
of the file to be written
gitPath
,
File
directory in which the file shall be placed, assumed to be the parent of the gitPath
parentDir
,
boolean
whether to delete a possibly existing file at parentDir
makeSpace
)

Ensure that the given parent directory exists, and cache the information that gitPath refers to a file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

repoback to summary
private final Repository repo
Annotations
@NonNull
rootback to summary
private final FileModeCache.CacheItem root
Annotations
@NonNull

Constructor Detail

FileModeCacheback to summary
public FileModeCache(Repository repo)

Creates a new FileModeCache for a Repository.

Parameters
repo:Repository

Repository this cache is for

Method Detail

addback to summary
private FileModeCache.CacheItem add(String gitPath, FileMode finalMode)

Records the given FileMode for the given git path in the cache. If an entry already exists for the given path, the previously cached file mode is overwritten.

Parameters
gitPath:String

to cache the FileMode for

finalMode:FileMode

FileMode to cache

Returns:FileModeCache.CacheItem

the CacheItem for the path

Annotations
@NonNull
deleteSymlinkParentback to summary
private void deleteSymlinkParent(FS fs, String gitPath, File workingTree) throws IOException
getRepositoryback to summary
public Repository getRepository()

Retrieves the Repository.

Returns:Repository

the Repository this FileModeCache was created for

Annotations
@NonNull
getRootback to summary
public FileModeCache.CacheItem getRoot()

Obtains the CacheItem for the working tree root.

Returns:FileModeCache.CacheItem

the CacheItem

Annotations
@NonNull
safeCreateDirectoryback to summary
public FileModeCache.CacheItem safeCreateDirectory(String gitPath, File dir, boolean makeSpace) throws IOException

Ensures the given directory dir with the given git path exists.

Parameters
gitPath:String

of a file to be written

dir:File

directory in which the file shall be placed, assumed to be the parent of the gitPath

makeSpace:boolean

whether to remove a file that already at that name

Returns:FileModeCache.CacheItem

A CacheItem describing the directory, which is guaranteed to exist

Exceptions
IOException:
if the directory cannot be made to exist at the given location
safeCreateParentDirectoryback to summary
public void safeCreateParentDirectory(String gitPath, File parentDir, boolean makeSpace) throws IOException

Ensure that the given parent directory exists, and cache the information that gitPath refers to a file.

Parameters
gitPath:String

of the file to be written

parentDir:File

directory in which the file shall be placed, assumed to be the parent of the gitPath

makeSpace:boolean

whether to delete a possibly existing file at parentDir

Exceptions
IOException:
if the directory cannot be created, if necessary
org.eclipse.jgit.lib back to summary

public Class FileModeCache.CacheItem

extends Object
Class Inheritance

An item from a FileModeCache, recording information about a git path (known from context).

Field Summary

Modifier and TypeField and Description
private Map<String, FileModeCache.CacheItem>
private FileMode

Constructor Summary

AccessConstructor and Description
public
CacheItem(FileMode
FileMode to cache
mode
)

Creates a new CacheItem.

Method Summary

Modifier and TypeMethod and Description
public FileModeCache.CacheItem

Returns:

the CacheItem, or null if no such child is known
child
(String
name of the child to get
childName
)

Retrieves an immediate child of this CacheItem by name.

public FileMode

Returns:

the FileMode
getMode
()

Retrieves the cached FileMode.

public FileModeCache.CacheItem

Returns:

the new CacheItem created for the child
insert
(String
name of the child to create
childName
,
FileMode
FileMode to cache
childMode
)

Inserts a new cached FileMode as an immediate child of this CacheItem.

public FileModeCache.CacheItem

Returns:

the previously cached CacheItem, if any
remove
(String
name of the child to remove
childName
)

Removes the immediate child with the given name.

pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

childrenback to summary
private Map<String, FileModeCache.CacheItem> children
modeback to summary
private FileMode mode
Annotations
@NonNull

Constructor Detail

CacheItemback to summary
public CacheItem(FileMode mode)

Creates a new CacheItem.

Parameters
mode:FileMode

FileMode to cache

Method Detail

childback to summary
public FileModeCache.CacheItem child(String childName)

Retrieves an immediate child of this CacheItem by name.

Parameters
childName:String

name of the child to get

Returns:FileModeCache.CacheItem

the CacheItem, or null if no such child is known

getModeback to summary
public FileMode getMode()

Retrieves the cached FileMode.

Returns:FileMode

the FileMode

Annotations
@NonNull
insertback to summary
public FileModeCache.CacheItem insert(String childName, FileMode childMode)

Inserts a new cached FileMode as an immediate child of this CacheItem. If there is already a child with the same name, it is overwritten.

Parameters
childName:String

name of the child to create

childMode:FileMode

FileMode to cache

Returns:FileModeCache.CacheItem

the new CacheItem created for the child

removeback to summary
public FileModeCache.CacheItem remove(String childName)

Removes the immediate child with the given name.

Parameters
childName:String

name of the child to remove

Returns:FileModeCache.CacheItem

the previously cached CacheItem, if any

setModeback to summary
pack-priv void setMode(FileMode mode)