public Object setObjectValue ( StringToObjectConverter pConverter , Object pInner , String pIndex , Object pValue ) throws IllegalAccessException , InvocationTargetException { Class clazz = pInner . getClass ( ) ; if ( ! clazz . isArray ( ) ) { throw new IllegalArgumentException ( "Not an array to set a value, but " + clazz + ". (index = " + pIndex + ", value = " + pValue + ")" ) ; } int idx ; try { idx = Integer . parseInt ( pIndex ) ; } catch ( NumberFormatException exp ) { throw new IllegalArgumentException ( "Non-numeric index for accessing array " + pInner + ". (index = " + pIndex + ", value to set = " + pValue + ")" , exp ) ; } Class type = clazz . getComponentType ( ) ; Object value = pConverter . prepareValue ( type . getName ( ) , pValue ) ; Object oldValue = Array . get ( pInner , idx ) ; Array . set ( pInner , idx , value ) ; return oldValue ; }
Set a value in an array