OrderFormFactory.java :  » J2EE » Enhydra-Demos » com » lutris » airsent » spec » delivery » Java Open Source

Java Open Source » J2EE » Enhydra Demos 
Enhydra Demos » com » lutris » airsent » spec » delivery » OrderFormFactory.java
/*
 * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
 * Reserved.
 * 
 * This source code file is distributed by Lutris Technologies, Inc. for
 * use only by licensed users of product(s) that include this source
 * file. Use of this source file or the software that uses it is covered
 * by the terms and conditions of the Lutris Enhydra Development License
 * Agreement included with this product.
 * 
 * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
 * ANY KIND, either express or implied. See the License for the specific terms
 * governing rights and limitations under the License.
 * 
 * Contributor(s):
 * 
 * $Id: OrderFormFactory.java,v 1.1 2004/05/19 18:15:19
 */
package com.lutris.airsent.spec.delivery;

import java.lang.reflect.Constructor;


public class OrderFormFactory {
    
    /**
     * Constructor can't be used.
     */
    private OrderFormFactory() {
    }

    /**
     * Create a OrderForm as state object/value object/data transfer object
     */
    public static OrderForm getOrderForm(String fullClassName) {
        
        OrderForm result = null;
       
        Class objectClass = null;

        try {
            // Create the value object
       
      
         objectClass = Class.forName(fullClassName);
                                   
          result = (OrderForm)objectClass.newInstance();
                            
       } catch (Exception ex) {
            System.out.println("Error on creating the object" + ex);
       }

        return result;
    }
 /**
     * Create a OrderForm as state object/value object/data transfer object
     */
    public static OrderForm getOrderForm(String fullClassName,Delivery d) {
        
        OrderForm result = null;
       
        Class objectClass = null;

        try {
            // Create the value object
       
      
         objectClass = Class.forName(fullClassName);
         
         Class[] parameterTypes ={Class.forName("com.lutris.airsent.business.delivery.DeliveryImpl")};
         
                   
         Constructor constr =  objectClass.getConstructor(parameterTypes);
        
         
        Object[] objects ={d};
    
       
        
         Object obj =   constr.newInstance(objects);
   
      return (OrderForm)obj;
                        
                    
      } catch (Exception ex) {
            System.out.println("Error on creating the object" + ex);
        }

        return result;
    }   
     
    
    
    
    
    
    
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.