org.clazzes.util.reflect
Class PackageHelper

java.lang.Object
  extended by org.clazzes.util.reflect.PackageHelper

public abstract class PackageHelper
extends java.lang.Object

This class provides static functionality for handling java packages.

Author:
wglas

Constructor Summary
PackageHelper()
           
 
Method Summary
static java.util.List<java.lang.Class> getPackageClasses(java.lang.Class clazz)
          Return a list of classes, which reside in the same package an on the same classpath entry than the given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackageHelper

public PackageHelper()
Method Detail

getPackageClasses

public static java.util.List<java.lang.Class> getPackageClasses(java.lang.Class clazz)
                                                         throws java.lang.ClassNotFoundException
Return a list of classes, which reside in the same package an on the same classpath entry than the given class. Please note, that due to the nature of the java class loading mechanism it is impossible to find all classes, which belong to a package, that is spread over several jar files or classpath directories. Furthermore it is impossible to implement this method without a given concrete class, because some jar files do not contain a zip entry representing the package directory itself. (Most notably, rt.jar from the JRE itself) The returned list does not include inner classes, because these may be retrieved through Class.getClasses() anyways.

Parameters:
clazz - The class for which to retrieve all siblings.
Returns:
A list of classes, which are on the same package than the given class.
Throws:
java.lang.ClassNotFoundException


Copyright © 2009. All Rights Reserved.