public void load ( Map < String , Object > data ) throws PersistenceException { logger . debug ( "enter - load(Map)" ) ; try { for ( String key : data . keySet ( ) ) { Class < ? > cls = persistent . getClass ( ) ; Object val = data . get ( key ) ; Field f = null ; while ( f == null ) { try { f = cls . getDeclaredField ( key ) ; } catch ( NoSuchFieldException ignore ) { // ignore } if ( f == null ) { cls = cls . getSuperclass ( ) ; if ( cls == null || cls . getName ( ) . equals ( Object . class . getName ( ) ) ) { break ; } } } if ( f == null ) { logger . debug ( "No such field: " + key ) ; continue ; } try { f . setAccessible ( true ) ; f . set ( persistent , val ) ; } catch ( IllegalAccessException e ) { String msg = "Error setting value for " + key + ":\n" ; if ( val == null ) { msg = msg + " (null)" ; } else { msg = msg + " (" + val + ":" + val . getClass ( ) . getName ( ) + ")" ; } msg = msg + ":\n" + e . getClass ( ) . getName ( ) + ":\n" ; throw new PersistenceException ( msg + e . getMessage ( ) ) ; } catch ( IllegalArgumentException e ) { String msg = "Error setting value for " + key ; if ( val == null ) { msg = msg + " (null)" ; } else { msg = msg + " (" + val + ":" + val . getClass ( ) . getName ( ) + ")" ; } msg = msg + ":\n" + e . getClass ( ) . getName ( ) + ":\n" ; throw new PersistenceException ( msg + e . getMessage ( ) ) ; } } } finally { logger . debug ( "exit - load(Map)" ) ; } }
Loads the data values into the persistent object .