KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > spec > delivery > OrderFormFactory


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: OrderFormFactory.java,v 1.1 2004/05/19 18:15:19
18  */

19 package com.lutris.airsent.spec.delivery;
20
21 import java.lang.reflect.Constructor JavaDoc;
22
23
24 public class OrderFormFactory {
25     
26     /**
27      * Constructor can't be used.
28      */

29     private OrderFormFactory() {
30     }
31
32     /**
33      * Create a OrderForm as state object/value object/data transfer object
34      */

35     public static OrderForm getOrderForm(String JavaDoc fullClassName) {
36         
37         OrderForm result = null;
38        
39         Class JavaDoc objectClass = null;
40
41         try {
42             // Create the value object
43

44       
45          objectClass = Class.forName(fullClassName);
46                                    
47           result = (OrderForm)objectClass.newInstance();
48                             
49        } catch (Exception JavaDoc ex) {
50             System.out.println("Error on creating the object" + ex);
51        }
52
53         return result;
54     }
55  /**
56      * Create a OrderForm as state object/value object/data transfer object
57      */

58     public static OrderForm getOrderForm(String JavaDoc fullClassName,Delivery d) {
59         
60         OrderForm result = null;
61        
62         Class JavaDoc objectClass = null;
63
64         try {
65             // Create the value object
66

67       
68          objectClass = Class.forName(fullClassName);
69          
70          Class JavaDoc[] parameterTypes ={Class.forName("com.lutris.airsent.business.delivery.DeliveryImpl")};
71          
72                    
73          Constructor JavaDoc constr = objectClass.getConstructor(parameterTypes);
74         
75          
76         Object JavaDoc[] objects ={d};
77     
78        
79         
80          Object JavaDoc obj = constr.newInstance(objects);
81    
82       return (OrderForm)obj;
83                         
84                     
85       } catch (Exception JavaDoc ex) {
86             System.out.println("Error on creating the object" + ex);
87         }
88
89         return result;
90     }
91      
92     
93     
94     
95     
96     
97     
98 }
Popular Tags