private Map computeColumnWidths()

in platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RestRegistryListCommand.java [105:148]


    private Map<String, Integer> computeColumnWidths(List<Map<String, String>> services) throws Exception {
        int maxUriLen = 0;
        int maxBasePathLen = 0;
        int maxUriTemplateLen = 0;
        int maxMethodLen = 0;
        int maxStatusLen = 0;
        int maxRouteLen = 0;

        for (Map<String, String> row : services) {
            String uri = row.get("url");
            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());

            String basePath = row.get("basePath");
            maxBasePathLen = Math.max(maxBasePathLen, basePath == null ? 0 : basePath.length());

            String uriTemplate = row.get("uriTemplate");
            maxUriTemplateLen = Math.max(maxUriTemplateLen, uriTemplate == null ? 0 : uriTemplate.length());

            String method = row.get("method");
            maxMethodLen = Math.max(maxMethodLen, method == null ? 0 : method.length());

            String status = row.get("state");
            maxStatusLen = Math.max(maxStatusLen, status == null ? 0 : status.length());

            String routeId = row.get("routeId");
            maxRouteLen = Math.max(maxRouteLen, routeId == null ? 0 : routeId.length());
        }

        final Map<String, Integer> retval = new Hashtable<>();
        retval.put(URL_COLUMN_NAME, maxUriLen);
        retval.put(BASE_PATH_LABEL, maxBasePathLen);
        retval.put(URI_TEMPLATE_LABEL, maxUriTemplateLen);
        retval.put(METHOD_COLUMN_LABEL, maxMethodLen);
        retval.put(STATE_COLUMN_LABEL, maxStatusLen);
        retval.put(ROUTE_COLUMN_LABEL, maxRouteLen);

        return retval;
    }