com.mucommander.file
Class AbstractFileClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by com.mucommander.file.AbstractFileClassLoader

public class AbstractFileClassLoader
extends java.lang.ClassLoader

ClassLoader implementation capable of loading classes from instances of AbstractFile.

It's possible to modify this loader's classpath at runtime through the addFile(AbstractFile) method.

Author:
Nicolas Rinaudo

Constructor Summary
AbstractFileClassLoader()
          Creates a new AbstractFileClassLoader that uses the system classloader as a parent.
AbstractFileClassLoader(java.lang.ClassLoader parent)
          Creates a new AbstractFileClassLoader.
 
Method Summary
 void addFile(AbstractFile file)
          Adds the specified file to the class loader's classpath.
 boolean contains(AbstractFile file)
          Returns true if this loader's classpath already contains the specified file.
 java.util.Iterator files()
          Returns an iterator on all files in this loader's classpath.
protected  java.lang.Class findClass(java.lang.String name)
          Tries to find and load the specified class.
protected  java.lang.String findLibrary(java.lang.String name)
          Returns the absolute path of the requested library.
protected  java.net.URL findResource(java.lang.String name)
          Tries to find the requested resource.
protected  java.util.Enumeration findResources(java.lang.String name)
          Tries to find all the resources with the specified name.
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Returns an input stream on the requested resource.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFileClassLoader

public AbstractFileClassLoader(java.lang.ClassLoader parent)
Creates a new AbstractFileClassLoader.

Parameters:
parent - parent of the class loader.

AbstractFileClassLoader

public AbstractFileClassLoader()
Creates a new AbstractFileClassLoader that uses the system classloader as a parent.

Method Detail

addFile

public void addFile(AbstractFile file)
Adds the specified file to the class loader's classpath.

Note that the file will not be added if it's already in the classpath.

Parameters:
file - file to add the class loader's classpath.
Throws:
java.lang.IllegalArgumentException - if file is not browsable.

files

public java.util.Iterator files()
Returns an iterator on all files in this loader's classpath.

Returns:
an iterator on all files in this loader's classpath.

contains

public boolean contains(AbstractFile file)
Returns true if this loader's classpath already contains the specified file.

Parameters:
file - file to look for.
Returns:
true if this loader's classpath already contains the specified file.

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Returns an input stream on the requested resource.

Overrides:
getResourceAsStream in class java.lang.ClassLoader
Parameters:
name - name of the resource to open.
Returns:
an input stream on the requested resource, null if not found.

findResource

protected java.net.URL findResource(java.lang.String name)
Tries to find the requested resource.

Overrides:
findResource in class java.lang.ClassLoader
Parameters:
name - name of the resource to locate.
Returns:
the URL of the requested resource if found, null otherwise.

findResources

protected java.util.Enumeration findResources(java.lang.String name)
Tries to find all the resources with the specified name.

Overrides:
findResources in class java.lang.ClassLoader
Parameters:
name - of the resources to find.
Returns:
an enumeration containing the URLs of all the resources that match name.

findLibrary

protected java.lang.String findLibrary(java.lang.String name)
Returns the absolute path of the requested library.

Overrides:
findLibrary in class java.lang.ClassLoader
Parameters:
name - name of the library to load.
Returns:
the absolute path of the requested library if found, null otheriwse.

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Tries to find and load the specified class.

Overrides:
findClass in class java.lang.ClassLoader
Parameters:
name - fully qualified name of the class to load.
Returns:
the requested Class if found, null otherwise.
Throws:
java.lang.ClassNotFoundException - if the requested class was not found.


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard