Top Description Inners Constructors Methods
org.eclipse.jgit.diff

public abstract Class ContentSource

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.diff.ContentSource.ObjectReaderSource, org.eclipse.jgit.diff.ContentSource.WorkingTreeSource
Imports
java.io.BufferedInputStream, .FileNotFoundException, .IOException, .InputStream, org.eclipse.jgit.errors.LargeObjectException, .MissingObjectException, org.eclipse.jgit.lib.Constants, .ObjectId, .ObjectLoader, .ObjectReader, .ObjectStream, org.eclipse.jgit.treewalk.TreeWalk, .WorkingTreeIterator, org.eclipse.jgit.treewalk.filter.PathFilter

Supplies the content of a file for org.eclipse.jgit.diff.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 and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class
ContentSource.Pair

A pair of sources to access the old and new sides of a DiffEntry.

private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Closes the used resources like ObjectReader, TreeWalk etc. Default implementation does nothing.

public static ContentSource

Returns:

a source wrapping the reader.
create
(ObjectReader
the reader to obtain blobs from.
reader
)

Construct a content source for an ObjectReader.

public static ContentSource

Returns:

a content source wrapping the iterator.
create
(WorkingTreeIterator
the iterator to obtain source files through.
iterator
)

Construct a content source for a working directory.

public boolean

Returns:

true if working tree source and false otherwise (loader must be used)
isWorkingTreeSource
()

Checks if the source is from "working tree", so it can be accessed as a file directly.

public abstract ObjectLoader

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.
open
(String
the path of the file, relative to the root of the repository.
path
,
ObjectId
blob id of the file, if known.
id
)

Open the object.

public abstract long

Returns:

the size in bytes.
size
(String
the path of the file, relative to the root of the repository.
path
,
ObjectId
blob id of the file, if known.
id
)

Determine the size of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ContentSourceback to summary
public ContentSource()

Method Detail

closeback to summary
public void close()

Closes the used resources like ObjectReader, TreeWalk etc. Default implementation does nothing.

Since
6.2
createback to summary
public static ContentSource create(ObjectReader reader)

Construct a content source for an ObjectReader.

Parameters
reader:ObjectReader

the reader to obtain blobs from.

Returns:ContentSource

a source wrapping the reader.

createback to summary
public static ContentSource create(WorkingTreeIterator iterator)

Construct a content source for a working directory. If the iterator is a org.eclipse.jgit.treewalk.FileTreeIterator an optimized version is used that doesn't require seeking through a TreeWalk.

Parameters
iterator:WorkingTreeIterator

the iterator to obtain source files through.

Returns:ContentSource

a content source wrapping the iterator.

isWorkingTreeSourceback to summary
public boolean isWorkingTreeSource()

Checks if the source is from "working tree", so it can be accessed as a file directly.

Returns:boolean

true if working tree source and false otherwise (loader must be used)

Since
6.2
openback to summary
public abstract ObjectLoader open(String path, ObjectId id) throws IOException

Open the object.

Parameters
path:String

the path of the file, relative to the root of the repository.

id:ObjectId

blob id of the file, if known.

Returns:ObjectLoader

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.

Exceptions
IOException:
the file cannot be accessed.
sizeback to summary
public abstract long size(String path, ObjectId id) throws IOException

Determine the size of the object.

Parameters
path:String

the path of the file, relative to the root of the repository.

id:ObjectId

blob id of the file, if known.

Returns:long

the size in bytes.

Exceptions
IOException:
the file cannot be accessed.
org.eclipse.jgit.diff back to summary

private Class ContentSource.ObjectReaderSource

extends ContentSource
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ObjectReader

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides org.eclipse.jgit.diff.ContentSource.close.

Closes the used resources like ObjectReader, TreeWalk etc. Default implementation does nothing.

public boolean
isWorkingTreeSource()

Overrides org.eclipse.jgit.diff.ContentSource.isWorkingTreeSource.

Checks if the source is from "working tree", so it can be accessed as a file directly.

