public static int [ ] computeMaximums ( String [ ] headers , OutputFormatter ... outputs ) { int [ ] max = new int [ headers . length ] ; for ( int i = 0 ; i < headers . length ; i ++ ) max [ i ] = headers [ i ] . length ( ) ; for ( OutputFormatter output : outputs ) { max [ 0 ] = Math . max ( output . host . length ( ) , max [ 0 ] ) ; for ( int i = 1 ; i < headers . length ; i ++ ) max [ i ] = Math . max ( output . results [ i - 1 ] . length ( ) , max [ i ] ) ; } return max ; }
compute the maximum width for each field across a collection of formatters .