org.exolab.castor.xml.util.resolvers
Class ResolveHelpers

java.lang.Object
  extended by org.exolab.castor.xml.util.resolvers.ResolveHelpers

public final class ResolveHelpers
extends java.lang.Object

Some helpers used by the resolver commands. This is a utility class which is NOT meant to be instantiated.

Since:
1.2
Version:
$Revision$ $Date$
Author:
Joachim Grueneis

Method Summary
static java.lang.ClassLoader getClassLoader(java.lang.ClassLoader loader)
          Gets the ClassLoader that's actually to be used (e.g.
static java.lang.String getPackageName(java.lang.String className)
          Gets the package name of the given class name.
static java.lang.String getQualifiedFileName(java.lang.String fileName, java.lang.String packageName)
          Qualifies the given fileName with the given packageName and returns the resulting file path.
If packageName is null or a zero-length String, this method will return fileName.
static java.lang.Class loadClass(java.lang.ClassLoader classLoader, java.lang.String className)
          Capsulates the ClassLoader.loadClass method to throw no exceptions but return null instead.
static boolean namespaceEquals(java.lang.String ns1, java.lang.String ns2)
          Compares the two strings for equality.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getQualifiedFileName

public static java.lang.String getQualifiedFileName(java.lang.String fileName,
                                                    java.lang.String packageName)
Qualifies the given fileName with the given packageName and returns the resulting file path.
If packageName is null or a zero-length String, this method will return fileName.

Parameters:
fileName - The file name to be qualified.
packageName - The package name to be used for qualifying.
Returns:
The qualified file path.

getPackageName

public static java.lang.String getPackageName(java.lang.String className)
Gets the package name of the given class name.

Parameters:
className - The class name to retrieve the package name from.
Returns:
The package name or the empty String if className is null or does not contain a package.

namespaceEquals

public static boolean namespaceEquals(java.lang.String ns1,
                                      java.lang.String ns2)
Compares the two strings for equality. A Null and empty strings are considered equal.

Returns:
true if the two strings are considered equal.

getClassLoader

public static java.lang.ClassLoader getClassLoader(java.lang.ClassLoader loader)
Gets the ClassLoader that's actually to be used (e.g. for loading resources).
The actual ClassLoader is determined in the following way:
  • If the passed in "preferred" loader is not null, it is used.
  • If the loader of this XMLClassDescriptor is not null, it is used.
  • The context class loader of the current thread is used.

    Parameters:
    loader - The "preferred" ClassLoader.
    Returns:
    The loader to be used.

  • loadClass

    public static java.lang.Class loadClass(java.lang.ClassLoader classLoader,
                                            java.lang.String className)
    Capsulates the ClassLoader.loadClass method to throw no exceptions but return null instead. Any exception caught are logged with info severity.

    Parameters:
    classLoader - the class loader to use
    className - the class to load
    Returns:
    the loaded Class or null


    Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com