public Object getEntryValue ( JPAEntry entry ) { try { Class < ? > typeClass = loadClass ( entry . getType ( ) ) ; if ( typeClass == null ) { return entry . getValue ( ) ; } if ( typeClass == Character . class ) { if ( entry . getValue ( ) . length ( ) > 1 ) { LOGGER . warn ( "Too many chars in the string for a character type: " + entry . getValue ( ) ) ; LOGGER . warn ( "The first char of the string will be used." ) ; return entry . getValue ( ) . charAt ( 0 ) ; } else if ( entry . getValue ( ) . length ( ) != 0 ) { return entry . getValue ( ) . charAt ( 0 ) ; } } Object result = invokeValueOf ( typeClass , entry . getValue ( ) ) ; if ( result != null ) { return result ; } Constructor < ? > constructor = ClassUtils . getConstructorIfAvailable ( typeClass , String . class ) ; if ( constructor != null ) { return constructor . newInstance ( entry . getValue ( ) ) ; } LOGGER . debug ( "DefaultConverterStep didn't find any possibility to convert entry {}. " + "The simple string value will be returned" , entry ) ; } catch ( IllegalAccessException e ) { LOGGER . error ( "IllegalAccessException when trying to create object of type {}" , entry . getType ( ) , e ) ; } catch ( InvocationTargetException e ) { LOGGER . error ( "InvocationTargetException when trying to create object of type {}" , entry . getType ( ) , e ) ; } catch ( IllegalArgumentException e ) { LOGGER . error ( "IllegalArgumentException when trying to create object of type {}" , entry . getType ( ) , e ) ; } catch ( InstantiationException e ) { LOGGER . error ( "InstantiationException when trying to create object of type {}" , entry . getType ( ) , e ) ; } return entry . getType ( ) ; }
Tries to get the object value for a given JPAEntry . To instantiate the type first the static method valueOf of the type will be tried . If that didn t work then the constructor of the object with a string parameter is used . If that didn t work either the simple string will be set in the entry .