Package edu.umd.cs.findbugs.ba
Class SourceFinder
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.SourceFinder
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class SourceFinder extends java.lang.Object implements java.lang.AutoCloseable
Class to open input streams on source files. It maintains a "source path", which is like a classpath, but for finding source files instead of class files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
SourceFinder.BlockingSourceRepository
private static class
SourceFinder.Cache
Cache of SourceFiles.private static class
SourceFinder.DirectorySourceRepository
A directory containing source files.private static class
SourceFinder.InMemorySourceRepository
private static interface
SourceFinder.SourceRepository
A repository of source files.(package private) static class
SourceFinder.ZipSourceRepository
A zip or jar archive containing source files.
-
Field Summary
Fields Modifier and Type Field Description private SourceFinder.Cache
cache
private static int
CACHE_SIZE
private static boolean
DEBUG
private Project
project
private java.util.List<SourceFinder.SourceRepository>
repositoryList
-
Constructor Summary
Constructors Constructor Description SourceFinder(Project project)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
SourceFile
findSourceFile(SourceLineAnnotation source)
SourceFile
findSourceFile(java.lang.String packageName, java.lang.String fileName)
Open a source file in given package.java.util.Optional<java.net.URI>
getBase(SourceLineAnnotation sourceLineAnnotation)
java.util.Optional<java.net.URI>
getBase(java.lang.String fileName)
static java.lang.String
getCanonicalName(SourceLineAnnotation source)
static java.lang.String
getCanonicalName(java.lang.String packageName, java.lang.String fileName)
static java.lang.String
getOrGuessSourceFile(SourceLineAnnotation source)
static java.lang.String
getPlatformName(SourceLineAnnotation source)
static java.lang.String
getPlatformName(java.lang.String packageName, java.lang.String fileName)
Project
getProject()
boolean
hasSourceFile(SourceLineAnnotation source)
boolean
hasSourceFile(java.lang.String packageName, java.lang.String fileName)
(package private) SourceFinder.SourceRepository
makeInMemorySourceRepository(java.lang.String url)
(package private) SourceFinder.SourceRepository
makeJarURLConnectionSourceRepository(java.lang.String url)
private java.io.InputStream
open(java.lang.String url)
java.io.InputStream
openSource(SourceLineAnnotation source)
java.io.InputStream
openSource(java.lang.String packageName, java.lang.String fileName)
Open an input stream on a source file in given package.private void
setProject(Project project)
void
setSourceBaseList(java.lang.Iterable<java.lang.String> sourceBaseList)
Set the list of source directories.
-
-
-
Field Detail
-
DEBUG
private static final boolean DEBUG
-
CACHE_SIZE
private static final int CACHE_SIZE
- See Also:
- Constant Field Values
-
repositoryList
private java.util.List<SourceFinder.SourceRepository> repositoryList
-
cache
private SourceFinder.Cache cache
-
project
private Project project
-
-
Constructor Detail
-
SourceFinder
public SourceFinder(Project project)
-
-
Method Detail
-
makeInMemorySourceRepository
SourceFinder.SourceRepository makeInMemorySourceRepository(java.lang.String url)
-
makeJarURLConnectionSourceRepository
SourceFinder.SourceRepository makeJarURLConnectionSourceRepository(java.lang.String url) throws java.io.IOException
- Throws:
java.io.IOException
-
open
private java.io.InputStream open(java.lang.String url) throws java.io.IOException
- Parameters:
url
-- Returns:
- Throws:
java.io.IOException
java.net.MalformedURLException
-
getProject
public Project getProject()
- Returns:
- Returns the project.
-
setSourceBaseList
public void setSourceBaseList(java.lang.Iterable<java.lang.String> sourceBaseList)
Set the list of source directories.
-
openSource
public java.io.InputStream openSource(java.lang.String packageName, java.lang.String fileName) throws java.io.IOException
Open an input stream on a source file in given package.- Parameters:
packageName
- the name of the package containing the class whose source file is givenfileName
- the unqualified name of the source file- Returns:
- an InputStream on the source file
- Throws:
java.io.IOException
- if a matching source file cannot be found
-
openSource
public java.io.InputStream openSource(SourceLineAnnotation source) throws java.io.IOException
- Throws:
java.io.IOException
-
findSourceFile
public SourceFile findSourceFile(SourceLineAnnotation source) throws java.io.IOException
- Throws:
java.io.IOException
-
findSourceFile
public SourceFile findSourceFile(java.lang.String packageName, java.lang.String fileName) throws java.io.IOException
Open a source file in given package.- Parameters:
packageName
- the name of the package containing the class whose source file is givenfileName
- the unqualified name of the source file- Returns:
- the source file
- Throws:
java.io.IOException
- if a matching source file cannot be found
-
getPlatformName
public static java.lang.String getPlatformName(java.lang.String packageName, java.lang.String fileName)
-
getPlatformName
public static java.lang.String getPlatformName(SourceLineAnnotation source)
-
getCanonicalName
public static java.lang.String getCanonicalName(SourceLineAnnotation source)
-
getCanonicalName
public static java.lang.String getCanonicalName(java.lang.String packageName, java.lang.String fileName)
-
getOrGuessSourceFile
public static java.lang.String getOrGuessSourceFile(SourceLineAnnotation source)
-
hasSourceFile
public boolean hasSourceFile(SourceLineAnnotation source)
-
hasSourceFile
public boolean hasSourceFile(java.lang.String packageName, java.lang.String fileName)
-
setProject
private void setProject(Project project)
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
getBase
public java.util.Optional<java.net.URI> getBase(SourceLineAnnotation sourceLineAnnotation)
-
getBase
public java.util.Optional<java.net.URI> getBase(java.lang.String fileName)
-
-