public void setReadMethod(java.lang.reflect.Method getter) {//throws IntrospectionException { if (getter != null) { int modifiers = getter.getModifiers(); if (!java.lang.reflect.Modifier.isPublic(modifiers)) { throw new IntrospectionException("Modifier for getter method should be public.");//Messages.getString("beans.0A")); //$NON-NLS-1$ } java.lang.Class[] parameterTypes = getter.getParameterTypes(); if (parameterTypes.Length != 0) { throw new IntrospectionException("Number of parameters in getter method is not equal to 0.");//Messages.getString("beans.08")); //$NON-NLS-1$ } java.lang.Class returnType = getter.getReturnType(); if (returnType.equals(java.lang.Void.TYPE)) { throw new IntrospectionException("{0} does not return <void>");//Messages.getString("beans.33")); //$NON-NLS-1$ } java.lang.Class propertyType = getPropertyType(); if ((propertyType != null) && !returnType.equals(propertyType)) { throw new IntrospectionException("Parameter type in getter method does not corresponds to predefined.");//Messages.getString("beans.09")); //$NON-NLS-1$ } } this.getter = getter; }
/** * Creates an array of parameters to pass to the given mutator method. * If the given object is not the right type to pass to the method * directly, it will be converted using {@link #convertType(Class,Object)}. * * @param method the mutator method * @param value the value to pass to the mutator method * @return an array containing one object that is either the given value * or a transformed value * @throws IllegalAccessException if {@link #convertType(Class,Object)} * raises it * @throws IllegalArgumentException if any other exception is raised * by {@link #convertType(Class,Object)} */ protected Object[] createWriteMethodArguments(java.lang.reflect.Method method, Object value) {//throws IllegalAccessException, ClassCastException { try { if (value != null) { java.lang.Class[] types = method.getParameterTypes(); if (types != null && types.Length > 0) { java.lang.Class paramType = types[0]; if (!paramType.isAssignableFrom(value.getClass())) { value = convertType(paramType, value); } } } Object[] answer = { value }; return(answer); } catch (java.lang.reflect.InvocationTargetException e) { logInfo(e); throw new java.lang.IllegalArgumentException(e.getMessage()); } catch (java.lang.InstantiationException e) { logInfo(e); throw new java.lang.IllegalArgumentException(e.getMessage()); } }
public java.lang.Class getPropertyType() { java.lang.Class result = null; if (getter != null) { result = getter.getReturnType(); } else if (setter != null) { java.lang.Class[] parameterTypes = setter.getParameterTypes(); result = parameterTypes[0]; } return(result); }
public void setWriteMethod(java.lang.reflect.Method setter) {//throws IntrospectionException { if (setter != null) { int modifiers = setter.getModifiers(); if (!java.lang.reflect.Modifier.isPublic(modifiers)) { throw new IntrospectionException("Modifier for setter method should be public.");//Messages.getString("beans.05")); //$NON-NLS-1$ } java.lang.Class[] parameterTypes = setter.getParameterTypes(); if (parameterTypes.Length != 1) { throw new IntrospectionException("Number of parameters in setter method is not equal to 1.");//Messages.getString("beans.06")); //$NON-NLS-1$ } java.lang.Class parameterType = parameterTypes[0]; java.lang.Class propertyType = getPropertyType(); if (propertyType != null && !propertyType.equals(parameterType)) { throw new IntrospectionException("Parameter type in setter method does not corresponds to predefined.");//Messages.getString("beans.07")); //$NON-NLS-1$ } } this.setter = setter; }