Description
The class org.apache.karaf.shell.commands.InfoAction accepts input from InfoProvider services. The items from those providers are printed via this code:
for (String section : properties.keySet()) { System.out.println(section); for (Object key : properties.get(section).keySet()) { printValue(String.valueOf(key), maxNameLen, String.valueOf(properties.get(section).get(key))); } }
The .keySet() method returns keys in effectively random order, making the output hard to read. I propose instead the following presentation:
List<String> sections = new ArrayList<String>(properties.keySet()); Collections.sort(sections); for (String section : sections) { List<Object> keys = new ArrayList<Object>(properties.get(section).keySet()); if (keys.size() > 0) { System.out.println(section); Collections.sort(keys, new Comparator<Object>() { public int compare(Object o1, Object o2) { return String.valueOf(o1).compareTo(String.valueOf(o2)); } }); for (Object key : keys) { printValue(String.valueOf(key), maxNameLen, String.valueOf(properties.get(section).get(key))); } } }