edu.umd.cs.findbugs.ba

Class URLClassPath

public class URLClassPath extends Object implements 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

Constructor Summary
URLClassPath()
Constructor.
Method Summary
voidaddURL(String fileName)
Add given filename/URL to the classpath.
voidclose()
Close all underlying resources.
StringgetClassPath()
Return the classpath string.
static StringgetFileExtension(String fileName)
Get the file extension of given fileName.
static StringgetURLProtocol(String urlString)
Get the URL protocol of given URL string.
static booleanisArchiveExtension(String fileExtension)
Determine if given file extension indicates an archive file.
JavaClasslookupClass(String className)
Look up a class from the classpath.

Constructor Detail

URLClassPath

public URLClassPath()
Constructor. Creates a classpath with no elements.

Method Detail

addURL

public void addURL(String fileName)
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: IOException if entry is invalid or does not exist

close

public void close()
Close all underlying resources.

getClassPath

public String getClassPath()
Return the classpath string.

Returns: the classpath string

getFileExtension

public static String getFileExtension(String fileName)
Get the file extension of given fileName.

Returns: the file extension, or null if there is no file extension

getURLProtocol

public static String getURLProtocol(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

isArchiveExtension

public static boolean isArchiveExtension(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

lookupClass

public JavaClass lookupClass(String className)
Look up a class from the classpath.

Parameters: className name of class to look up

Returns: the JavaClass object for the class

Throws: ClassNotFoundException if the class couldn't be found ClassFormatException if the classfile format is invalid

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.