FileDocCategorySizeDatePackage
ClassLoaderRepository.javaAPI DocJava SE 6 API5071Tue Jun 10 00:22:24 BST 2008com.sun.org.apache.bcel.internal.util

ClassLoaderRepository

public class ClassLoaderRepository extends Object implements Repository
The repository maintains information about which classes have been loaded. It loads its data from the ClassLoader implementation passed into its constructor.
see
com.sun.org.apache.bcel.internal.Repository
version
$Id: ClassLoaderRepository.java,v 1.1.2.1 2005/07/31 23:47:01 jeffsuttor Exp $
author
M. Dahm
author
David Dixon-Peugh

Fields Summary
private ClassLoader
loader
private HashMap
loadedClasses
Constructors Summary
public ClassLoaderRepository(ClassLoader loader)

 // CLASSNAME X JAVACLASS

       
    this.loader = loader;
  
Methods Summary
public voidclear()
Clear all entries from cache.

    loadedClasses.clear();
  
public com.sun.org.apache.bcel.internal.classfile.JavaClassfindClass(java.lang.String className)
Find an already defined JavaClass.

    if ( loadedClasses.containsKey( className )) {
      return (JavaClass) loadedClasses.get( className );
    } else {
      return null;
    }
  
public com.sun.org.apache.bcel.internal.classfile.JavaClassloadClass(java.lang.String className)
Lookup a JavaClass object from the Class Name provided.

    String classFile = className.replace('.", '/");

    JavaClass RC = findClass( className );
    if (RC != null) { return RC; }

    try {
      InputStream is = 
	loader.getResourceAsStream( classFile + ".class" );
	    
      if(is == null) {
	throw new ClassNotFoundException(className + " not found.");
      }

      ClassParser parser = new ClassParser( is, className );
      RC = parser.parse();
	    
      storeClass( RC );

      return RC;
    } catch (IOException e) {
      throw new ClassNotFoundException( e.toString() );
    }
  
public com.sun.org.apache.bcel.internal.classfile.JavaClassloadClass(java.lang.Class clazz)

    return loadClass(clazz.getName());
  
public voidremoveClass(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz)
Remove class from repository

    loadedClasses.remove(clazz.getClassName());
  
public voidstoreClass(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz)
Store a new JavaClass into this Repository.

    loadedClasses.put( clazz.getClassName(),
		       clazz );
    clazz.setRepository( this );