org.davesag.generica.util
Class ObjectAssistant

java.lang.Object
  extended byorg.davesag.generica.util.ObjectAssistant

public class ObjectAssistant
extends Object

Useful helper methods for dynamically loading objects and properties.

Since:
Generica 1.0
Version:
CVS Revision $Id: ObjectAssistant.java,v 1.7 2004/04/02 20:11:43 davesag Exp $
Author:
Dave Sag http://www.davesag.com

Constructor Summary
ObjectAssistant()
           
 
Method Summary
static Object loadObjectByName(String name)
          Uses the default ClassLoader to load the named class, catches all the individual exceptions and rethrows as a more general ClassNotFoundException.
static Properties loadProperties(Class clazz, String filename)
          load the named properties file and return a populated Properties object.
static Properties loadProperties(String filename)
          load the named properties file and return a populated Properties object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectAssistant

public ObjectAssistant()
Method Detail

loadObjectByName

public static Object loadObjectByName(String name)
                               throws ClassNotFoundException
Uses the default ClassLoader to load the named class, catches all the individual exceptions and rethrows as a more general ClassNotFoundException.

Parameters:
name - The name of the class to load.
Returns:
the loaded Object.
Throws:
ClassNotFoundException - if anything went wrong.

loadProperties

public static Properties loadProperties(String filename)
                                 throws IOException
load the named properties file and return a populated Properties object.

Parameters:
filename - The name of the properties file relative to the root of the classpath.
Returns:
a populated Properties object, or null.
Throws:
IOException - if the properties could not be loaded.

loadProperties

public static Properties loadProperties(Class clazz,
                                        String filename)
                                 throws IOException
load the named properties file and return a populated Properties object.

Parameters:
clazz - any class in the current class path.
filename - The name of the properties file relative to the root of the classpath.
Returns:
a populated Properties object, or null.
Throws:
IOException - if the properties could not be loaded.


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.