com.sdm.quasar.client.core.common.util
Class ClassUtilities

java.lang.Object
  extended bycom.sdm.quasar.client.core.common.util.ClassUtilities

public class ClassUtilities
extends java.lang.Object

Provides various utility methods concerning files and the class path.

Version:
1.0
Author:
Thomas Wolf

Nested Class Summary
static interface ClassUtilities.ClassUtilitiesImplementation
          This is the interface that implementors must implement.
 
Method Summary
static boolean fileExistsInClassPath(java.lang.String filename)
          Tests, whether a file is accessible in the class path using the ClassLoader.getResourceAsStream(java.lang.String) method of the current thread class loader.
static java.lang.Class getClassForName(java.lang.String classname)
          Creates a Class for the class name specified.
static java.io.InputStream getResourceAsStream(java.lang.String resourcename)
          Returns the resource with the given name as InputStream.
static boolean isClassAssignableFrom(java.lang.Class superClassCandidate, java.lang.Class subClassCandidate)
          Checks, if the given superClassCandidate class is the same or a superclass or superinterface of the subClassCandidate class.
static java.lang.Object newInstance(java.lang.Class cls)
          Creates a new instance for the class given.
static void setClassUtilitiesImplementation(ClassUtilities.ClassUtilitiesImplementation classUtilitiesImplementation)
          Sets the ClassUtilities.ClassUtilitiesImplementation to be used by the ClassUtilities.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setClassUtilitiesImplementation

public static void setClassUtilitiesImplementation(ClassUtilities.ClassUtilitiesImplementation classUtilitiesImplementation)
Sets the ClassUtilities.ClassUtilitiesImplementation to be used by the ClassUtilities.

Parameters:
classUtilitiesImplementation -

fileExistsInClassPath

public static boolean fileExistsInClassPath(java.lang.String filename)
Tests, whether a file is accessible in the class path using the ClassLoader.getResourceAsStream(java.lang.String) method of the current thread class loader.

Parameters:
filename - the filename
Returns:
true, iff the file is accessible

getClassForName

public static java.lang.Class getClassForName(java.lang.String classname)
Creates a Class for the class name specified.

Parameters:
classname - the full qualified class name (not null)
Returns:
the Class object for the class name given
Throws:
java.lang.IllegalArgumentException - if the class with that name could not be found or if the class name is null

newInstance

public static java.lang.Object newInstance(java.lang.Class cls)
Creates a new instance for the class given. Normally should do something equal to Class.newInstance().

Parameters:
cls - the class to create an instance of (not null)
Returns:
the new created instance of cls
Throws:
java.lang.IllegalArgumentException - if no instance could be created of the given class or if the given class is null

isClassAssignableFrom

public static boolean isClassAssignableFrom(java.lang.Class superClassCandidate,
                                            java.lang.Class subClassCandidate)
Checks, if the given superClassCandidate class is the same or a superclass or superinterface of the subClassCandidate class. This method should work according to Class.isAssignableFrom(Class)

Parameters:
superClassCandidate - the super class or interface candidate to check (not null)
subClassCandidate - the sub class or interface candidate to check (not null)
Returns:
true if superClassCandidate is the same or a super class or super interface of subClassCandidate

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String resourcename)
Returns the resource with the given name as InputStream.

Parameters:
resourcename - the resource name
Returns:
the InputStream for the resource