org.jacoco.report

## Class InputStreamSourceFileLocator

- java.lang.Object
- - org.jacoco.report.InputStreamSourceFileLocator

All Implemented Interfaces:
  ISourceFileLocator

Direct Known Subclasses:
  DirectorySourceFileLocator

    public abstract class InputStreamSourceFileLocator
    extends Object
    implements ISourceFileLocator

Abstract base class for `ISourceFileLocator` locator implementations based on `InputStream`s. It handles the encoding and tab width.

### Constructor Summary

Constructors
`protected` `InputStreamSourceFileLocator(String encoding, int tabWidth)` Creates a new locator with the given specification.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`Reader` `getSourceFile(String packageName, String fileName)` Tries to locate the given source file and opens a reader with the appropriate encoding.
`protected abstract InputStream` `getSourceStream(String path)` Tries to locate the given source file and opens its binary content.
`int` `getTabWidth()` Returns number of blank characters that represent a tab in source code.

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

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

### Constructor Detail

#### InputStreamSourceFileLocator

    protected InputStreamSourceFileLocator(String encoding,
                                           int tabWidth)

Creates a new locator with the given specification.

Parameters:
  `encoding` - encoding of the source files, `null` for platform default encoding
  `tabWidth` - tab width in source files as number of blanks

### Method Detail

#### getSourceFile

    public Reader getSourceFile(String packageName,
                                String fileName)
                         throws IOException

Description copied from interface: `ISourceFileLocator`
Tries to locate the given source file and opens a reader with the appropriate encoding.

Specified by:
  `getSourceFile` in interface `ISourceFileLocator`
Parameters:
  `packageName` - VM name of the package
  `fileName` - name of the source file
Returns:
  reader if the file could be located, `null` otherwise
Throws:
  `IOException` - in case of problems while opening the file

#### getTabWidth

    public int getTabWidth()

Description copied from interface: `ISourceFileLocator`
Returns number of blank characters that represent a tab in source code.

Specified by:
  `getTabWidth` in interface `ISourceFileLocator`
Returns:
  tab width as number of blanks

#### getSourceStream

    protected abstract InputStream getSourceStream(String path)
                                            throws IOException

Tries to locate the given source file and opens its binary content.

Parameters:
  `path` - local path to the resource
Returns:
  stream if the file could be located, `null` otherwise
Throws:
  `IOException` - in case of problems while opening the stream