in platforms/commands/commands-core/src/main/java/org/apache/camel/commands/EndpointStatisticCommand.java [139:194]
private Map<String, Integer> computeColumnWidths(Map<String, List<Map<String, String>>> allEndpoints) throws Exception {
if (allEndpoints == null) {
throw new IllegalArgumentException("Unable to determine column widths from null Iterable<Endpoint>");
} else {
int maxContextLen = 0;
int maxUriLen = 0;
int maxRouteIdLen = 0;
int maxDirectionLen = 0;
int maxStaticLen = 0;
int maxDynamicLen = 0;
int maxHitsLen = 0;
for (Map.Entry<String, List<Map<String, String>>> entry : allEndpoints.entrySet()) {
String contextName = entry.getKey();
for (Map<String, String> row : entry.getValue()) {
maxContextLen = Math.max(maxContextLen, contextName == null ? 0 : contextName.length());
String uri = row.get("uri");
if (decode) {
// decode uri so its more human readable
uri = URLDecoder.decode(uri, "UTF-8");
}
// sanitize and mask uri so we dont see passwords
uri = URISupport.sanitizeUri(uri);
maxUriLen = Math.max(maxUriLen, uri == null ? 0 : uri.length());
final String routeId = row.get("routeId");
maxRouteIdLen = Math.max(maxRouteIdLen, routeId == null ? 0 : routeId.length());
final String direction = row.get("direction");
maxDirectionLen = Math.max(maxDirectionLen, direction == null ? 0 : direction.length());
final String isStatic = row.get("static");
maxStaticLen = Math.max(maxStaticLen, isStatic == null ? 0 : isStatic.length());
final String isDynamic = row.get("dynamic");
maxDynamicLen = Math.max(maxDynamicLen, isDynamic == null ? 0 : isDynamic.length());
final String hits = row.get("hits");
maxHitsLen = Math.max(maxHitsLen, hits == null ? 0 : hits.length());
}
}
final Map<String, Integer> retval = new Hashtable<>();
retval.put(CONTEXT_COLUMN_LABEL, maxContextLen);
retval.put(URI_COLUMN_LABEL, maxUriLen);
retval.put(ROUTE_COLUMN_LABEL, maxRouteIdLen);
retval.put(DIRECTION_COLUMN_LABEL, maxDirectionLen);
retval.put(STATIC_COLUMN_LABEL, maxStaticLen);
retval.put(DYNAMIC_COLUMN_LABEL, maxDynamicLen);
retval.put(HITS_COLUMN_LABEL, maxHitsLen);
return retval;
}
}