public ObjectLoader
open(String
the path of the file, relative to the root of the repository.
path
,
ObjectId
blob id of the file, if known.
id
)

Implements abstract org.eclipse.jgit.diff.ContentSource.open.

Open the object.

public long
size(String
the path of the file, relative to the root of the repository.
path
,
ObjectId
blob id of the file, if known.
id
)

Implements abstract org.eclipse.jgit.diff.ContentSource.size.

Determine the size of the object.

Inherited from org.eclipse.jgit.diff.ContentSource:
createcreate

Field Detail

readerback to summary
private final ObjectReader reader

Constructor Detail

ObjectReaderSourceback to summary
pack-priv ObjectReaderSource(ObjectReader reader)

Method Detail

closeback to summary
public void close()

Overrides org.eclipse.jgit.diff.ContentSource.close.

Doc from org.eclipse.jgit.diff.ContentSource.close.

Closes the used resources like ObjectReader, TreeWalk etc. Default implementation does nothing.

Annotations
@Override
isWorkingTreeSourceback to summary
public boolean isWorkingTreeSource()

Overrides org.eclipse.jgit.diff.ContentSource.isWorkingTreeSource.

Doc from org.eclipse.jgit.diff.ContentSource.isWorkingTreeSource.

Checks if the source is from "working tree", so it can be accessed as a file directly.

Returns:boolean

true if working tree source and false otherwise (loader must be used)

Annotations
@Override
openback to summary
public ObjectLoader open(String path, ObjectId id) throws IOException

Implements abstract org.eclipse.jgit.diff.ContentSource.open.

Doc from org.eclipse.jgit.diff.ContentSource.open.

Open the object.

Parameters
path:String

the path of the file, relative to the root of the repository.

id:ObjectId

blob id of the file, if known.

Returns:ObjectLoader

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.

Annotations
@Override
Exceptions
IOException:
the file cannot be accessed.
sizeback to summary
public long size(String path, ObjectId id) throws IOException

Implements abstract org.eclipse.jgit.diff.ContentSource.size.

Doc from org.eclipse.jgit.diff.ContentSource.size.

Determine the size of the object.

Parameters
path:String

the path of the file, relative to the root of the repository.

id:ObjectId

blob id of the file, if known.

Returns:long

the size in bytes.

Annotations
@Override
Exceptions
IOException:
the file cannot be accessed.
org.eclipse.jgit.diff back to summary

public final Class ContentSource.Pair

extends Object
Class Inheritance

A pair of sources to access the old and new sides of a DiffEntry.

Field Summary

Modifier and TypeField and Description
private final ContentSource
private final ContentSource

Constructor Summary

AccessConstructor and Description
public
Pair(ContentSource
source to read the old side of a DiffEntry.
oldSource
,
ContentSource
source to read the new side of a DiffEntry.
newSource
)

Construct a pair of sources.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Closes used resources.

public boolean

Returns:

is the source a "working tree"
isWorkingTreeSource
(DiffEntry.Side
which side of the entry to read (OLD or NEW).
side
)

Checks if source (side) is a "working tree".

public ObjectLoader

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.
open
(DiffEntry.Side
which side of the entry to read (OLD or NEW).
side
,
DiffEntry
the entry to examine.
ent
)

Open the object.

public long

Returns:

the size in bytes.
size
(DiffEntry.Side
which side of the entry to read (OLD or NEW).
side
,
DiffEntry
the entry to examine.
ent
)

Determine the size of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

newSourceback to summary
private final ContentSource newSource
oldSourceback to summary
private final ContentSource oldSource

Constructor Detail

Pairback to summary
public Pair(ContentSource oldSource, ContentSource newSource)

Construct a pair of sources.

Parameters
oldSource:ContentSource

source to read the old side of a DiffEntry.

newSource:ContentSource

source to read the new side of a DiffEntry.

Method Detail

closeback to summary
public void close()

Closes used resources.

Since
6.2
isWorkingTreeSourceback to summary
public boolean isWorkingTreeSource(DiffEntry.Side side)

Checks if source (side) is a "working tree".

Parameters
side:DiffEntry.Side

