public boolean matchMethod(MethodSignature method) { return method.getParameterTypes().length == _parameterCount; }
public boolean matchMethod(MethodSignature sig) { Class actualType = sig.getParameterTypes()[_parameterIndex]; String actualTypeName = ClassFabUtils.getJavaClassName(actualType); return actualTypeName.equals(_parameterType); }
/** * Finds a public or protected method in the base class. */ private Method findMethod(MethodSignature sig) { // Finding a public method is easy: try { return _baseClass.getMethod(sig.getName(), sig.getParameterTypes()); } catch (NoSuchMethodException ex) { // Good; no super-implementation to invoke. } Class c = _baseClass; while(c != Object.class) { try { return c.getDeclaredMethod(sig.getName(), sig .getParameterTypes()); } catch (NoSuchMethodException ex) { // Ok, continue loop up to next base class. } c = c.getSuperclass(); } return null; }
/** * Finds a public or protected method in the base class. */ private Method findMethod(MethodSignature sig) { // Finding a public method is easy: try { return _baseClass.getMethod(sig.getName(), sig.getParameterTypes()); } catch (NoSuchMethodException ex) { // Good; no super-implementation to invoke. } Class c = _baseClass; while(c != Object.class) { try { return c.getDeclaredMethod(sig.getName(), sig .getParameterTypes()); } catch (NoSuchMethodException ex) { // Ok, continue loop up to next base class. } c = c.getSuperclass(); } return null; }
public MethodFab addMethod(int modifiers, MethodSignature ms, String body) { if (_methods.get(ms) != null) throw new ApplicationRuntimeException(EnhanceMessages.duplicateMethodInClass(ms, this)); if (body.indexOf("isWrapperFor") > 0 || body.indexOf("unwrap") > 0) return new MethodFabImpl(null, ms, null, "{ throw new UnsupportedOperationException(\"Method not implemented\"); }"); 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(EnhanceMessages.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; }
rootExpr = ""; createLocalReferences(context, generateClassFab(compiled), compiled.getGetterMethod().getParameterTypes());
rootExpr = ""; createLocalReferences(context, generateClassFab(compiled), compiled.getGetterMethod().getParameterTypes());
public MethodFab addMethod(int modifiers, MethodSignature ms, String body) { if (_methods.get(ms) != null) throw new ApplicationRuntimeException(EnhanceMessages.duplicateMethodInClass(ms, this)); if (body.indexOf("isWrapperFor") > 0 || body.indexOf("unwrap") > 0) return new MethodFabImpl(null, ms, null, "{ throw new UnsupportedOperationException(\"Method not implemented\"); }"); 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(EnhanceMessages.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; }
setterValue = ""; createLocalReferences(context, generateClassFab(compiled), compiled.getSettermethod().getParameterTypes());
public void addMethod(MethodSignature ms) { 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(Modifier.PUBLIC | Modifier.ABSTRACT); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(ServiceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } _methods.add(ms); }
setterValue = ""; createLocalReferences(context, generateClassFab(compiled), compiled.getSettermethod().getParameterTypes());
public void addMethod(MethodSignature ms) { 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(Modifier.PUBLIC | Modifier.ABSTRACT); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(EnhanceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } _methods.add(ms); }
public void addMethod(MethodSignature ms) { 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(Modifier.PUBLIC | Modifier.ABSTRACT); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(EnhanceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } _methods.add(ms); }
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; }