Package edu.umd.cs.findbugs.ba
Class SourceFile
java.lang.Object
edu.umd.cs.findbugs.ba.SourceFile
Cached data for a source file. Contains a map of line numbers to byte
offsets, for quick searching of source lines.
- Author:
- David Hovemeyer
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addLineOffset
(int offset) Add a source line byte offset.Get the full path name of the source file (with directory).Get the full URI of the source file (with directory).Get an InputStream on data.getInputStreamFromOffset
(int offset) Get an InputStream on data starting at given offset.long
int
getLineOffset
(int line) Get the byte offset in the data for a source line.
-
Constructor Details
-
SourceFile
Constructor.- Parameters:
dataSource
- the SourceFileDataSource object which will provide the data of the source file
-
-
Method Details
-
getFullFileName
Get the full path name of the source file (with directory). -
getFullURI
Get the full URI of the source file (with directory). -
getInputStream
Get an InputStream on data.- Returns:
- an InputStream on the data in the source file, starting from given offset
- Throws:
IOException
-
getInputStreamFromOffset
Get an InputStream on data starting at given offset.- Parameters:
offset
- the start offset- Returns:
- an InputStream on the data in the source file, starting at the given offset
- Throws:
IOException
-
addLineOffset
public void addLineOffset(int offset) Add a source line byte offset. This method should be called for each line in the source file, in order.- Parameters:
offset
- the byte offset of the next source line
-
getLineOffset
public int getLineOffset(int line) Get the byte offset in the data for a source line. Note that lines are considered to be zero-index, so the first line in the file is numbered zero.- Parameters:
line
- the line number- Returns:
- the byte offset in the file's data for the line, or -1 if the line is not valid
-
getLastModified
public long getLastModified()
-