Class SingleFileCodeBase
java.lang.Object
edu.umd.cs.findbugs.classfile.impl.SingleFileCodeBase
- All Implemented Interfaces:
ICodeBase, IScannableCodeBase, AutoCloseable
Implementation of ICodeBase for a single classfile.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ICodeBase
ICodeBase.Discovered -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ICodeBaseLocatorprivate final Stringprivate ICodeBase.Discoveredprivate booleanprivate longprivate Stringprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()This method should be called when done using the code base.booleanReturn whether or not this code base contains any source files.(package private) ClassDescriptorGet the codebase locator describing the location of this codebase.Return how this codebase was discovered.longGet timestamp indicating the most recent time when any of the files in the codebase were modified.(package private) intReturn the number of bytes in the file.Get the filesystem pathname of this codebase.(package private) StringGet the resource name of the single file.booleanReturn whether or not this codebase is an application codebase.iterator()Get an iterator over the resources in the this code base.lookupResource(String resourceName) Look up a resource in this code base.(package private) InputStreamopenFile()voidsetApplicationCodeBase(boolean isAppCodeBase) Designate this code base as an application codebase.voidsetHowDiscovered(ICodeBase.Discovered howDiscovered) Set how this codebase was discovered.voidsetLastModifiedTime(long lastModifiedTime) Set timestamp indicating the most recent time when any of the files in the codebase were modified.toString()
-
Field Details
-
codeBaseLocator
-
fileName
-
isAppCodeBase
private boolean isAppCodeBase -
howDiscovered
-
lastModifiedTime
private long lastModifiedTime -
resourceNameKnown
private boolean resourceNameKnown -
resourceName
-
-
Constructor Details
-
SingleFileCodeBase
-
-
Method Details
-
toString
-
getCodeBaseLocator
Description copied from interface:ICodeBaseGet the codebase locator describing the location of this codebase.- Specified by:
getCodeBaseLocatorin interfaceICodeBase- Returns:
- the ICodeBaseLocator
-
containsSourceFiles
Description copied from interface:ICodeBaseReturn whether or not this code base contains any source files.- Specified by:
containsSourceFilesin interfaceICodeBase- Returns:
- true if the code base contains source file(s), false if it does not contain source files
- Throws:
InterruptedException
-
iterator
Description copied from interface:IScannableCodeBaseGet an iterator over the resources in the this code base.- Specified by:
iteratorin interfaceIScannableCodeBase- Returns:
- ICodeBaseIterator over the resources in the code base
- Throws:
InterruptedException
-
lookupResource
Description copied from interface:ICodeBaseLook up a resource in this code base.- Specified by:
lookupResourcein interfaceICodeBase- Parameters:
resourceName- name of the resource to look up- Returns:
- ICodeBaseEntry representing the resource or null if the resource cannot be found in this code base
-
setApplicationCodeBase
public void setApplicationCodeBase(boolean isAppCodeBase) Description copied from interface:ICodeBaseDesignate this code base as an application codebase.- Specified by:
setApplicationCodeBasein interfaceICodeBase- Parameters:
isAppCodeBase- true if this is an application codebase, false if not
-
isApplicationCodeBase
public boolean isApplicationCodeBase()Description copied from interface:ICodeBaseReturn whether or not this codebase is an application codebase.- Specified by:
isApplicationCodeBasein interfaceICodeBase- Returns:
- true if this is an application codebase, false if not
-
setHowDiscovered
Description copied from interface:ICodeBaseSet how this codebase was discovered.- Specified by:
setHowDiscoveredin interfaceICodeBase- Parameters:
howDiscovered- one of the constants SPECIFIED, NESTED, IN_JAR_MANIFEST, or IN_SYSTEM_CLASSPATH
-
getHowDiscovered
Description copied from interface:ICodeBaseReturn how this codebase was discovered.- Specified by:
getHowDiscoveredin interfaceICodeBase- Returns:
- one of the constants SPECIFIED, NESTED, IN_JAR_MANIFEST, or IN_SYSTEM_CLASSPATH
-
setLastModifiedTime
public void setLastModifiedTime(long lastModifiedTime) Description copied from interface:ICodeBaseSet timestamp indicating the most recent time when any of the files in the codebase were modified.- Specified by:
setLastModifiedTimein interfaceICodeBase- Parameters:
lastModifiedTime- timestamp when any codebase files were most-recently modified
-
getLastModifiedTime
public long getLastModifiedTime()Description copied from interface:ICodeBaseGet timestamp indicating the most recent time when any of the files in the codebase were modified. This information is only likely to be accurate if an ICodeBaseIterator has been used to scan the resources in the codebase (scannable codebases only, obviously).- Specified by:
getLastModifiedTimein interfaceICodeBase- Returns:
- timestamp when any codebase files were most-recently modified, -1 if unknown
-
getPathName
Description copied from interface:ICodeBaseGet the filesystem pathname of this codebase.- Specified by:
getPathNamein interfaceICodeBase- Returns:
- the filesystem pathname of this codebase, or null if this codebase is not accessible via the filesystem
-
openFile
- Throws:
IOException
-
close
public void close()Description copied from interface:ICodeBaseThis method should be called when done using the code base.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceICodeBase
-
getResourceName
String getResourceName()Get the resource name of the single file. We have to open the file and parse the constant pool in order to find this out.- Returns:
- the resource name (e.g., "java/lang/String.class" if the class is java.lang.String)
-
getClassDescriptor
ClassDescriptor getClassDescriptor() throws ResourceNotFoundException, InvalidClassFileFormatException -
getNumBytes
int getNumBytes()Return the number of bytes in the file.- Returns:
- the number of bytes in the file, or -1 if the file's length can't be determined
-