private GempakParameter makeParameter ( String [ ] words ) { int num = 0 ; String description ; if ( words [ 0 ] != null ) { num = ( int ) Double . parseDouble ( words [ 0 ] ) ; } if ( ( words [ 3 ] == null ) || words [ 3 ] . equals ( "" ) ) { // no param name return null ; } String name = words [ 3 ] ; if ( name . contains ( "-" ) ) { int first = name . indexOf ( "-" ) ; int last = name . lastIndexOf ( "-" ) ; StringBuilder buf = new StringBuilder ( name . substring ( 0 , first ) ) ; buf . append ( "(" ) ; for ( int i = first ; i <= last ; i ++ ) { buf . append ( "\\d" ) ; } buf . append ( ")" ) ; buf . append ( name . substring ( last + 1 ) ) ; name = buf . toString ( ) ; } if ( ( words [ 1 ] == null ) || words [ 1 ] . equals ( "" ) ) { description = words [ 3 ] ; } else { description = words [ 1 ] ; } String unit = words [ 2 ] ; if ( unit != null ) { unit = unit . replaceAll ( "\\*\\*" , "" ) ; if ( unit . equals ( "-" ) ) { unit = "" ; } } int decimalScale ; try { decimalScale = Integer . parseInt ( words [ 4 ] . trim ( ) ) ; } catch ( NumberFormatException ne ) { decimalScale = 0 ; } return new GempakParameter ( num , name , description , unit , decimalScale ) ; }
Make a parameter from the tokens