1 package net.sf.mavenhist.extractor.util; 2 3 import net.sf.mavenhist.extractor.MultiMetric; 4 5 import org.apache.commons.lang.StringUtils; 6 7 /** 8 * Util to handle {@link MultiMetric} arrays. 9 */ 10 public final class MultimetricArrayToStringUtil { 11 12 /** 13 * Private constructor since this is a utility class and should not be instantiated. 14 */ 15 private MultimetricArrayToStringUtil() { } 16 17 /** 18 * Returns a userreadable {@link String} from an array of {@link MultiMetric}. 19 * 20 * @param metrics to present in user readable form. 21 * @return user readable string. 22 */ 23 public static String toString(MultiMetric[] metrics) { 24 StringBuffer buffer = new StringBuffer(); 25 for (int i = 0; i < metrics.length; i++) { 26 MultiMetric metric = metrics[i]; 27 String location = metric.getLocation(); 28 if (!StringUtils.isEmpty(location)) { 29 buffer.append(location); 30 buffer.append(": "); 31 } 32 33 buffer.append(metric.getValue()); 34 if ((i + 1) < metrics.length) { 35 buffer.append("; "); 36 } 37 } 38 return buffer.toString(); 39 } 40 }