Oracle

com.compoze.util
Class ClassPath

java.lang.Object
  extended by com.compoze.util.ClassPath

public class ClassPath
extends java.lang.Object

This class wraps access to the entries in the Java CLASSPATH.


Nested Class Summary
 class ClassPath.ClassPathIterator
          This is an iterator that iterates over the entries in the classpath.
 
Constructor Summary
ClassPath()
          Constructor.
ClassPath(java.lang.String sClasspath)
          Constructor.
 
Method Summary
 void addExclude(java.lang.String sExclude)
          Add a class or package to exclude.
 void addInclude(java.lang.String sInclude)
          Add a class or package to include.
 java.util.Iterator classIterator()
          Gets an iterator over the classes.
 java.util.Iterator classNamesIterator()
          Gets an iterator over the class names.
static java.lang.String[] getAllClassNames(java.lang.String sEntry)
          Get the names of all classes in the given classpath entry (could be a zip/jar or a directory).
 byte[] getClassBytes(java.lang.String sClassName)
          Gets the bytes for a class.
 java.lang.Class[] getClassesInPackages(java.lang.String[] packages)
          Get all of the classes in a package.
 java.io.InputStream getResourceAsStream(java.lang.String sResource)
          Gets a resource as a stream.
 byte[] getResourceBytes(java.lang.String sResource)
          Gets the resource as a byte array.
 java.util.zip.ZipFile getZipFile(java.lang.String sName)
          Get a zip file.
static void main(java.lang.String[] args)
          Exerciser.
static java.lang.String[] tokenizeClassPath(java.lang.String sClasspath)
          Separate a CLASSPATH out into its individual entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassPath

public ClassPath()
Constructor. Use the java.class.path system property as the CLASSPATH.


ClassPath

public ClassPath(java.lang.String sClasspath)
Constructor.

Parameters:
sClasspath - the CLASSPATH
Method Detail

addExclude

public void addExclude(java.lang.String sExclude)
Add a class or package to exclude.

Parameters:
sExclude - a class or package to exclude

addInclude

public void addInclude(java.lang.String sInclude)
Add a class or package to include.

Parameters:
sInclude - a class or package to include

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String sResource)
                                        throws java.io.IOException
Gets a resource as a stream.

Throws:
java.io.IOException

getResourceBytes

public byte[] getResourceBytes(java.lang.String sResource)
                        throws java.io.IOException
Gets the resource as a byte array.

Throws:
java.io.IOException

getClassBytes

public byte[] getClassBytes(java.lang.String sClassName)
                     throws java.io.IOException
Gets the bytes for a class.

Throws:
java.io.IOException

getClassesInPackages

public java.lang.Class[] getClassesInPackages(java.lang.String[] packages)
Get all of the classes in a package.

Parameters:
sPackage - the package to get classes in

getZipFile

public java.util.zip.ZipFile getZipFile(java.lang.String sName)
                                 throws java.io.IOException
Get a zip file. Create a new one only if necessary.

Returns:
the zip file
Throws:
java.io.IOException

classNamesIterator

public java.util.Iterator classNamesIterator()
Gets an iterator over the class names. Not yet implemented.

Returns:
an iterator over the class names

classIterator

public java.util.Iterator classIterator()
Gets an iterator over the classes. Not yet implemented.

Returns:
an iterator over the classes

getAllClassNames

public static java.lang.String[] getAllClassNames(java.lang.String sEntry)
Get the names of all classes in the given classpath entry (could be a zip/jar or a directory).

Returns:
the names of all of the classes

tokenizeClassPath

public static java.lang.String[] tokenizeClassPath(java.lang.String sClasspath)
Separate a CLASSPATH out into its individual entries.

Parameters:
sClasspath - the classpath
Returns:
the classpath separated out

main

public static void main(java.lang.String[] args)
Exerciser.

Parameters:
args - command line arguments

Oracle

Copyright ©1999-2008 Oracle All rights reserved.