org.eclipse.jgit.blame

## Class BlameResult

- java.lang.Object
- - org.eclipse.jgit.blame.BlameResult

    public class BlameResult
    extends Object

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:

- result - The file whose lines are being examined. This is the revision the user is trying to view blame/annotation information alongside of.
- source - The file that was blamed with supplying one or more lines of data into result. The source may be a different file path (due to copy or rename). Source line numbers may differ from result line numbers due to lines being added/removed in intermediate revisions.

### Method Summary

Methods
`void` `computeAll()` Compute all pending information.
`int` `computeNext()` Compute the next available segment and return the first index.
`void` `computeRange(int start, int end)` Compute until the entire range has been populated.
`static BlameResult` `create(BlameGenerator gen)` Construct a new BlameResult for a generator.
`void` `discardResultContents()` Throw away the `getResultContents()`.
`RawText` `getResultContents()`
`String` `getResultPath()`
`PersonIdent` `getSourceAuthor(int idx)` Get the author that provided the specified line of the result.
`RevCommit` `getSourceCommit(int idx)` Get the commit that provided the specified line of the result.
`PersonIdent` `getSourceCommitter(int idx)` Get the committer that provided the specified line of the result.
`int` `getSourceLine(int idx)` Get the corresponding line number in the source file.
`String` `getSourcePath(int idx)` Get the file path that provided the specified line of the result.
`boolean` `hasSourceData(int idx)` Check if the given result line has been annotated yet.
`boolean` `hasSourceData(int start, int end)` Check if the given result line has been annotated yet.
`int` `lastLength()`
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Method Detail

#### create

    public static BlameResult create(BlameGenerator gen)
                              throws IOException

Construct a new BlameResult for a generator.

Parameters:
  `gen` - the generator the result will consume records from.
Returns:
  the new result object. null if the generator cannot find the path it starts from.
Throws:
  `IOException` - the repository cannot be read.

#### getResultPath

    public String getResultPath()

Returns:
  path of the file this result annotates.

#### getResultContents

    public RawText getResultContents()

Returns:
  contents of the result file, available for display.

#### discardResultContents

    public void discardResultContents()

Throw away the `getResultContents()`.

#### hasSourceData

    public boolean hasSourceData(int idx)

Check if the given result line has been annotated yet.

Parameters:
  `idx` - line to read data of, 0 based.
Returns:
  true if the data has been annotated, false otherwise.

#### hasSourceData

    public boolean hasSourceData(int start,
                        int end)

Check if the given result line has been annotated yet.

Parameters:
  `start` - first index to examine.
  `end` - last index to examine.
Returns:
  true if the data has been annotated, false otherwise.

#### getSourceCommit

    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` - line to read data of, 0 based.
Returns:
  commit that provided line `idx`. May be null.

#### getSourceAuthor

    public PersonIdent getSourceAuthor(int idx)

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

Parameters:
  `idx` - line to read data of, 0 based.
Returns:
  author that provided line `idx`. May be null.

#### getSourceCommitter

    public PersonIdent getSourceCommitter(int idx)

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

Parameters:
  `idx` - line to read data of, 0 based.
Returns:
  committer that provided line `idx`. May be null.

#### getSourcePath

    public String getSourcePath(int idx)

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

Parameters:
  `idx` - line to read data of, 0 based.
Returns:
  source file path that provided line `idx`.

#### getSourceLine

    public int getSourceLine(int idx)

Get the corresponding line number in the source file.

Parameters:
  `idx` - line to read data of, 0 based.
Returns:
  matching line number in the source file.

#### computeAll

    public void computeAll()
                    throws IOException

Compute all pending information.

Throws:
  `IOException` - the repository cannot be read.

#### computeNext

    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:
  index that is now available. -1 if no more are available.
Throws:
  `IOException` - the repository cannot be read.

#### lastLength

    public int lastLength()

Returns:
  length of the last segment found by `computeNext()`.

#### computeRange

    public void computeRange(int start,
                    int end)
                      throws IOException

Compute until the entire range has been populated.

Parameters:
  `start` - first index to examine.
  `end` - last index to examine.
Throws:
  `IOException` - the repository cannot be read.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`