01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: package org.netbeans.modules.sql.framework.codegen.base;
21:
22: import org.netbeans.modules.sql.framework.codegen.AbstractGeneratorFactory;
23: import org.netbeans.modules.sql.framework.codegen.Generator;
24: import com.sun.sql.framework.exception.BaseException;
25:
26: /**
27: * @author Ritesh Adval
28: * @author Ahimanikya Satapathy
29: * @version $Revision$
30: */
31: public class GeneratorHelper {
32:
33: public static Generator create(String className,
34: AbstractGeneratorFactory factory) throws BaseException {
35: Generator generator = null;
36: if (className != null) {
37: try {
38: Class cls = Class.forName(className);
39: generator = (Generator) cls.newInstance();
40: generator.setGeneratorFactory(factory);
41: } catch (ClassNotFoundException ex1) {
42: throw new BaseException(
43: "Cannot create an instance of generator of class "
44: + className, ex1);
45: } catch (InstantiationException ex2) {
46: throw new BaseException(
47: "Cannot create an instance of generator of class "
48: + className, ex2);
49: } catch (IllegalAccessException ex3) {
50: throw new BaseException(
51: "Cannot create an instance of generator of class "
52: + className, ex3);
53: }
54: }
55:
56: return generator;
57: }
58: }
|