ch.elca.el4j.util.classpath
Class DuplicateClassFinder

java.lang.Object
  extended by ch.elca.el4j.util.classpath.DuplicateClassFinder

public class DuplicateClassFinder
extends Object

A tool for looking up duplicate class definitions in the classpath. It can also be used to inspect all class definitions loaded.

Author:
David Bernhard (DBD)
File-location:
DuplicateClassFinder
Last check-in date:
2009-08-04 14:25:40 +0200 (Di, 04. Aug 2009) by swismer for revision 3874

Constructor Summary
DuplicateClassFinder()
          Default constructor - initialize the members.
 
Method Summary
 void addClass(Class<?> c)
          Add a class's classloader search path.
 void addSystemClassPath()
          Add the system class path to the search path.
 void addUrl(URL url)
          Add an URL to the search path.
 void addURLClassLoader(URLClassLoader cl)
          Add all URLs of a given classloader to the search path.
 boolean duplicatesFound()
           
 Set<String> getAllClasses()
           
 Set<String> getAllDuplicates()
           
 List<String> getLocations(String name)
          Returns all locations a class is defined at.
 boolean hasClass(String name)
          Looks up whether a class name exists.
 void report()
          Display the search results.
 void search()
          Search the added urls for classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DuplicateClassFinder

public DuplicateClassFinder()
Default constructor - initialize the members.

Method Detail

addUrl

public void addUrl(URL url)
Add an URL to the search path.

Parameters:
url - The URL to add.

addURLClassLoader

public void addURLClassLoader(URLClassLoader cl)
Add all URLs of a given classloader to the search path.

Parameters:
cl - The classloader.

addClass

public void addClass(Class<?> c)
Add a class's classloader search path. If the class is loaded by an URLClassLoader, add its URLs. If not, add the system classpath.

Parameters:
c - The class to add.

addSystemClassPath

public void addSystemClassPath()
Add the system class path to the search path.


search

public void search()
Search the added urls for classes.


report

public void report()
Display the search results.


getAllClasses

public Set<String> getAllClasses()
Returns:
all found classes

hasClass

public boolean hasClass(String name)
Looks up whether a class name exists.

Parameters:
name - The fully qualified class name.
Returns:
boolean.

getLocations

public List<String> getLocations(String name)
Returns all locations a class is defined at.

Parameters:
name - The class name.
Returns:
A list of locations.

duplicatesFound

public boolean duplicatesFound()
Returns:
Whether any duplicates were found.

getAllDuplicates

public Set<String> getAllDuplicates()
Returns:
A set of strings describing duplicated classes.


Copyright © 2005-2011 ELCA. All Rights Reserved.