/** * Sets a method/constructor body. * * @param src the source code representing the body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * body does nothing except returning zero or null. */ public void setBody(String src) throws CannotCompileException { setBody(src, null, null); }
/** * Sets a method/constructor body. * * @param src the source code representing the body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * body does nothing except returning zero or null. */ public void setBody(String src) throws CannotCompileException { setBody(src, null, null); }
/** * Sets a constructor body. * * @param src the source code representing the constructor body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * constructor body does nothing except calling * <code>super()</code>. */ public void setBody(String src) throws CannotCompileException { if (src == null) if (isClassInitializer()) src = ";"; else src = "super();"; super.setBody(src); }
/** * Sets a constructor body. * * @param src the source code representing the constructor body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * constructor body does nothing except calling * <code>super()</code>. */ @Override public void setBody(String src) throws CannotCompileException { if (src == null) if (isClassInitializer()) src = ";"; else src = "super();"; super.setBody(src); }
/** * Sets a method/constructor body. * * @param src the source code representing the body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * body does nothing except returning zero or null. */ public void setBody(String src) throws CannotCompileException { setBody(src, null, null); }
/** * Sets a method/constructor body. * * @param src the source code representing the body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * body does nothing except returning zero or null. */ public void setBody(String src) throws CannotCompileException { setBody(src, null, null); }
/** * Sets a method/constructor body. * * @param src the source code representing the body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * body does nothing except returning zero or null. */ public void setBody(String src) throws CannotCompileException { setBody(src, null, null); }
/** * Sets a method/constructor body. * * @param src the source code representing the body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * body does nothing except returning zero or null. */ public void setBody(String src) throws CannotCompileException { setBody(src, null, null); }
/** * Sets a method/constructor body. * * @param src the source code representing the body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * body does nothing except returning zero or null. */ public void setBody(String src) throws CannotCompileException { setBody(src, null, null); }
/** * Sets a constructor body. * * @param src the source code representing the constructor body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * constructor body does nothing except calling * <code>super()</code>. */ public void setBody(String src) throws CannotCompileException { if (src == null) if (isClassInitializer()) src = ";"; else src = "super();"; super.setBody(src); }
/** * Sets a constructor body. * * @param src the source code representing the constructor body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * constructor body does nothing except calling * <code>super()</code>. */ public void setBody(String src) throws CannotCompileException { if (src == null) if (isClassInitializer()) src = ";"; else src = "super();"; super.setBody(src); }
/** * Sets a constructor body. * * @param src the source code representing the constructor body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * constructor body does nothing except calling * <code>super()</code>. */ public void setBody(String src) throws CannotCompileException { if (src == null) if (isClassInitializer()) src = ";"; else src = "super();"; super.setBody(src); }
/** * Sets a constructor body. * * @param src the source code representing the constructor body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * constructor body does nothing except calling * <code>super()</code>. */ public void setBody(String src) throws CannotCompileException { if (src == null) if (isClassInitializer()) src = ";"; else src = "super();"; super.setBody(src); }
/** * Sets a constructor body. * * @param src the source code representing the constructor body. * It must be a single statement or block. * If it is <code>null</code>, the substituted * constructor body does nothing except calling * <code>super()</code>. */ public void setBody(String src) throws CannotCompileException { if (src == null) if (isClassInitializer()) src = ";"; else src = "super();"; super.setBody(src); }
@Override void createBody(CtBehavior behavior) { try { behavior.setBody(getBody()); } catch (CannotCompileException e) { throw new org.jboss.reflect.spi.CannotCompileException(e.getMessage()); } }
private void setBody(CtBehavior m, String body, String jDoc) throws Exception { // for debug StringBuffer args = new StringBuffer(); if (m.getParameterTypes() != null) { int p = 0; for (CtClass ct : m.getParameterTypes()) { p++; args.append(ct.getName() + " $" + p); if (p < m.getParameterTypes().length) { args.append(", "); } } } if (jDoc != null) { debug("/** " + jDoc + " */"); } if (m instanceof CtConstructor) { debug("public " + m.getName() + " ( " + args.toString() + " ) {"); } else { debug("method " + ((CtMethod) m).getReturnType().getName() + " " + m.getName() + " ( " + args.toString() + " ) {"); } debug(body); debug("}"); debug(""); m.setBody("{ " + body + "}"); }
public MethodFab addMethod(int modifiers, MethodSignature ms, String body) { if (_methods.get(ms) != null) throw new ApplicationRuntimeException(ServiceMessages.duplicateMethodInClass(ms, this)); CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(modifiers); method.setBody(body); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(ServiceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } // Return a MethodFab so the caller can add catches. MethodFab result = new MethodFabImpl(getSource(), ms, method, body); _methods.put(ms, result); return result; }