Class SmartLines

java.lang.Object
atessera.markup.SmartLines

public final class SmartLines extends Object
Parses a Dockerfile-style argument list into individual string values.

The parser supports the bracketed syntax used by Docker for the exec form of CMD, ENTRYPOINT, and RUN. Such a value is a comma-separated list of double-quoted JSON-like string literals, for example:


 ["/bin/sh", "-c", "echo \"hello\""]
 
This class intentionally implements only the small subset of JSON syntax that is needed for such argument lists: a top-level array of strings. It does not support nested arrays, objects, numbers, booleans, or null.

If an input value is not enclosed in square brackets, it is returned unchanged as a single-element list. This makes the parser convenient for accepting both Dockerfile forms of a command line:


 echo hello
 ["echo", "hello"]
 

Supported escapes

Inside string literals the following escape sequences are supported: \", \\, \/, \b, \f, \n, \r, \t, and \\uXXXX (four hexadecimal digits).
  • Method Details

    • parse

      public static List<String> parse(String value)
      Parses the given value into a list of strings.

      If value does not start with [ and end with ] (ignoring leading and trailing whitespace), it is returned unchanged as the only element of the result list. Otherwise the text between the brackets is parsed as a comma-separated list of double-quoted string literals.

      Parameters:
      value - the input value, must not be null
      Returns:
      an immutable list of parsed strings; empty for []
      Throws:
      NullPointerException - if value is null
      IllegalArgumentException - if the bracketed input is malformed