private int convertNonNegativeInteger ( String str ) { str = str . trim ( ) ; DecimalDatatype decimal = new DecimalDatatype ( ) ; if ( ! decimal . lexicallyAllows ( str ) ) return - 1 ; // Canonicalize the value str = decimal . getValue ( str , null ) . toString ( ) ; // Reject negative and fractional numbers if ( str . charAt ( 0 ) == ' ' || str . indexOf ( ' ' ) >= 0 ) return - 1 ; try { return Integer . parseInt ( str ) ; } catch ( NumberFormatException e ) { // Map out of range integers to MAX_VALUE return Integer . MAX_VALUE ; } }
Return Integer . MAX_VALUE for values that are too big