java.lang.Object
org.eclipse.jgit.diff.ContentSource
Supplies the content of a file for
DiffFormatter
.
A content source is not thread-safe. Sources may contain state, including information about the last ObjectLoader they returned. Callers must be careful to ensure there is no more than one ObjectLoader pending on any source, at any time.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A pair of sources to access the old and new sides of a DiffEntry. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the used resources like ObjectReader, TreeWalk etc.static ContentSource
create
(ObjectReader reader) Construct a content source for an ObjectReader.static ContentSource
create
(WorkingTreeIterator iterator) Construct a content source for a working directory.boolean
Checks if the source is from "working tree", so it can be accessed as a file directly.abstract ObjectLoader
Open the object.abstract long
Determine the size of the object.
-
Constructor Details
-
ContentSource
public ContentSource()
-
-
Method Details
-
create
Construct a content source for an ObjectReader.- Parameters:
reader
- the reader to obtain blobs from.- Returns:
- a source wrapping the reader.
-
create
Construct a content source for a working directory. If the iterator is aFileTreeIterator
an optimized version is used that doesn't require seeking through a TreeWalk.- Parameters:
iterator
- the iterator to obtain source files through.- Returns:
- a content source wrapping the iterator.
-
size
Determine the size of the object.- Parameters:
path
- the path of the file, relative to the root of the repository.id
- blob id of the file, if known.- Returns:
- the size in bytes.
- Throws:
IOException
- the file cannot be accessed.
-
open
Open the object.- Parameters:
path
- the path of the file, relative to the root of the repository.id
- blob id of the file, if known.- Returns:
- a loader that can supply the content of the file. The loader must be used before another loader can be obtained from this same source.
- Throws:
IOException
- the file cannot be accessed.
-
close
public void close()Closes the used resources like ObjectReader, TreeWalk etc. Default implementation does nothing.- Since:
- 6.2
-
isWorkingTreeSource
public boolean isWorkingTreeSource()Checks if the source is from "working tree", so it can be accessed as a file directly.- Returns:
- true if working tree source and false otherwise (loader must be used)
- Since:
- 6.2
-