Method m = XmlRpcCaller.class.getMethod("xmlRpcCall", new Class[]{String.class, Vector.class});
Class[] exceptions = m.getExceptionTypes();
List exceptionList = new ArrayList();
if (exceptions != null) {
for (int i = 0; i < exceptions.length; i++) {
JavaQName qName = JavaQNameImpl.getInstance(exceptions[i]);
if (!pMethod.isThrowing(qName)) {
exceptionList.add(qName);
}
}
}
JavaMethod jm = pJs.newJavaMethod(pMethod);
LocalJavaField v = jm.newJavaField(Vector.class);
v.addLine("new ", Vector.class, "()");
Parameter[] params = jm.getParams();
for (int i = 0; i < params.length; i++) {
Parameter p = params[i];
jm.addLine(v, ".add(", getInputValue(jm, p.getType(), p), ");");
}
if (!exceptionList.isEmpty()) {
jm.addTry();
}
Object result = new Object[]{pCaller, ".xmlRpcCall(",
JavaSource.getQuoted(pName), ", ", v, ")"};
if (JavaQNameImpl.VOID.equals(jm.getType())) {
jm.addLine(result, ";");
} else {
jm.addLine("return ", getResultValue(jm, jm.getType(), result), ";");
}
if (!exceptionList.isEmpty()) {
for (int i = 0; i < exceptionList.size(); i++) {
JavaQName exClass = (JavaQName) exceptionList.get(i);
DirectAccessible e = jm.addCatch(exClass);
jm.addThrowNew(UndeclaredThrowableException.class, e);
}
jm.addEndTry();
}