protected void invokeSetter ( String value ) { try { // coerce value to field type Class < ? > type = descriptor . getPropertyType ( ) ; PropertyEditor editor = PropertyEditors . findEditor ( type ) ; editor . setAsText ( value ) ; Object coerced = editor . getValue ( ) ; // System.out.println("type: " + type); // System.out.println("coerced: " + coerced); // invoke the setter method setter . invoke ( instance , new Object [ ] { coerced } ) ; } catch ( InvocationTargetException e ) { Throwable target = e . getTargetException ( ) ; if ( target instanceof PropertyException ) { throw ( PropertyException ) target ; } else { throw new PropertyException ( target ) ; } } catch ( Exception e ) { throw new PropertyException ( e ) ; } }
Coerce and invoke the property setter method on the instance .