public class BlameResult
extends java.lang.Object
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:
Modifier and Type | Field and Description |
---|---|
private BlameGenerator |
generator |
private int |
lastLength |
private RawText |
resultContents |
private java.lang.String |
resultPath |
private PersonIdent[] |
sourceAuthors |
private RevCommit[] |
sourceCommits |
private PersonIdent[] |
sourceCommitters |
private int[] |
sourceLines
Warning: these are actually 1-based.
|
private java.lang.String[] |
sourcePaths |
Constructor and Description |
---|
BlameResult(BlameGenerator bg,
java.lang.String path,
RawText text) |
Modifier and Type | Method and Description |
---|---|
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()
Get result contents
|
java.lang.String |
getResultPath()
Get result path
|
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.
|
java.lang.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()
Get last length
|
private void |
loadFrom(BlameGenerator gen) |
java.lang.String |
toString() |
private final java.lang.String resultPath
private final RevCommit[] sourceCommits
private final PersonIdent[] sourceAuthors
private final PersonIdent[] sourceCommitters
private final java.lang.String[] sourcePaths
private final int[] sourceLines
private RawText resultContents
private BlameGenerator generator
private int lastLength
BlameResult(BlameGenerator bg, java.lang.String path, RawText text)
public static BlameResult create(BlameGenerator gen) throws java.io.IOException
gen
- the generator the result will consume records from.java.io.IOException
- the repository cannot be read.public java.lang.String getResultPath()
public RawText getResultContents()
public void discardResultContents()
getResultContents()
.public boolean hasSourceData(int idx)
idx
- line to read data of, 0 based.public boolean hasSourceData(int start, int end)
start
- first index to examine.end
- last index to examine.public RevCommit getSourceCommit(int idx)
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).
idx
- line to read data of, 0 based.idx
. May be null.public PersonIdent getSourceAuthor(int idx)
idx
- line to read data of, 0 based.idx
. May be null.public PersonIdent getSourceCommitter(int idx)
idx
- line to read data of, 0 based.idx
. May be null.public java.lang.String getSourcePath(int idx)
idx
- line to read data of, 0 based.idx
.public int getSourceLine(int idx)
idx
- line to read data of, 0 based.public void computeAll() throws java.io.IOException
java.io.IOException
- the repository cannot be read.public int computeNext() throws java.io.IOException
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.
java.io.IOException
- the repository cannot be read.public int lastLength()
computeNext()
public void computeRange(int start, int end) throws java.io.IOException
start
- first index to examine (inclusive).end
- end index (exclusive).java.io.IOException
- the repository cannot be read.public java.lang.String toString()
toString
in class java.lang.Object
private void loadFrom(BlameGenerator gen)