Class ReportText

java.lang.Object
org.apache.juneau.terminal.report.ReportText

public final class ReportText extends Object
Text helpers shared by the report readers.
  • Method Details

    • stripAnsi

      public static String stripAnsi(String s)
      Removes ANSI escape sequences (test runners colour their messages).
      Parameters:
      s - The text. May be null.
      Returns:
      The text without escape sequences, or an empty string for null.
    • clip

      public static String clip(String s, int max)
      Truncates a string to at most max chars, ending in an ellipsis when it was cut.
      Parameters:
      s - The text. May be null.
      max - The maximum length, at least 1.
      Returns:
      The clipped text, or an empty string for null.
    • fileName

      public static String fileName(Path path)
      Returns the file name of a path, never the directories (warnings leave the machine).
      Parameters:
      path - The path.
      Returns:
      The last segment, or an empty string.
    • stripCommonDir

      public static List<String> stripCommonDir(List<String> paths)
      Shortens a list of test file paths for display.

      Backslashes become slashes, then the longest common directory prefix of all paths is removed, so /ci/work/repo/src/a.test.js and /ci/work/repo/src/b/c.test.js become a.test.js and b/c.test.js. A list with a single path keeps its last two segments (src/a.test.js).

      Parameters:
      paths - The paths.
      Returns:
      The display paths, in the same order.