which side of the entry to read (OLD or NEW).

Returns:boolean

is the source a "working tree"

Since
6.2
openback to summary
public ObjectLoader open(DiffEntry.Side side, DiffEntry ent) throws IOException

Open the object.

Parameters
side:DiffEntry.Side

which side of the entry to read (OLD or NEW).

ent:DiffEntry

the entry to examine.

Returns:ObjectLoader

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.

Exceptions
IOException:
the file cannot be accessed.
sizeback to summary
public long size(DiffEntry.Side side, DiffEntry ent) throws IOException

Determine the size of the object.

Parameters
side:DiffEntry.Side

which side of the entry to read (OLD or NEW).

ent:DiffEntry

the entry to examine.

Returns:long

the size in bytes.

Exceptions
IOException:
the file cannot be accessed.
org.eclipse.jgit.diff back to summary

private Class ContentSource.WorkingTreeSource

extends ContentSource
Class Inheritance

Field Summary

Modifier and TypeField and Description
private String
private final WorkingTreeIterator
pack-priv WorkingTreeIterator
private final TreeWalk

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides org.eclipse.jgit.diff.ContentSource.close.

Closes the used resources like ObjectReader, TreeWalk etc. Default implementation does nothing.

public boolean
isWorkingTreeSource()

Overrides org.eclipse.jgit.diff.ContentSource.isWorkingTreeSource.

Checks if the source is from "working tree", so it can be accessed as a file directly.

public ObjectLoader
open(String
the path of the file, relative to the root of the repository.
path
,
ObjectId
blob id of the file, if known.
id
)

Implements abstract org.eclipse.jgit.diff.ContentSource.open.

Open the object.

private void
seek(String path)

public long
size(String
the path of the file, relative to the root of the repository.
path
,
ObjectId
blob id of the file, if known.
id
)

Implements abstract org.eclipse.jgit.diff.ContentSource.size.

Determine the size of the object.

Inherited from org.eclipse.jgit.diff.ContentSource:
createcreate

Field Detail

currentback to summary
private String current
iteratorback to summary
private final WorkingTreeIterator iterator
ptrback to summary
pack-priv WorkingTreeIterator ptr
twback to summary
private final TreeWalk tw

Constructor Detail

WorkingTreeSourceback to summary
pack-priv WorkingTreeSource(WorkingTreeIterator iterator)

Method Detail

closeback to summary
public void close()

Overrides org.eclipse.jgit.diff.ContentSource.close.

Doc from org.eclipse.jgit.diff.ContentSource.close.

Closes the used resources like ObjectReader, TreeWalk etc. Default implementation does nothing.

Annotations
@Override
isWorkingTreeSourceback to summary
public boolean isWorkingTreeSource()

Overrides org.eclipse.jgit.diff.ContentSource.isWorkingTreeSource.

Doc from org.eclipse.jgit.diff.ContentSource.isWorkingTreeSource.

Checks if the source is from "working tree", so it can be accessed as a file directly.

Returns:boolean

true if working tree source and false otherwise (loader must be used)

Annotations
@Override
openback to summary
public ObjectLoader open(String path, ObjectId id) throws IOException

Implements abstract org.eclipse.jgit.diff.ContentSource.open.

Doc from org.eclipse.jgit.diff.ContentSource.open.

Open the object.

Parameters
path:String

the path of the file, relative to the root of the repository.

id:ObjectId

blob id of the file, if known.

Returns:ObjectLoader

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.

Annotations
@Override
Exceptions
IOException:
the file cannot be accessed.
seekback to summary
private void seek(String path) throws IOException
sizeback to summary
public long size(String path, ObjectId id) throws IOException

Implements abstract org.eclipse.jgit.diff.ContentSource.size.

Doc from org.eclipse.jgit.diff.ContentSource.size.

Determine the size of the object.

Parameters
path:String

the path of the file, relative to the root of the repository.

id:ObjectId

blob id of the file, if known.

Returns:long

the size in bytes.

Annotations
@Override
Exceptions
IOException:
the file cannot be accessed.