/*
 * GenericFactory.java
 *
 * Created on September 17, 2002, 8:26 AM
 * 
 */
package org.apache.commons.collections;

/**
 *
 * This is a simple GenericFactory that uses reflection to 
 * instantiate a new object that will populate a lazyList
 *
 * @author  <a href="mailto:mail@phase.ws">Brandon Goodin</a>
 */
public class GenericFactory implements Factory {
    
    private String className;
    private Object object;
    
    /**
    *  Create a new instance of GenericFactory
    *  
    *  @param className value is a fully qualified class name of 
    *  the class the create method will instantiate
    *
    **/
    public GenericFactory(String className) {
        this.className = className;
    }
    
    /**
    *
    * Returns object to calling method
    *
    */
    public Object create() {
      try {
          object = null;
          Class classDefinition = Class.forName(className);
          object = classDefinition.newInstance();
      } catch (InstantiationException ex) {
           System.out.println( "ERROR: Exception: " + ex );
      } catch (IllegalAccessException ex) {
           System.out.println( "ERROR: Exception: " + ex );
      } catch (ClassNotFoundException ex) {
           System.out.println( "ERROR: Exception: " + ex );
      }
      return object;
   
    }
    
}

