public static FormatInfo valueOf ( String str ) throws IllegalArgumentException { if ( str == null ) { throw new NullPointerException ( "Argument cannot be null" ) ; } FormatInfo fi = new FormatInfo ( ) ; int indexOfDot = str . indexOf ( ' ' ) ; String minPart = null ; String maxPart = null ; if ( indexOfDot != - 1 ) { minPart = str . substring ( 0 , indexOfDot ) ; if ( indexOfDot + 1 == str . length ( ) ) { throw new IllegalArgumentException ( "Formatting string [" + str + "] should not end with '.'" ) ; } else { maxPart = str . substring ( indexOfDot + 1 ) ; } } else { minPart = str ; } if ( minPart != null && minPart . length ( ) > 0 ) { int min = Integer . parseInt ( minPart ) ; if ( min >= 0 ) { fi . min = min ; } else { fi . min = - min ; fi . leftPad = false ; } } if ( maxPart != null && maxPart . length ( ) > 0 ) { int max = Integer . parseInt ( maxPart ) ; if ( max >= 0 ) { fi . max = max ; } else { fi . max = - max ; fi . leftTruncate = false ; } } return fi ; }
This method is used to parse a string such as 5 . 7 5 . 7 or - 5 . 7 into a FormatInfo .