Package edu.umd.cs.findbugs.ba
Class URLClassPath
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.URLClassPath
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.AutoCloseable
public class URLClassPath extends java.lang.Object implements java.lang.AutoCloseable, java.io.Serializable
A work-alike class to use instead of BCEL's ClassPath class. The main difference is that URLClassPath can load classfiles from URLs.- Author:
- David Hovemeyer
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description URLClassPath()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addURL(java.lang.String fileName)
Add given filename/URL to the classpath.void
close()
Close all underlying resources.java.lang.String
getClassPath()
Return the classpath string.static java.lang.String
getFileExtension(java.lang.String fileName)
Get the file extension of given fileName.static java.lang.String
getURLProtocol(java.lang.String urlString)
Get the URL protocol of given URL string.static boolean
isArchiveExtension(java.lang.String fileExtension)
Determine if given file extension indicates an archive file.org.apache.bcel.classfile.JavaClass
lookupClass(java.lang.String className)
Look up a class from the classpath.
-
-
-
Method Detail
-
addURL
public void addURL(java.lang.String fileName) throws java.io.IOException
Add given filename/URL to the classpath. If no URL protocol is given, the filename is assumed to be a local file or directory. Remote directories must be specified with a "/" character at the end of the URL.- Parameters:
fileName
- filename or URL of codebase (directory or archive file)- Throws:
java.io.IOException
- if entry is invalid or does not exist
-
getClassPath
public java.lang.String getClassPath()
Return the classpath string.- Returns:
- the classpath string
-
lookupClass
public org.apache.bcel.classfile.JavaClass lookupClass(java.lang.String className) throws java.lang.ClassNotFoundException
Look up a class from the classpath.- Parameters:
className
- name of class to look up- Returns:
- the JavaClass object for the class
- Throws:
java.lang.ClassNotFoundException
- if the class couldn't be found
-
close
public void close()
Close all underlying resources.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
getURLProtocol
public static java.lang.String getURLProtocol(java.lang.String urlString)
Get the URL protocol of given URL string.- Parameters:
urlString
- the URL string- Returns:
- the protocol name ("http", "file", etc.), or null if there is no protocol
-
getFileExtension
public static java.lang.String getFileExtension(java.lang.String fileName)
Get the file extension of given fileName.- Returns:
- the file extension, or null if there is no file extension
-
isArchiveExtension
public static boolean isArchiveExtension(java.lang.String fileExtension)
Determine if given file extension indicates an archive file.- Parameters:
fileExtension
- the file extension (e.g., ".jar")- Returns:
- true if the file extension indicates an archive, false otherwise
-
-