protected Integer parseIntString ( String string , boolean abortOnError , int def ) throws TransformationOperationException { Integer integer = def ; if ( string == null ) { logger . debug ( "Given string is empty so the default value is taken." ) ; } try { integer = Integer . parseInt ( string ) ; } catch ( NumberFormatException e ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "The string " ) . append ( string ) . append ( " is not a number. " ) ; if ( abortOnError ) { builder . append ( "The step will be skipped." ) ; } else { builder . append ( def ) . append ( " will be taken instead." ) ; } logger . warn ( builder . toString ( ) ) ; if ( abortOnError ) { throw new TransformationOperationException ( builder . toString ( ) ) ; } } return integer ; }
Parses a string to an integer object . AbortOnError defines if the function should throw an exception if an error occurs during the parsing . If it doesn t abort the given default value is given back as result on error .