01: /*
02: * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
03: * Reserved.
04: *
05: * This source code file is distributed by Lutris Technologies, Inc. for
06: * use only by licensed users of product(s) that include this source
07: * file. Use of this source file or the software that uses it is covered
08: * by the terms and conditions of the Lutris Enhydra Development License
09: * 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;
22:
23: public class OrderFormFactory {
24:
25: /**
26: * Constructor can't be used.
27: */
28: private OrderFormFactory() {
29: }
30:
31: /**
32: * Create a OrderForm as state object/value object/data transfer object
33: */
34: public static OrderForm getOrderForm(String fullClassName) {
35:
36: OrderForm result = null;
37:
38: Class objectClass = null;
39:
40: try {
41: // Create the value object
42:
43: objectClass = Class.forName(fullClassName);
44:
45: result = (OrderForm) objectClass.newInstance();
46:
47: } catch (Exception ex) {
48: System.out.println("Error on creating the object" + ex);
49: }
50:
51: return result;
52: }
53:
54: /**
55: * Create a OrderForm as state object/value object/data transfer object
56: */
57: public static OrderForm getOrderForm(String fullClassName,
58: Delivery d) {
59:
60: OrderForm result = null;
61:
62: Class objectClass = null;
63:
64: try {
65: // Create the value object
66:
67: objectClass = Class.forName(fullClassName);
68:
69: Class[] parameterTypes = { Class
70: .forName("com.lutris.airsent.business.delivery.DeliveryImpl") };
71:
72: Constructor constr = objectClass
73: .getConstructor(parameterTypes);
74:
75: Object[] objects = { d };
76:
77: Object obj = constr.newInstance(objects);
78:
79: return (OrderForm) obj;
80:
81: } catch (Exception ex) {
82: System.out.println("Error on creating the object" + ex);
83: }
84:
85: return result;
86: }
87:
88: }
|