void generateFindMethodAndArgs(Method method, IndentedWriter iw) throws IOException { iw.println("Class[] argTypes = "); iw.println("{"); iw.upIndent(); Class[] argTypes = method.getParameterTypes(); for (int i = 0, len = argTypes.length; i < len; ++i) { if (i != 0) iw.println(","); iw.print(CodegenUtils.simpleClassName(argTypes[i]) + ".class"); } iw.println(); iw.downIndent(); iw.println("};"); iw.println( "Method method = Connection.class.getMethod( \042" + method.getName() + "\042 , argTypes );"); iw.println(); iw.println("Object[] args = "); iw.println("{"); iw.upIndent(); for (int i = 0, len = argTypes.length; i < len; ++i) { if (i != 0) iw.println(","); String argName = CodegenUtils.generatedArgumentName(i); Class argType = argTypes[i]; if (argType.isPrimitive()) { if (argType == boolean.class) iw.print("Boolean.valueOf( " + argName + " )"); else if (argType == byte.class) iw.print("new Byte( " + argName + " )"); else if (argType == char.class) iw.print("new Character( " + argName + " )"); else if (argType == short.class) iw.print("new Short( " + argName + " )"); else if (argType == int.class) iw.print("new Integer( " + argName + " )"); else if (argType == long.class) iw.print("new Long( " + argName + " )"); else if (argType == float.class) iw.print("new Float( " + argName + " )"); else if (argType == double.class) iw.print("new Double( " + argName + " )"); } else iw.print(argName); } iw.downIndent(); iw.println("};"); }
// Support JDBC4 Wrapper interface private static void generateIsWrapperHelperMethods(Class intfcl, IndentedWriter iw) throws IOException { iw.println("// helper methods for unwrap( ... ), isWrapperFor( ... )"); iw.println("private boolean isWrapperForInner( Class intfcl )"); iw.println( "{ return ( " + intfcl.getName() + ".class == intfcl || intfcl.isAssignableFrom( inner.getClass() ) ); }"); iw.println(); iw.println("private boolean isWrapperForThis( Class intfcl )"); iw.println("{ return intfcl.isAssignableFrom( this.getClass() ); }"); }