public interface

FileContentCallback

com.atlassian.stash.content.FileContentCallback
Known Indirect Subclasses

Class Overview

A callback for the contents of a file

Note: Implementors are strongly encouraged to extend from AbstractFileContentCallback. This interface will change, over time, and any class implementing it directly will be broken by such changes. Extending from the abstract class will help prevent such breakages.

Warning: The semantics of blame were changed slightly in Stash 2.10. Previously appendBlame(List) was called after onEndPage(Page). For 2.10+, appendBlame(List) is now called before onEndPage(Page). This makes onEndPage(Page)'s behaviour consistent with other callbacks; it is always intended to be the final callback method to be invoked, indicating there is no further data available so that callback implementations can wrap up their processing.

Summary

Public Methods
@Deprecated void appendBlame(List<? extends Blame> blames)
This method is deprecated. in 2.10 for removal in 3.0. Callbacks should extend AbstractFileContentCallback and implement offerBlame(List) instead.
void onBinary()
Called once if the file is binary.
@Deprecated void onEndPage(Page<?> page)
This method is deprecated. in 2.10 for removal in 3.0. Callbacks should extend AbstractFileContentCallback and implement onEnd(FileSummary) instead.
boolean onLine(int lineNumber, String line, boolean truncated)
Called once for each line in the file.
@Deprecated void onStartPage(int index)
This method is deprecated. in 2.10 for removal in 3.0. Callbacks should extend AbstractFileContentCallback and implement onStart(FileSummary) instead.

Public Methods

@Deprecated public void appendBlame (List<? extends Blame> blames)

This method is deprecated.
in 2.10 for removal in 3.0. Callbacks should extend AbstractFileContentCallback and implement offerBlame(List) instead.

If annotations were requested and at least one line was streamed, this method will be called before onEndPage(Page) to provide blame for the streamed lines.

Warning: The semantics of this method were changed slightly in Stash 2.10. In previous releases it was called after onEndPage(Page). It is now called before onEndPage(Page). This makes onEndPage(Page)'s handling consistent with other callbacks; it is always intended to be the final callback method to be invoked, indicating there is no further data available.

Parameters
blames blame for the streamed lines
Throws
IOException if the callback fails

public void onBinary ()

Called once if the file is binary. None of the other methods will be called.

Throws
IOException if the callback fails

@Deprecated public void onEndPage (Page<?> page)

This method is deprecated.
in 2.10 for removal in 3.0. Callbacks should extend AbstractFileContentCallback and implement onEnd(FileSummary) instead.

Called after onStartPage(int)

Parameters
page information about the page streamed to the callback. The page.getValues() will return null as the callback has already received the data. This is used to know information about the number of elements processed and whether there is more content to be retrieved in the future
Throws
IOException if the callback fails

public boolean onLine (int lineNumber, String line, boolean truncated)

Called once for each line in the file. onStartPage(int) is called before any invocation of this method. onEndPage(Page) is called after all invocations of this method.

Parameters
lineNumber the line number of the line in the file
line a truncated line of code. The line character limit can be set at a system level via a system property
truncated where the received line was truncated
Returns
  • true if additional lines should be provided; otherwise, false if sufficient lines have been processed
Throws
IOException if the callback fails

@Deprecated public void onStartPage (int index)

This method is deprecated.
in 2.10 for removal in 3.0. Callbacks should extend AbstractFileContentCallback and implement onStart(FileSummary) instead.

Called before onLine(int, String, boolean). It provides the callback the index of the first line on the page.

onStart(FileContext) will replace this method in Stash 3.0. Until 3.0, the starting index can be retrieved using the deprecated getStart(). Plugin developers should implement onEnd(FileSummary) and use the FileSummary to retrieve paging details.

Parameters
index the index of the starting element of the page
Throws
IOException if the callback fails