|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.mdr.handlers; import org.netbeans.mdr.util.ImplGenerator; import java.io.*; import java.lang.reflect.Method; import java.util.*; /** * * @author Martin Matula * @version */ public class StructGenerator extends ImplGenerator { private static final String GET_PREFIX = "get"; //NOI18N private static final String IS_PREFIX = "is"; //NOI18N private static final String M_GET_NAME = "handleGet"; //NOI18N private static final String M_GET_DESC = "(Ljava/lang/String;)Ljava/lang/Object;"; //NOI18N private static final String CONSTRUCTOR_DESCRIPTOR = "(Ljava/util/List;Ljava/util/Map;Ljava/util/List;)V"; //NOI18N private StructGenerator(String className, Class ifc) { super(className, ifc, StructImpl.class); } public static byte[] generateStruct(final String name, Class ifc) { StructGenerator gen = new StructGenerator(name, ifc); final byte[] classFile = gen.generateClassFile(); return classFile; } protected Method[] getMethodsToImplement() { Method ifcMethods[] = ifc.getMethods(); Method objMethods[] = javax.jmi.reflect.RefStruct.class.getMethods(); HashSet excludeMethods = new HashSet(); ArrayList methodsToImplement = new ArrayList(); for (int i = 0; i < objMethods.length; i++) { excludeMethods.add(objMethods[i].getName() + getMethodDescriptor(objMethods[i].getParameterTypes(), objMethods[i].getReturnType())); } for (int i = 0; i < ifcMethods.length; i++) { if (!excludeMethods.contains(ifcMethods[i].getName() + getMethodDescriptor(ifcMethods[i].getParameterTypes(), ifcMethods[i].getReturnType()))) { methodsToImplement.add(ifcMethods[i]); } } return (Method[]) methodsToImplement.toArray(new Method[0]); } /** * Generate the constructor method for the proxy class. */ protected MethodInfo generateConstructor() throws IOException { MethodInfo minfo = new MethodInfo( " |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.