int consumableLen = 0;
int defaultLen = 0;
int urgencyLen = 0;
//Sort the list alphabetically
List<ComplexEntry> complexList = sortListByName(cList);
ComplexEntry ceDummy = new ComplexEntryImpl(true);
//Need to first get the maximum column lengths
for (ComplexEntry complex : complexList) {
nameLen = Math.max(nameLen, complex.getName().length());
shortcutLen = Math.max(shortcutLen, complex.getShortcut().length());
typeLen = Math.max(typeLen, ceDummy.typeToString(complex.getValtype()).length());
requestableLen = Math.max(requestableLen, (complex.getRequestable() == 1) ? 2 : 3); //length of YES, NO
consumableLen = Math.max(consumableLen, (complex.getConsumable() != 0) ? 3 : 2); //length of YES/JOB, NO);
defaultLen = Math.max(defaultLen, complex.getDefault().length());
urgencyLen = Math.max(urgencyLen, complex.getUrgencyWeight().length());
}
//Now format the columns
String header0 = String.format("%-19.19s %-10.10s %-11.11s %-5.5s %-11.11s %-10.10s %-8.8s %-8s", "#name", "shortcut", "type", "relop", "requestable", "consumable", "default", "urgency");
StringBuilder header1 = new StringBuilder("#");
for (int j = 0; j < header0.length() - 1; j++) {
header1.append("-");
}
sb.append(header0 + "\n");
sb.append(header1 + "\n");
String val;
//And finally print the columns
for (ComplexEntry complex : complexList) {
val = String.format("%-19.19s %-10.10s %-11.11s %-5.5s %-11.11s %-10.10s %-8.8s %-8s", complex.getName(),
complex.getShortcut(), ceDummy.typeToString(complex.getValtype()), ceDummy.opToString(complex.getRelop()),
ceDummy.reqToString(complex.getRequestable()), Util.getYesNoJobAsString(complex.getConsumable()), complex.getDefault(),
complex.getUrgencyWeight());
sb.append(val + "\n");
}
sb.append("# >#< starts a comment but comments are not saved across edits --------\n");
return sb.toString();