Package org.eclipse.jgit.diff
Class ContentSource
- java.lang.Object
-
- org.eclipse.jgit.diff.ContentSource
-
- Direct Known Subclasses:
ContentSource.ObjectReaderSource,ContentSource.WorkingTreeSource
public abstract class ContentSource extends java.lang.ObjectSupplies the content of a file forDiffFormatter.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 Classes Modifier and Type Class Description private static classContentSource.ObjectReaderSourcestatic classContentSource.PairA pair of sources to access the old and new sides of a DiffEntry.private static classContentSource.WorkingTreeSource
-
Constructor Summary
Constructors Constructor Description ContentSource()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ContentSourcecreate(ObjectReader reader)Construct a content source for an ObjectReader.static ContentSourcecreate(WorkingTreeIterator iterator)Construct a content source for a working directory.abstract ObjectLoaderopen(java.lang.String path, ObjectId id)Open the object.abstract longsize(java.lang.String path, ObjectId id)Determine the size of the object.
-
-
-
Method Detail
-
create
public static ContentSource create(ObjectReader reader)
Construct a content source for an ObjectReader.- Parameters:
reader- the reader to obtain blobs from.- Returns:
- a source wrapping the reader.
-
create
public static ContentSource create(WorkingTreeIterator iterator)
Construct a content source for a working directory. If the iterator is aFileTreeIteratoran 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
public abstract long size(java.lang.String path, ObjectId id) throws java.io.IOExceptionDetermine 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:
java.io.IOException- the file cannot be accessed.
-
open
public abstract ObjectLoader open(java.lang.String path, ObjectId id) throws java.io.IOException
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:
java.io.IOException- the file cannot be accessed.
-
-