Package org.apache.bcel.util
Class ClassPath
- java.lang.Object
-
- org.apache.bcel.util.ClassPath
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class ClassPath extends java.lang.Object implements java.io.Closeable
Responsible for loading (class) files from the CLASSPATH. Inspired by sun.tools.ClassPath.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ClassPath.ClassFile
Contains information about file/ZIP entry of the Java class.
-
Field Summary
Fields Modifier and Type Field Description static ClassPath
SYSTEM_CLASS_PATH
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
equals(java.lang.Object o)
byte[]
getBytes(java.lang.String name)
byte[]
getBytes(java.lang.String name, java.lang.String suffix)
ClassPath.ClassFile
getClassFile(java.lang.String name)
ClassPath.ClassFile
getClassFile(java.lang.String name, java.lang.String suffix)
static java.lang.String
getClassPath()
Checks for class path components in the following properties: "java.class.path", "sun.boot.class.path", "java.ext.dirs"java.io.InputStream
getInputStream(java.lang.String name)
java.io.InputStream
getInputStream(java.lang.String name, java.lang.String suffix)
Return stream for class or resource on CLASSPATH.java.lang.String
getPath(java.lang.String name)
java.lang.String
getPath(java.lang.String name, java.lang.String suffix)
java.net.URL
getResource(java.lang.String name)
java.io.InputStream
getResourceAsStream(java.lang.String name)
java.util.Enumeration<java.net.URL>
getResources(java.lang.String name)
int
hashCode()
java.lang.String
toString()
-
-
-
Field Detail
-
SYSTEM_CLASS_PATH
public static final ClassPath SYSTEM_CLASS_PATH
-
-
Constructor Detail
-
ClassPath
@Deprecated public ClassPath()
Deprecated.Use SYSTEM_CLASS_PATH constantSearch for classes in CLASSPATH.
-
ClassPath
public ClassPath(ClassPath parent, java.lang.String classPath)
-
ClassPath
public ClassPath(java.lang.String classPath)
Search for classes in given path.- Parameters:
classPath
-
-
-
Method Detail
-
getClassPath
public static java.lang.String getClassPath()
Checks for class path components in the following properties: "java.class.path", "sun.boot.class.path", "java.ext.dirs"- Returns:
- class path as used by default by BCEL
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
getBytes
public byte[] getBytes(java.lang.String name) throws java.io.IOException
- Returns:
- byte array for class
- Throws:
java.io.IOException
-
getBytes
public byte[] getBytes(java.lang.String name, java.lang.String suffix) throws java.io.IOException
- Parameters:
name
- fully qualified file name, e.g. java/lang/Stringsuffix
- file name ends with suffix, e.g. .java- Returns:
- byte array for file on class path
- Throws:
java.io.IOException
-
getClassFile
public ClassPath.ClassFile getClassFile(java.lang.String name) throws java.io.IOException
- Parameters:
name
- fully qualified class name, e.g. java.lang.String- Returns:
- input stream for class
- Throws:
java.io.IOException
-
getClassFile
public ClassPath.ClassFile getClassFile(java.lang.String name, java.lang.String suffix) throws java.io.IOException
- Parameters:
name
- fully qualified file name, e.g. java/lang/Stringsuffix
- file name ends with suff, e.g. .java- Returns:
- class file for the java class
- Throws:
java.io.IOException
-
getInputStream
public java.io.InputStream getInputStream(java.lang.String name) throws java.io.IOException
- Parameters:
name
- fully qualified class name, e.g. java.lang.String- Returns:
- input stream for class
- Throws:
java.io.IOException
-
getInputStream
public java.io.InputStream getInputStream(java.lang.String name, java.lang.String suffix) throws java.io.IOException
Return stream for class or resource on CLASSPATH.- Parameters:
name
- fully qualified file name, e.g. java/lang/Stringsuffix
- file name ends with suff, e.g. .java- Returns:
- input stream for file on class path
- Throws:
java.io.IOException
-
getPath
public java.lang.String getPath(java.lang.String name) throws java.io.IOException
- Parameters:
name
- name of file to search for, e.g. java/lang/String.java- Returns:
- full (canonical) path for file
- Throws:
java.io.IOException
-
getPath
public java.lang.String getPath(java.lang.String name, java.lang.String suffix) throws java.io.IOException
- Parameters:
name
- name of file to search for, e.g. java/lang/Stringsuffix
- file name suffix, e.g. .java- Returns:
- full (canonical) path for file, if it exists
- Throws:
java.io.IOException
-
getResource
public java.net.URL getResource(java.lang.String name)
- Parameters:
name
- fully qualified resource name, e.g. java/lang/String.class- Returns:
- URL supplying the resource, or null if no resource with that name.
- Since:
- 6.0
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String name)
- Parameters:
name
- fully qualified resource name, e.g. java/lang/String.class- Returns:
- InputStream supplying the resource, or null if no resource with that name.
- Since:
- 6.0
-
getResources
public java.util.Enumeration<java.net.URL> getResources(java.lang.String name)
- Parameters:
name
- fully qualified resource name, e.g. java/lang/String.class- Returns:
- An Enumeration of URLs supplying the resource, or an empty Enumeration if no resource with that name.
- Since:
- 6.0
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- used class path string
-
-