edu.umd.cs.findbugs
Class URLClassPath

java.lang.Object
  extended by edu.umd.cs.findbugs.URLClassPath
All Implemented Interfaces:
java.io.Serializable

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

Nested Class Summary
private static interface URLClassPath.Entry
          Interface describing a single classpath entry.
private static class URLClassPath.LocalArchiveEntry
          Classpath entry class to load files from a zip/jar file in the local filesystem.
private static class URLClassPath.LocalDirectoryEntry
          Classpath entry class to load files from a directory in the local filesystem.
private static class URLClassPath.RemoteArchiveEntry
          Classpath entry class to load files from a remote archive URL.
private static class URLClassPath.RemoteDirectoryEntry
          Classpath entry class to load files from a remote directory URL.
 
Field Summary
private  java.util.List<URLClassPath.Entry> entryList
           
 
Constructor Summary
URLClassPath()
          Constructor.
 
Method Summary
 void addURL(java.lang.String fileName)
          Add given filename/URL to the classpath.
 java.lang.String getClassPath()
          Return the classpath string.
 java.io.InputStream getInputStreamForResource(java.lang.String resourceName)
          Open a stream to read given resource.
 org.apache.bcel.classfile.JavaClass lookupClass(java.lang.String className)
          Look up a class from the classpath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entryList

private java.util.List<URLClassPath.Entry> entryList
Constructor Detail

URLClassPath

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

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

getInputStreamForResource

public java.io.InputStream getInputStreamForResource(java.lang.String resourceName)
                                              throws java.io.IOException
Open a stream to read given resource.

Parameters:
resourceName - name of resource to load, e.g. "java/lang/Object.class"
Returns:
input stream to read resource, or null if resource could not be found
Throws:
java.io.IOException - if an IO error occurs trying to determine whether or not the resource exists

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
org.apache.bcel.classfile.ClassFormatException - if the classfile format is invalid