KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openuss > utility > ClassUtility


1 /**
2  * Title: OpenUSS - Open Source University Support System
3  * Description: Utility for OpenUSS
4  * Copyright: Copyright (c) B. Lofi Dewanto
5  * Company: University of Muenster
6  * @author B. Lofi Dewanto
7  * @version 1.0
8  */

9 package org.openuss.utility;
10
11 import java.util.*;
12
13
14 /**
15  * Utility for classes.
16  *
17  * @author B. Lofi Dewanto
18  * @version 1.0
19  */

20 public class ClassUtility {
21     /**
22      * Create an object from the classname and its package.
23      */

24     public static Object JavaDoc createClass(String JavaDoc policyName, String JavaDoc packageName)
25                               throws Exception JavaDoc {
26         // Put the package name
27
String JavaDoc className = policyName;
28         String JavaDoc fullClassName = packageName.concat(".").concat(className);
29
30         Class JavaDoc objectClass = null;
31         Object JavaDoc result = null;
32
33
34         // Create the policy
35
objectClass = Class.forName(fullClassName);
36         result = objectClass.newInstance();
37
38         // Result
39
return result;
40     }
41 }
Popular Tags