private void importMethod(DbJVClass dbClaz, Method method) throws DbException { if (dbClaz == null) { return; } String methodName = method.getName(); boolean isConstructor = "<init>".equals(methodName); boolean isInitBlock = "<clinit>".equals(methodName); DbOOAbstractMethod oper = null; if (isInitBlock) { new DbJVInitBlock(dbClaz); } else if (isConstructor) { DbJVConstructor constr = new DbJVConstructor(dbClaz); importExceptions(constr, method); oper = constr; } else { // create method and return type DbJVMethod meth = new DbJVMethod(dbClaz); Type type = method.getReturnType(); meth.setReturnType(toAdt(type)); meth.setTypeUse(toTypeUse(type)); // set method modifiers meth.setAbstract(method.isAbstract()); meth.setFinal(method.isFinal()); meth.setNative(method.isNative()); meth.setStatic(method.isStatic()); meth.setStrictfp(method.isStrictfp()); meth.setSynchronized(method.isSynchronized()); // method.isTransient() // method.isVolatile() importExceptions(meth, method); oper = meth; } // set name and visibility if (oper != null) { oper.setName(methodName); oper.setVisibility(toVisibility(method)); // create parameters Type[] args = method.getArgumentTypes(); for (Type arg : args) { DbJVParameter param = new DbJVParameter(oper); param.setType(toAdt(arg)); param.setTypeUse(toTypeUse(arg)); } // end for } // end if } // end importMethod()
private void importExceptions(DbOOAbstractMethod oper, Method method) throws DbException { ExceptionTable table = method.getExceptionTable(); if (table != null) { String[] exceptionNames = table.getExceptionNames(); for (String exceptionName : exceptionNames) { DbOOAdt adt = findClassByName(exceptionName); if (adt instanceof DbJVClass) { DbJVClass exception = (DbJVClass) adt; if (oper instanceof DbJVConstructor) { DbJVConstructor constr = (DbJVConstructor) oper; constr.addToJavaExceptions(exception); } else if (oper instanceof DbJVMethod) { DbJVMethod meth = (DbJVMethod) oper; meth.addToJavaExceptions(exception); } // end if } // end if } // end for } // end if } // end importExceptions()