public static StatusUpdate instantiateStatusUpdate ( final String typeIdentifier , final FormItemList values ) throws StatusUpdateInstantiationFailedException { final StatusUpdateTemplate template = getStatusUpdateTemplate ( typeIdentifier ) ; final Class < ? > templateInstantiationClass = template . getInstantiationClass ( ) ; try { // instantiate status update final StatusUpdate statusUpdate = ( StatusUpdate ) templateInstantiationClass . newInstance ( ) ; // set status update fields String value ; try { for ( String fieldName : template . getFields ( ) . keySet ( ) ) { try { value = values . getField ( fieldName ) ; } catch ( final IllegalArgumentException e ) { throw new StatusUpdateInstantiationFailedException ( e . getMessage ( ) ) ; } templateInstantiationClass . getField ( fieldName ) . set ( statusUpdate , value ) ; } // set status update file paths for ( String fileName : template . getFiles ( ) . keySet ( ) ) { try { value = values . getFile ( fileName ) . getAbsoluteFilePath ( ) ; } catch ( final IllegalArgumentException e ) { throw new StatusUpdateInstantiationFailedException ( e . getMessage ( ) ) ; } templateInstantiationClass . getField ( fileName ) . set ( statusUpdate , value ) ; } } catch ( final IllegalArgumentException e ) { throw new StatusUpdateInstantiationFailedException ( "The types of the parameters passed do not match the status update template." ) ; } return statusUpdate ; } catch ( final SecurityException e ) { throw new IllegalArgumentException ( "failed to load the status update type specified, SecurityException occurred!" ) ; } catch ( final InstantiationException e ) { throw new IllegalArgumentException ( "failed to load the status update type specified, InstantiationException occurred!" ) ; } catch ( final IllegalAccessException e ) { throw new IllegalArgumentException ( "failed to load the status update type specified, IllegalAccessException occurred!" ) ; } catch ( final NoSuchFieldException e ) { throw new IllegalArgumentException ( "failed to load the status update type specified, NoSuchFieldException occurred!" ) ; } }
instantiate a status update