classpathhelper
Class Package

java.lang.Object
  extended byclasspathhelper.Package

public class Package
extends java.lang.Object

Class that represents information on the classpath that is aggregated at the Java package level. Packages can span locations and class loaders.

Note

If a location contains a class a.b.c.SomeClass that location clearly contains the package a.b.c, however it is also considered to contain packages a and a.b as well (even though those packages contain only subpackages and no content for this location.

Since:
1.2
Author:
bharris

Constructor Summary
protected Package(CGClassLoader theClassLoader, PackageStore theCache, java.lang.String theName)
          Internal constructor typically created by CGClassLoader or Location objects.
 
Method Summary
protected  void addLocationsFromClassLoader(java.util.Set retVal, CGClassLoader classLoader, PackageStore cache)
          Adds locations for this package for a specific classloader.
 Package findPackage(java.lang.String packageName)
          Finds a specific sub package
 ContentDescription[] getBlockedContent()
           
 ContentDescription[] getBlockedContentWithDifferentByteCode()
           
 ContentDescription[] getContents()
           
 Location[] getLocations()
           
 java.lang.String getName()
           
 ClassDescription[] getNotFoundDependentClasses()
           
 Package[] getPackages(boolean includeSub)
           
 java.lang.String getSubName()
           
 boolean isSubPackage(Package other)
          Is other a subpackage of this package.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Package

protected Package(CGClassLoader theClassLoader,
                  PackageStore theCache,
                  java.lang.String theName)
Internal constructor typically created by CGClassLoader or Location objects.

Parameters:
theClassLoader - The class loader this package is in.
theCache - The cache used to find/create sub packages.
theName - The fully qualified name of this package.
Since:
1.2
Method Detail

getName

public java.lang.String getName()
Returns:
The fully qualified name of this package (e.g. a.b.c).
Since:
1.2

getSubName

public java.lang.String getSubName()
Returns:
The last segment of the package name (e.g. if package is a.b.c the subName would be c).
Since:
1.2

getPackages

public Package[] getPackages(boolean includeSub)
Parameters:
includeSub - Whether or not to include all recursive sub packages true or just the immediate child packages false. (e.g. should package a return a.b.c as well as a.b.
Returns:
The packages underneith this package.
Since:
1.2

findPackage

public Package findPackage(java.lang.String packageName)
Finds a specific sub package

Parameters:
packageName - The package relative to this package.
Returns:
The subpackage or null if the subpackage cannot be found.
Since:
1.2

getContents

public ContentDescription[] getContents()
Returns:
The contents of this package.
Since:
1.2

getLocations

public Location[] getLocations()
Returns:
The locations this package is located at.
Since:
1.2

isSubPackage

public boolean isSubPackage(Package other)
Is other a subpackage of this package.

Parameters:
other - The other package.
Returns:
true if other is a subpackage of this, otherwise false.
Since:
1.2

getNotFoundDependentClasses

public ClassDescription[] getNotFoundDependentClasses()
Returns:
A list of classes that classes in this package depend on but are not found on the classpath.
Since:
1.2

getBlockedContent

public ContentDescription[] getBlockedContent()
Returns:
A list of content in this package that is available in multiple locations on this classpath (with the same bytes).
Since:
1.2

getBlockedContentWithDifferentByteCode

public ContentDescription[] getBlockedContentWithDifferentByteCode()
Returns:
A list of content that is located in this package that is available at multiple locations with different bytes.
Since:
1.2

toString

public java.lang.String toString()

addLocationsFromClassLoader

protected void addLocationsFromClassLoader(java.util.Set retVal,
                                           CGClassLoader classLoader,
                                           PackageStore cache)
Adds locations for this package for a specific classloader.

Parameters:
retVal - The current set of locations.
classLoader - The classloader to load from.
cache - The cache used for creating packages.
Since:
1.2