@ SuppressWarnings ( "unchecked" ) public static void setProperty ( Object object , String name , String text ) throws NoSuchFieldException { try { // need to get to the field for any typeinfo annotation, so here we go ... int length = name . lastIndexOf ( ' ' ) ; if ( length > 0 ) { object = getProperty ( object , name . substring ( 0 , length ) ) ; name = name . substring ( length + 1 ) ; } length = name . length ( ) ; Matcher matcher = ARRAY_INDEX . matcher ( name ) ; for ( Matcher m = matcher ; m . matches ( ) ; m = ARRAY_INDEX . matcher ( name ) ) { name = m . group ( 1 ) ; } Field field = Beans . getKnownField ( object . getClass ( ) , name ) ; if ( name . length ( ) != length ) { int index = Integer . parseInt ( matcher . group ( 2 ) ) ; object = getProperty ( object , matcher . group ( 1 ) ) ; if ( object . getClass ( ) . isArray ( ) ) { Array . set ( object , index , new ValueOf ( object . getClass ( ) . getComponentType ( ) , field . getAnnotation ( typeinfo . class ) ) . invoke ( text ) ) ; } else { ( ( List ) object ) . set ( index , new ValueOf ( field . getAnnotation ( typeinfo . class ) . value ( ) [ 0 ] ) . invoke ( text ) ) ; } } else { field . set ( object , new ValueOf ( field . getType ( ) , field . getAnnotation ( typeinfo . class ) ) . invoke ( text ) ) ; } } catch ( NoSuchFieldException x ) { throw x ; } catch ( Exception x ) { throw new IllegalArgumentException ( x . getMessage ( ) + ": " + name , x ) ; } }
Updates a property .