public void addParameters ( String tbl ) throws IOException { try ( InputStream is = getInputStream ( tbl ) ) { if ( is == null ) { throw new IOException ( "Unable to open " + tbl ) ; } String content = readContents ( is ) ; // LOOK this is silly - should just read one line at a time // List lines = StringUtil.split(content, "\n", false); String [ ] lines = content . split ( "\n" ) ; List < String [ ] > result = new ArrayList <> ( ) ; for ( String line : lines ) { //String line = (String) lines.get(i); String tline = line . trim ( ) ; if ( tline . length ( ) == 0 ) { continue ; } if ( tline . startsWith ( "!" ) ) { continue ; } String [ ] words = new String [ indices . length ] ; for ( int idx = 0 ; idx < indices . length ; idx ++ ) { if ( indices [ idx ] >= tline . length ( ) ) { continue ; } if ( indices [ idx ] + lengths [ idx ] > tline . length ( ) ) { words [ idx ] = line . substring ( indices [ idx ] ) ; } else { words [ idx ] = line . substring ( indices [ idx ] , indices [ idx ] + lengths [ idx ] ) ; } //if (trimWords) { words [ idx ] = words [ idx ] . trim ( ) ; //} } result . add ( words ) ; } for ( String [ ] aResult : result ) { GempakParameter p = makeParameter ( aResult ) ; if ( p != null ) { if ( p . getName ( ) . contains ( "(" ) ) { templateParamMap . put ( p . getName ( ) , p ) ; } else { paramMap . put ( p . getName ( ) , p ) ; } } } } }
Add parameters from the table