Class Project
java.lang.Object
edu.umd.cs.findbugs.Project
- All Implemented Interfaces:
XMLWriteable, AutoCloseable
A project in the GUI. This consists of some number of Jar files to analyze for bugs, and optionally
- some number of source directories, for locating the program's source code
- some number of auxiliary classpath entries, for locating classes referenced by the program which the user doesn't want to analyze
- some number of boolean options
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classWorklist for finding implicit classpath entries.private static classWorklist item for finding implicit classpath entries. -
Field Summary
FieldsModifier and TypeFieldDescriptionList of jars/directories to analyzeprivate static final String(package private) static final StringThe list of auxiliary classpath entries.private UserPreferenceskey is plugin idprivate static final booleanHack for whether files are case insensitive.(package private) static final Stringprivate IGuiCallbackprivate booleanFlag to indicate that this Project has been modified.(package private) static final Stringprivate static final Stringprivate static final org.slf4j.Loggerprivate static final String(package private) static final String(package private) static final String(package private) static final Stringprivate String(package private) static final Stringstatic final Stringprivate SourceFinder(package private) static final Stringprivate static final StringThe list of source directories.private Filterprivate longstatic final StringStaticConstant used to name anonymous projects.(package private) static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd information from project2 to this projectbooleanaddAuxClasspathEntry(String auxClasspathEntry) Add an auxiliary classpath entrybooleanAdd a file to the project.booleanaddSourceDir(String sourceDir) Deprecated.Calling this method repeatedly performs poorly because a SourceFinder is created each time, which checks all files for existence each time.booleanaddSourceDirs(Collection<String> sourceDirs) Add source directories to the project.voidaddTimestamp(long timestamp) private <T> booleanaddToListInternal(Collection<T> list, T value) Add a value to given list, making the Project modified if the value is not already present in the list.booleanaddWorkingDir(String dirName) Add a working directory to the project.static <T> List<T> appendWithoutDuplicates(List<T> lst1, List<T> lst2) voidclose()private StringconvertToRelative(String srcFile, String base) Converts a full path to a relative path if possibleconvertToRelative(List<String> paths, String base) Return an exact copy of this Project.getAuxClasspathEntry(int n) Get the n'th auxiliary classpath entry.Return the list of aux classpath entries.getFile(int num) Get the given file in the list of project files.String[]Get project files as an array of Strings.intGet the number of files in the project.Get the list of files, directories, and zip files in the project.Deprecated.FindBugs2 and ClassPathBuilder take care of this automaticallyintGet the number of auxiliary classpath entries.intGet the number of source directories in the project.getPluginStatus(Plugin plugin) getSourceDir(int num) Get the given source directory.String[]Get source dirs as an array of Strings.Get the source dir list.longbooleanbooleanReturn whether or not this Project has unsaved modifications.private StringmakeAbsoluteCWD(String fileName) Make the given filename absolute relative to the current working directory.makeAbsoluteCwdCandidates(String fileName) Make the given filename absolute relative to the current working directory candidates.private voidprocessComponentJar(URL jarFileURL, Project.WorkList workList, List<String> implicitClasspath) Examine the manifest of a single zip/jar file for implicit classapth entries.static ProjectreadProject(String argument) Read Project from named file.static ProjectvoidremoveAuxClasspathEntry(int n) Remove the n'th auxiliary classpath entry.voidremoveFile(int num) Remove file at the given index in the list of project filesvoidremoveSourceDir(int num) Remove source directory at given index.voidsetConfiguration(UserPreferences configuration) voidvoidsetGuiCallback(IGuiCallback guiCallback) voidsetModified(boolean isModified) Set whether or not this Project has unsaved modifications.voidsetPluginStatusTrinary(String pluginId, Boolean enabled) voidsetProjectName(String projectName) voidsetSuppressionFilter(Filter suppressionFilter) voidsetTimestamp(long timestamp) toString()Convert to a string in a nice (displayable) format.static StringtransformFilename(String fileName) Transform a user-entered filename into a proper filename, by adding the ".fb" file extension if it isn't already present.voidDeprecated.voidWrite this object to given XMLOutput.voidwriteXML(XMLOutput xmlOutput, File destination, BugCollection bugCollection) voidwriteXML(File f, BugCollection bugCollection)
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
currentWorkingDirectoryList
-
projectName
-
analysisTargets
-
srcDirList
-
auxClasspathEntryList
-
isModified
private boolean isModifiedFlag to indicate that this Project has been modified. -
configuration
-
enabledPlugins
-
UNNAMED_PROJECT
StaticConstant used to name anonymous projects.- See Also:
-
timestampForAnalyzedClasses
private long timestampForAnalyzedClasses -
guiCallback
-
suppressionFilter
-
sourceFinder
-
JAR_ELEMENT_NAME
- See Also:
-
AUX_CLASSPATH_ENTRY_ELEMENT_NAME
- See Also:
-
SRC_DIR_ELEMENT_NAME
- See Also:
-
WRK_DIR_ELEMENT_NAME
- See Also:
-
FILENAME_ATTRIBUTE_NAME
- See Also:
-
PROJECTNAME_ATTRIBUTE_NAME
- See Also:
-
PLUGIN_ELEMENT_NAME
- See Also:
-
PLUGIN_ID_ATTRIBUTE_NAME
- See Also:
-
PLUGIN_STATUS_ELEMENT_NAME
- See Also:
-
OPTIONS_KEY
- See Also:
-
JAR_FILES_KEY
- See Also:
-
SRC_DIRS_KEY
- See Also:
-
AUX_CLASSPATH_ENTRIES_KEY
- See Also:
-
RELATIVE_PATHS
- See Also:
-
FILE_IGNORE_CASE
private static final boolean FILE_IGNORE_CASEHack for whether files are case insensitive. For now, we'll assume that Windows is the only case insensitive OS. (OpenVMS users, feel free to submit a patch :-)
-
-
Constructor Details
-
Project
public Project()Create an anonymous project.
-
-
Method Details
-
getPluginStatus
-
setPluginStatusTrinary
-
getConfiguration
-
setConfiguration
- Parameters:
configuration- The configuration to set, non null
-
duplicate
Return an exact copy of this Project. -
getSourceFinder
-
isGuiAvaliable
public boolean isGuiAvaliable() -
add
add information from project2 to this project -
appendWithoutDuplicates
-
setCurrentWorkingDirectory
-
isModified
public boolean isModified()Return whether or not this Project has unsaved modifications. -
setModified
public void setModified(boolean isModified) Set whether or not this Project has unsaved modifications. -
addFile
Add a file to the project.- Parameters:
fileName- the file to add- Returns:
- true if the file was added, or false if the file was already present
-
addSourceDir
Deprecated.Calling this method repeatedly performs poorly because a SourceFinder is created each time, which checks all files for existence each time. UseaddSourceDirs(Collection)instead.Add a source directory to the project.- Parameters:
sourceDir- The source directory to add. These can be either an absolute path or relative to any of the working directories in this project object.- Returns:
- true if the source directory was added or false if it was already present
-
addSourceDirs
Add source directories to the project.- Parameters:
sourceDirs- The source directories to add. These can be either absolute paths or relative to any of the working directories in this project object.- Returns:
- true if a source directory was added or false if all source directories were already present
-
addWorkingDir
Add a working directory to the project.- Parameters:
dirName- the directory to add- Returns:
- true if the working directory was added, or false if the working directory was already present
-
getFileCount
public int getFileCount()Get the number of files in the project.- Returns:
- the number of files in the project
-
getFile
Get the given file in the list of project files.- Parameters:
num- the number of the file in the list of project files- Returns:
- the name of the file
-
removeFile
public void removeFile(int num) Remove file at the given index in the list of project files- Parameters:
num- index of the file to remove in the list of project files
-
getFileList
-
getNumSourceDirs
public int getNumSourceDirs()Get the number of source directories in the project.- Returns:
- the number of source directories in the project
-
getSourceDir
Get the given source directory.- Parameters:
num- the number of the source directory- Returns:
- the source directory
-
removeSourceDir
public void removeSourceDir(int num) Remove source directory at given index.- Parameters:
num- index of the source directory to remove
-
getFileArray
Get project files as an array of Strings. -
getSourceDirArray
Get source dirs as an array of Strings. -
getSourceDirList
-
addAuxClasspathEntry
Add an auxiliary classpath entry- Parameters:
auxClasspathEntry- the entry- Returns:
- true if the entry was added successfully, or false if the given entry is already in the list
-
getNumAuxClasspathEntries
public int getNumAuxClasspathEntries()Get the number of auxiliary classpath entries. -
getAuxClasspathEntry
Get the n'th auxiliary classpath entry. -
removeAuxClasspathEntry
public void removeAuxClasspathEntry(int n) Remove the n'th auxiliary classpath entry. -
getAuxClasspathEntryList
-
getImplicitClasspathEntryList
Deprecated.FindBugs2 and ClassPathBuilder take care of this automaticallyReturn the list of implicit classpath entries. The implicit classpath is computed from the closure of the set of jar files that are referenced by the"Class-Path"attribute of the manifest of the any jar file that is part of this project or by the"Class-Path"attribute of any directly or indirectly referenced jar. The referenced jar files that exist are the list of implicit classpath entries. -
processComponentJar
private void processComponentJar(URL jarFileURL, Project.WorkList workList, List<String> implicitClasspath) Examine the manifest of a single zip/jar file for implicit classapth entries.- Parameters:
jarFileURL- URL of the zip/jar fileworkList- worklist of zip/jar files to examineimplicitClasspath- list of implicit classpath entries found
-
write
@Deprecated public void write(String outputFile, boolean useRelativePaths, String relativeBase) throws IOException Deprecated.Save the project to an output file.- Parameters:
outputFile- name of output fileuseRelativePaths- true if the project should be written using only relative pathsrelativeBase- if useRelativePaths is true, this file is taken as the base directory in terms of which all files should be made relative- Throws:
IOException- if an error occurs while writing
-
readXML
public static Project readXML(File f) throws IOException, SAXException, ParserConfigurationException -
writeXML
- Throws:
IOException
-
readProject
Read Project from named file.- Parameters:
argument- command line argument containing project file name- Returns:
- the Project
- Throws:
IOException
-
toString
-
transformFilename
-
writeXML
Description copied from interface:XMLWriteableWrite this object to given XMLOutput.- Specified by:
writeXMLin interfaceXMLWriteable- Parameters:
xmlOutput- the XMLOutput for the document- Throws:
IOException
-
writeXML
public void writeXML(XMLOutput xmlOutput, @CheckForNull File destination, @CheckForNull BugCollection bugCollection) throws IOException - Throws:
IOException
-
convertToRelative
-
convertToRelative
-
makeAbsoluteCWD
-
makeAbsoluteCwdCandidates
Make the given filename absolute relative to the current working directory candidates. If the given filename exists in more than one of the working directories, a list of these existing absolute paths is returned. The returned list is guaranteed to be non-empty. The returned paths might exist or not exist and might be relative or absolute.- Returns:
- A list of at least one candidate path for the given filename.
-
addToListInternal
Add a value to given list, making the Project modified if the value is not already present in the list.- Parameters:
list- the listvalue- the value to be added- Returns:
- true if the value was not already present in the list, false otherwise
-
setTimestamp
public void setTimestamp(long timestamp) -
addTimestamp
public void addTimestamp(long timestamp) -
getTimestamp
public long getTimestamp() -
setProjectName
-
getProjectName
-
setSuppressionFilter
-
getSuppressionFilter
-
setGuiCallback
-
getGuiCallback
-
getResolvedSourcePaths
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-