Top Description Fields Constructors Methods
org.eclipse.jgit.blame

public Class BlameResult

extends Object
Class Inheritance
Imports
java.io.IOException, org.eclipse.jgit.diff.RawText, org.eclipse.jgit.lib.PersonIdent, org.eclipse.jgit.revwalk.RevCommit

Collects line annotations for inspection by applications.

A result is usually updated incrementally as the BlameGenerator digs back further through history. Applications that want to lay annotations down text to the original source file in a viewer may find the BlameResult structure an easy way to acquire the information, at the expense of keeping tables in memory tracking every line of the result file.

This class is not thread-safe.

During blame processing there are two files involved:

Field Summary

Modifier and TypeField and Description
private BlameGenerator
private int
private RawText
private final String
private final PersonIdent[]
private final RevCommit[]
private final PersonIdent[]
private final int[]
sourceLines

Warning

these are actually 1-based.

private final String[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
computeAll()

Compute all pending information.

public int

Returns:

index that is now available. -1 if no more are available.
computeNext
()

Compute the next available segment and return the first index.

public void
computeRange(int
first index to examine (inclusive).
start
,
int
end index (exclusive).
end
)

Compute until the entire range has been populated.

public static BlameResult

Returns:

the new result object. null if the generator cannot find the path it starts from.
create
(BlameGenerator
the generator the result will consume records from.
gen
)

Construct a new BlameResult for a generator.

public void
public RawText

Returns:

contents of the result file, available for display
getResultContents
()

Get result contents

public String

Returns:

path of the file this result annotates
getResultPath
()

Get result path

public PersonIdent

Returns:

author that provided line idx. May be null.
getSourceAuthor
(int
line to read data of, 0 based.
idx
)

Get the author that provided the specified line of the result.

public RevCommit

Returns:

commit that provided line idx. May be null.
getSourceCommit
(int
line to read data of, 0 based.
idx
)

Get the commit that provided the specified line of the result.

public PersonIdent

Returns:

committer that provided line idx. May be null.
getSourceCommitter
(int
line to read data of, 0 based.
idx
)

Get the committer that provided the specified line of the result.

public int

Returns:

matching line number in the source file.
getSourceLine
(int
line to read data of, 0 based.
idx
)

Get the corresponding line number in the source file.

public String

Returns:

source file path that provided line idx.
getSourcePath
(int
line to read data of, 0 based.
idx
)

Get the file path that provided the specified line of the result.

public boolean

Returns:

true if the data has been annotated, false otherwise.
hasSourceData
(int
line to read data of, 0 based.
idx
)

Check if the given result line has been annotated yet.

public boolean

Returns:

true if the data has been annotated, false otherwise.
hasSourceData
(int
first index to examine.
start
,
int
last index to examine.
end
)

Check if the given result line has been annotated yet.

public int

Returns:

length of the last segment found by computeNext()
lastLength
()

Get last length

private void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

generatorback to summary
private BlameGenerator generator
lastLengthback to summary
private int lastLength
resultContentsback to summary
private RawText resultContents
resultPathback to summary
private final String resultPath
sourceAuthorsback to summary
private final PersonIdent[] sourceAuthors
sourceCommitsback to summary
private final RevCommit[] sourceCommits
sourceCommittersback to summary
private final PersonIdent[] sourceCommitters
sourceLinesback to summary
private final int[] sourceLines

Warning

these are actually 1-based.

sourcePathsback to summary
private final String[] sourcePaths

Constructor Detail

BlameResultback to summary
pack-priv BlameResult(BlameGenerator bg, String path, RawText text)

Method Detail

computeAllback to summary
public void computeAll() throws IOException

Compute all pending information.

Exceptions
IOException:
the repository cannot be read.
computeNextback to summary
public int computeNext() throws IOException

Compute the next available segment and return the first index.

Computes one segment and returns to the caller the first index that is available. After return the caller can also inspect lastLength() to determine how many lines of the result were computed.

Returns:int

index that is now available. -1 if no more are available.

Exceptions
IOException:
the repository cannot be read.
computeRangeback to summary
public void computeRange(int start, int end) throws IOException

Compute until the entire range has been populated.

Parameters
start:int

first index to examine (inclusive).

end:int

end index (exclusive).

Exceptions
IOException:
the repository cannot be read.
createback to summary
public static BlameResult create(BlameGenerator gen) throws IOException

Construct a new BlameResult for a generator.

Parameters
gen:BlameGenerator

the generator the result will consume records from.

Returns:BlameResult

the new result object. null if the generator cannot find the path it starts from.

Exceptions
IOException:
the repository cannot be read.
discardResultContentsback to summary
public void discardResultContents()

Throw away the getResultContents().

getResultContentsback to summary
public RawText getResultContents()

Get result contents

Returns:RawText

contents of the result file, available for display

getResultPathback to summary
public String getResultPath()

Get result path

Returns:String

path of the file this result annotates

getSourceAuthorback to summary
public PersonIdent getSourceAuthor(int idx)

Get the author that provided the specified line of the result.

Parameters
idx:int

line to read data of, 0 based.

Returns:PersonIdent

author that provided line idx. May be null.

getSourceCommitback to summary
public RevCommit getSourceCommit(int idx)

Get the commit that provided the specified line of the result.

The source commit may be null if the line was blamed to an uncommitted revision, such as the working tree copy, or during a reverse blame if the line survives to the end revision (e.g. the branch tip).

Parameters
idx:int

line to read data of, 0 based.

Returns:RevCommit

commit that provided line idx. May be null.

getSourceCommitterback to summary
public PersonIdent getSourceCommitter(int idx)

Get the committer that provided the specified line of the result.

Parameters
idx:int

line to read data of, 0 based.

Returns:PersonIdent

committer that provided line idx. May be null.

getSourceLineback to summary
public int getSourceLine(int idx)

Get the corresponding line number in the source file.

Parameters
idx:int

line to read data of, 0 based.

Returns:int

matching line number in the source file.

getSourcePathback to summary
public String getSourcePath(int idx)

Get the file path that provided the specified line of the result.

Parameters
idx:int

line to read data of, 0 based.

Returns:String

source file path that provided line idx.

hasSourceDataback to summary
public boolean hasSourceData(int idx)

Check if the given result line has been annotated yet.

Parameters
idx:int

line to read data of, 0 based.

Returns:boolean

true if the data has been annotated, false otherwise.

hasSourceDataback to summary
public boolean hasSourceData(int start, int end)

Check if the given result line has been annotated yet.

Parameters
start:int

first index to examine.

end:int

last index to examine.

Returns:boolean

true if the data has been annotated, false otherwise.

lastLengthback to summary
public int lastLength()

Get last length

Returns:int

length of the last segment found by computeNext()

loadFromback to summary
private void loadFrom(BlameGenerator gen)
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
@Override