Class CatalogPathResolver

java.lang.Object
name.jurgenei.gradle.antlr.catalog.CatalogPathResolver

public final class CatalogPathResolver extends Object
Resolves local path and URL grammar coordinates declared in a catalog entry.
  • Method Details

    • resolveToUri

      public static URI resolveToUri(String value, Path baseDirectory)
      Resolves a catalog coordinate to a URI.

      Absolute URIs are returned as-is. Non-absolute values are treated as paths relative to baseDirectory.

      Protocol-relative coordinates (`//host/path.g4`) and host/path coordinates without explicit scheme (`localhost:8080/MiniParser.g4`, `example.org/Parser.g4`) are also supported. The default scheme is `http` for localhost/loopback hosts and `https` otherwise.

      Parameters:
      value - catalog value (path or URI).
      baseDirectory - base directory for relative values.
      Returns:
      resolved URI.
    • resolveToPath

      public static Path resolveToPath(String value, Path baseDirectory)
      Resolves a catalog coordinate to a local file system path when possible.
      Parameters:
      value - catalog value (path or URI).
      baseDirectory - base directory for relative values.
      Returns:
      resolved local path, or null for non-file URIs.