code: private static <T> int[] getFieldSizes(List<T> list, Field[] fields) {
  
  		if (list.isEmpty()) throw new IllegalArgumentException("List of beans is empty!");
  
  		if(fields == null)
  			fields = getFields(list.get(0).getClass());
  
  		int[] sizes = new int [fields.length];
  
  
  		for (T a:list) {
  			int i = -1;
  			for (Field f : fields) {
  				i++;
  
  				f.setAccessible(true);
  
  				try {
  					Object obj = f.get(a);
  					int length;
  					if (obj==null) {
  						length = MMCIF_MISSING_VALUE.length();
  					} else {
  						String val = (String) obj;
  						length = addMmCifQuoting(val).length();
  					}
  
  					if (length>sizes[i]) sizes[i] = length;
  
  				} catch (IllegalAccessException e) {
  					logger.warn("Field {} is inaccessible", f.getName());
  					continue;
  				} catch (ClassCastException e) {
  					logger.warn("Could not cast value to String for field {}",f.getName());
  					continue;
  				}
  			}
  		}
  		return sizes;
  	}
docs: Finds the max length of each of the String values contained in each of the fields of the given list of beans.
  Useful for producing mmCIF loop data that is aligned for all columns.
  @param list list of objects. All objects should have the same class.
  @param fields Set of fields for the record. If null, will be calculated from the class of the first record
  @return
  @see #toMMCIF(List, Class)