com.borland.primetime.util
Class Classes

java.lang.Object
  |
  +--com.borland.primetime.util.Classes

public class Classes
extends java.lang.Object

Some utilities for getting class info.


Constructor Summary
Classes()
           
 
Method Summary
static Url findPathUrl(Url[] classpath, java.lang.String className)
          Returns the first entry in a classpath that contains a given class
static java.lang.String getRootEntryFromClasspath(java.lang.Class c)
          Returns the entry in the classpath from which a class was loaded.
static java.lang.String getRootEntryFromClasspath(java.lang.String className)
          Returns the entry in the classpath from which a class was loaded.
static java.lang.String getShortName(java.lang.Class c)
          Returns the name of the class without the package, e.g.
static boolean pathContainsClass(Url[] classpath, java.lang.String className)
          Determines whether a class can be found in a given classpath
static java.lang.String toPath(java.lang.Class c)
          Converts a fully-qualified class name to the equivalent path by replacing the '.' characters with '/'
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Classes

public Classes()
Method Detail

getRootEntryFromClasspath

public static java.lang.String getRootEntryFromClasspath(java.lang.String className)
Returns the entry in the classpath from which a class was loaded. It will be either a jar file or directory name, suitable for insertion in another classpath.

Use this version of the method when you are unsure whether the class will be present.

Parameters:
className - name of class to query
Returns:
JAR file name or directory name, null if neither JAR nor directory or class not found

getRootEntryFromClasspath

public static java.lang.String getRootEntryFromClasspath(java.lang.Class c)
Returns the entry in the classpath from which a class was loaded. It will be either a jar file or directory name, suitable for insertion in another classpath.

Use this version of the method when you know the class should be present; otherwise, use getRootEntryFromClasspath(String)

Parameters:
c - Class to query
Returns:
JAR file name or directory name, null if neither JAR nor directory or class not found

getShortName

public static java.lang.String getShortName(java.lang.Class c)
Returns the name of the class without the package, e.g. File or JComponent. If passed a class representing an array, the name of the elements of that array is returned.
Parameters:
c - Class to query
Returns:
non-qualified class name

toPath

public static java.lang.String toPath(java.lang.Class c)
Converts a fully-qualified class name to the equivalent path by replacing the '.' characters with '/'
Parameters:
c - Class to convert
Returns:
name converted to path

pathContainsClass

public static boolean pathContainsClass(Url[] classpath,
                                        java.lang.String className)
Determines whether a class can be found in a given classpath
Parameters:
path - array of Urls that comprise the classpath. May be null or empty (in which case the method will always return false).
Returns:
whether the class is somewhere in the path

findPathUrl

public static Url findPathUrl(Url[] classpath,
                              java.lang.String className)
Returns the first entry in a classpath that contains a given class
Parameters:
path - array of Urls that comprise the classpath. May be null or empty (in which case the method will always return null).
Returns:
the Url that contains the class; null if the class is not found