Class TerminalViewChecks

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

public final class TerminalViewChecks extends Object
Shared validation grammar; not intended for application use.

The terminal-view grammars live in one place so the server types, the report readers and the client module (which mirrors them, pinned by a shared vectors file) cannot drift.

  • Field Details

  • Method Details

    • isRunId

      public static boolean isRunId(String s)
      Whether the string is a valid run id.
      Parameters:
      s - The candidate. May be null.
      Returns:
      true if valid.
    • isToken

      public static boolean isToken(String s)
      Whether the string is a valid opaque page token.
      Parameters:
      s - The candidate. May be null.
      Returns:
      true if valid.
    • isStepId

      public static boolean isStepId(String s)
      Whether the string is a valid step id.
      Parameters:
      s - The candidate. May be null.
      Returns:
      true if valid.
    • isFw

      public static boolean isFw(String s)
      Whether the string is a valid framework key.
      Parameters:
      s - The candidate. May be null.
      Returns:
      true if valid.
    • isNoteHref

      public static boolean isNoteHref(String s)
      Whether the string is a safe note href.

      Either an absolute URL whose scheme is exactly http or https and which has a non-empty host, or anything that isSafeLineHref(String) accepts. TAB, CR and LF are stripped first.

      Parameters:
      s - The candidate. May be null.
      Returns:
      true if safe.
    • isRawHrefTemplate

      public static boolean isRawHrefTemplate(String s)
      Whether the string is a valid raw-href template.

      It must contain exactly one {offset} placeholder and, with 1 substituted, be a safe line href.

      Parameters:
      s - The candidate. May be null.
      Returns:
      true if valid.
    • isSafeLineHref

      public static boolean isSafeLineHref(String s)
      Whether a line href is safe: a bare fragment, or a same-origin path accepted by isSameOriginPath(String).

      TAB, CR and LF are stripped first. A backslash anywhere refuses the href.

      Parameters:
      s - The candidate href. May be null.
      Returns:
      true if the href is safe.
    • isSameOriginPath

      public static boolean isSameOriginPath(String path)
      Whether the string is a same-origin path template, by the one shared rule in SafePathTemplate.isSameOriginPath(String): no ://, no // prefix, no scheme colon-before-slash, no .. path segment, and no backslash, control character, or leading or trailing space.
      Parameters:
      path - The candidate template. May be null.
      Returns:
      true if the string is a same-origin path template.
    • clip

      public static String clip(String s)
      Truncates a value for an error message: 64 characters plus an ellipsis.
      Parameters:
      s - The value. May be null.
      Returns:
      The clipped text, or "null" for null.
    • firstLine

      public static String firstLine(String s)
      Returns the stripped first line of a string.
      Parameters:
      s - The string. May be null.
      Returns:
      The first line, or an empty string for null.