KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > calculator > spec > StateFactory


1 /*
2  * calculator
3  *
4  * Enhydra super-servlet specification object
5  *
6  */

7 package calculator.spec;
8
9 import com.lutris.util.KeywordValueException;
10
11 public class StateFactory {
12     
13     /**
14      * Constructor can't be used.
15      */

16     private StateFactory() {
17     }
18
19     /**
20      * Create a State as state object/value object/data transfer object
21      */

22     public static State getState(String JavaDoc fullClassName) throws KeywordValueException{
23         
24         State result = null;
25        
26         Class JavaDoc objectClass = null;
27
28         try {
29             // Create the value object
30

31       
32          objectClass = Class.forName(fullClassName);
33                                    
34           result = (State)objectClass.newInstance();
35                
36                        
37                     
38       } catch (Exception JavaDoc ex) {
39             System.out.println("Error on creating the object" + ex);
40         }
41
42         return result;
43     }
44 }
Popular Tags