Package edu.umd.cs.findbugs
Class Project
- java.lang.Object
-
- edu.umd.cs.findbugs.Project
-
- All Implemented Interfaces:
XMLWriteable
public class Project extends java.lang.Object implements XMLWriteable
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
- Author:
- David Hovemeyer
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringRELATIVE_PATHSstatic java.lang.StringUNNAMED_PROJECTStaticConstant used to name anonymous projects.
-
Constructor Summary
Constructors Constructor Description Project()Create an anonymous project.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(Project project2)add information from project2 to this projectbooleanaddAuxClasspathEntry(java.lang.String auxClasspathEntry)Add an auxiliary classpath entrybooleanaddFile(java.lang.String fileName)Add a file to the project.booleanaddSourceDir(java.lang.String dirName)Add a source directory to the project.voidaddTimestamp(long timestamp)booleanaddWorkingDir(java.lang.String dirName)Add a working directory to the project.static <T> java.util.List<T>appendWithoutDuplicates(java.util.List<T> lst1, java.util.List<T> lst2)Projectduplicate()Return an exact copy of this Project.java.lang.StringgetAuxClasspathEntry(int n)Get the n'th auxiliary classpath entry.java.util.List<java.lang.String>getAuxClasspathEntryList()Return the list of aux classpath entries.java.lang.StringgetCloudId()java.util.PropertiesgetCloudProperties()UserPreferencesgetConfiguration()java.lang.StringgetFile(int num)Get the given file in the list of project files.java.lang.String[]getFileArray()Get project files as an array of Strings.intgetFileCount()Get the number of files in the project.java.util.List<java.lang.String>getFileList()Get the list of files, directories, and zip files in the project.IGuiCallbackgetGuiCallback()java.util.List<java.lang.String>getImplicitClasspathEntryList()Deprecated.FindBugs2 and ClassPathBuilder take care of this automaticallyintgetNumAuxClasspathEntries()Get the number of auxiliary classpath entries.intgetNumSourceDirs()Get the number of source directories in the project.java.lang.BooleangetPluginStatus(Plugin plugin)java.lang.StringgetProjectName()java.lang.Iterable<java.lang.String>getResolvedSourcePaths()java.lang.StringgetSourceDir(int num)Get the given source directory.java.lang.String[]getSourceDirArray()Get source dirs as an array of Strings.java.util.List<java.lang.String>getSourceDirList()Get the source dir list.SourceFindergetSourceFinder()FiltergetSuppressionFilter()longgetTimestamp()booleanisGuiAvaliable()booleanisModified()Return whether or not this Project has unsaved modifications.static ProjectreadProject(java.lang.String argument)Read Project from named file.static ProjectreadXML(java.io.File f)voidremoveAuxClasspathEntry(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.voidsetCloudId(java.lang.String cloudId)voidsetCloudProperties(java.util.Properties cloudProperties)voidsetConfiguration(UserPreferences configuration)voidsetCurrentWorkingDirectory(java.io.File f)voidsetGuiCallback(IGuiCallback guiCallback)voidsetModified(boolean isModified)Set whether or not this Project has unsaved modifications.voidsetPluginStatusTrinary(java.lang.String pluginId, java.lang.Boolean enabled)voidsetProjectName(java.lang.String projectName)voidsetSuppressionFilter(Filter suppressionFilter)voidsetTimestamp(long timestamp)Make the given list of pathnames absolute relative to the absolute path of the project file.java.lang.StringtoString()Convert to a string in a nice (displayable) format.static java.lang.StringtransformFilename(java.lang.String fileName)Transform a user-entered filename into a proper filename, by adding the ".fb" file extension if it isn't already present.voidwrite(java.lang.String outputFile, boolean useRelativePaths, java.lang.String relativeBase)Deprecated.voidwriteXML(XMLOutput xmlOutput)Write this object to given XMLOutput.voidwriteXML(XMLOutput xmlOutput, java.io.File destination, BugCollection bugCollection)voidwriteXML(java.io.File f, BugCollection bugCollection)
-
-
-
Field Detail
-
UNNAMED_PROJECT
public static final java.lang.String UNNAMED_PROJECT
StaticConstant used to name anonymous projects.- See Also:
- Constant Field Values
-
RELATIVE_PATHS
public static final java.lang.String RELATIVE_PATHS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPluginStatus
@CheckForNull public java.lang.Boolean getPluginStatus(Plugin plugin)
-
setPluginStatusTrinary
public void setPluginStatusTrinary(java.lang.String pluginId, java.lang.Boolean enabled)
-
getConfiguration
public UserPreferences getConfiguration()
-
setConfiguration
public void setConfiguration(@Nonnull UserPreferences configuration)- Parameters:
configuration- The configuration to set, non null
-
getCloudId
@CheckForNull public java.lang.String getCloudId()
-
setCloudId
public void setCloudId(@Nullable java.lang.String cloudId)
-
getCloudProperties
public java.util.Properties getCloudProperties()
- Returns:
- Returns the cloudProperties.
-
setCloudProperties
public void setCloudProperties(java.util.Properties cloudProperties)
- Parameters:
cloudProperties- The cloudProperties to set.
-
duplicate
public Project duplicate()
Return an exact copy of this Project.
-
getSourceFinder
public SourceFinder getSourceFinder()
-
isGuiAvaliable
public boolean isGuiAvaliable()
-
add
public void add(Project project2)
add information from project2 to this project
-
appendWithoutDuplicates
public static <T> java.util.List<T> appendWithoutDuplicates(java.util.List<T> lst1, java.util.List<T> lst2)
-
setCurrentWorkingDirectory
public void setCurrentWorkingDirectory(java.io.File f)
-
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
public boolean addFile(java.lang.String fileName)
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
public boolean addSourceDir(java.lang.String dirName)
Add a source directory to the project.- Parameters:
dirName- the directory to add- Returns:
- true if the source directory was added, or false if the source directory was already present
-
addWorkingDir
public boolean addWorkingDir(java.lang.String dirName)
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
public java.lang.String getFile(int num)
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
public java.util.List<java.lang.String> getFileList()
Get the list of files, directories, and zip files in the project.
-
getNumSourceDirs
public int getNumSourceDirs()
Get the number of source directories in the project.- Returns:
- the number of source directories in the project
-
getSourceDir
public java.lang.String getSourceDir(int num)
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
public java.lang.String[] getFileArray()
Get project files as an array of Strings.
-
getSourceDirArray
public java.lang.String[] getSourceDirArray()
Get source dirs as an array of Strings.
-
getSourceDirList
public java.util.List<java.lang.String> getSourceDirList()
Get the source dir list.
-
addAuxClasspathEntry
public boolean addAuxClasspathEntry(java.lang.String auxClasspathEntry)
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
public java.lang.String getAuxClasspathEntry(int n)
Get the n'th auxiliary classpath entry.
-
removeAuxClasspathEntry
public void removeAuxClasspathEntry(int n)
Remove the n'th auxiliary classpath entry.
-
getAuxClasspathEntryList
public java.util.List<java.lang.String> getAuxClasspathEntryList()
Return the list of aux classpath entries.
-
getImplicitClasspathEntryList
@Deprecated public java.util.List<java.lang.String> 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.
-
write
@Deprecated public void write(java.lang.String outputFile, boolean useRelativePaths, java.lang.String relativeBase) throws java.io.IOExceptionDeprecated.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:
java.io.IOException- if an error occurs while writing
-
readXML
public static Project readXML(java.io.File f) throws java.io.IOException, org.xml.sax.SAXException
- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
writeXML
public void writeXML(java.io.File f, @CheckForNull BugCollection bugCollection) throws java.io.IOException- Throws:
java.io.IOException
-
readProject
public static Project readProject(java.lang.String argument) throws java.io.IOException
Read Project from named file.- Parameters:
argument- command line argument containing project file name- Returns:
- the Project
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
Convert to a string in a nice (displayable) format.- Overrides:
toStringin classjava.lang.Object
-
transformFilename
public static java.lang.String transformFilename(java.lang.String fileName)
Transform a user-entered filename into a proper filename, by adding the ".fb" file extension if it isn't already present.
-
writeXML
public void writeXML(XMLOutput xmlOutput) throws java.io.IOException
Description copied from interface:XMLWriteableWrite this object to given XMLOutput.- Specified by:
writeXMLin interfaceXMLWriteable- Parameters:
xmlOutput- the XMLOutput for the document- Throws:
java.io.IOException
-
writeXML
public void writeXML(XMLOutput xmlOutput, @CheckForNull java.io.File destination, @CheckForNull BugCollection bugCollection) throws java.io.IOException
- Throws:
java.io.IOException
-
setTimestamp
public void setTimestamp(long timestamp)
Make the given list of pathnames absolute relative to the absolute path of the project file. private void makeListAbsoluteProject(Listlist) { List replace = new LinkedList (); for (String fileName : list) { fileName = convertToAbsolute(fileName); replace.add(fileName); } list.clear(); list.addAll(replace); }
-
addTimestamp
public void addTimestamp(long timestamp)
-
getTimestamp
public long getTimestamp()
-
setProjectName
public void setProjectName(java.lang.String projectName)
-
getProjectName
public java.lang.String getProjectName()
-
setSuppressionFilter
public void setSuppressionFilter(@Nonnull Filter suppressionFilter)
-
getSuppressionFilter
@Nonnull public Filter getSuppressionFilter()
-
setGuiCallback
public void setGuiCallback(IGuiCallback guiCallback)
-
getGuiCallback
public IGuiCallback getGuiCallback()
-
getResolvedSourcePaths
public java.lang.Iterable<java.lang.String> getResolvedSourcePaths()
-
-